SciPy 1.7 builds as zipped egg, ruining imports
See original GitHub issueWhen building SciPy 1.7.1 from source I end up with a broken build which is unable to import e.g. scipy.optimize
, as described in this Stack Overflow post. The installation finished without errors, though. I can (and have for years) successfully build SciPy 1.6, 1.5, 1.4. It turns out that SciPy 1.7 (at least on my system, for whatever reason) installs as a zipped Python egg to site-packages
, rather than as a directory.
Solution
Supplying zip_safe = False
to setuptools.setup()
in setup.py
does the trick. That is, zip_safe
should be added to the metadata
variable.
I wonder why this is not there already. Is it ever safe to build SciPy as a zipped archive?
Looking at NumPy’s setup.py
, we indeed find zip_safe=False
inside metadata
.
Version information:
Python 3.9.6 SciPy 1.7.1 NumPy 1.21.1 Cython 0.29.24 gcc 9.3.0 Linux Mint, kernel 5.11.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Yeah, sorry about that - we have a lot of build docs, and they’re always in need of improvements. There’s too many ways to build and set up environments.
Yes, that’s good. Or even simpler:
pip install . -v
(the-v
so you see the build log) does it all in one go.Ah yes, that’s a problem. In such cases I’m afraid you still need
setup.py build
orsetup.py build_ext
.Yes, that is guaranteed.
@rgommers I guess this issue is solved, but now I have questions for my own sake. 🙂
Here it says
is the way to go. How do I instead build a wheel and install this with
pip
? I find that I can successfully doeven without adding
zip_safe=False
. Is this the proper way? If so I have two minor problems:build
,bdist_wheel
does not allow the--fcompiler
option. I would like to be able to supply this to the build process..whl
file ends up and what it is called? Is it guaranteed to end up as the only file in the./dist
directory?