question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SciPy 1.7 builds as zipped egg, ruining imports

See original GitHub issue

When 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:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rgommerscommented, Sep 1, 2021

Here it says

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.

Is this the proper way?

Yes, that’s good. Or even simpler: pip install . -v (the -v so you see the build log) does it all in one go.

Unlike build, bdist_wheel does not allow the --fcompiler option. I would like to be able to supply this to the build process

Ah yes, that’s a problem. In such cases I’m afraid you still need setup.py build or setup.py build_ext.

How do I (programmatically) know where the .whl file ends up and what it is called? Is it guaranteed to end up as the only file in the ./dist directory?

Yes, that is guaranteed.

0reactions
jmd-dkcommented, Sep 1, 2021

@rgommers I guess this issue is solved, but now I have questions for my own sake. 🙂

python setup.py install

Obligatory comment: don’t do this, build a wheel instead and install that with pip. setup.py install is unsupported.

Here it says

python setup.py build
python setup.py install

is the way to go. How do I instead build a wheel and install this with pip? I find that I can successfully do

python setup.py bdist_wheel
pip install /path/to/freshly/build/wheel.whl

even without adding zip_safe=False. Is this the proper way? If so I have two minor problems:

  1. Unlike build, bdist_wheel does not allow the --fcompiler option. I would like to be able to supply this to the build process.
  2. How do I (programmatically) know where the .whl file ends up and what it is called? Is it guaranteed to end up as the only file in the ./dist directory?
Read more comments on GitHub >

github_iconTop Results From Across the Web

SciPy 1.7.2 Release Notes — SciPy v1.9.3 Manual
SciPy 1.7.2 is a bug-fix release with no new features compared to 1.7.1. ... #14599: SciPy 1.7 builds as zipped egg, ruining imports....
Read more >
Erroneous SciPy 1.7 source build - python - Stack Overflow
Looking at the site-packages directory I see that SciPy 1.7 installs itself as a zipped Python egg, whereas previous versions used to ...
Read more >
Mailman 3 ANN: SciPy 1.7.2 - NumPy-Discussion - python.org
SciPy 1.7.2 is a bug-fix release with no new features compared to 1.7.1. ... SciPy 1.7 builds as zipped egg, ruining imports *...
Read more >
Cannot install pygraphviz on MacOS · Issue #211 - GitHub
Failed to build pygraphviz Installing collected packages: ... Running command /usr/local/opt/python/bin/python3.7 -u -c 'import sys, ...
Read more >
Bug listing with status UNCONFIRMED as at 2022/12/21 06 ...
... and LDFLAGS used during build" status:UNCONFIRMED resolution: severity:normal ... running equery files under Python 3 with ROOT set" status:UNCONFIRMED ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found