Repository navigation
Make scipy optional again and declare packaging - #123
Closed
Kayvan-Zahiri wants to merge 1 commit into
Closed
Kayvan-Zahiri wants to merge 1 commit into
Kayvan-Zahiri wants to merge 1 commit into
Conversation
Since seekpath/__init__.py started importing brillouinzone (2024), scipy, which is only the `bz` extra, became required for `import seekpath`. Import scipy inside BZ._initialize_BZ instead. hpkot/tools.py also imports packaging, which was never declared, so get_path failed on a clean install.
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On a clean install of seekpath 2.2.1 (no
bzextra),import seekpathfails:scipy is listed only under the
bzextra, and the tests already skip the Brillouin zone tests when it's missing, butseekpath/__init__.pyhas importedbrillouinzonesince cffa9d5 (March 2024), and that module importsscipy.spatialat the top.Two changes:
brillouinzone.pyimportsscipy.spatialinsideBZ._initialize_BZ, the only place it's used at runtime. The return annotations onhullanddelaunaystay as they are throughfrom __future__ import annotationsand aTYPE_CHECKINGimport. Building aBZwithout scipy still raisesModuleNotFoundError: No module named 'scipy'.get_pathhit a second missing dependency:hpkot/tools.pyimportspackaging, which isn't declared. I added it todependencies.Tested: in a clean Python 3.12 venv with a plain install (no scipy),
import seekpathandseekpath.get_path(...)work on this branch; on 2.2.1 the import fails. With.[bz]installed, the full test suite passes (77 tests, including the newtests/test_import_without_scipy.py, which blocks scipy in a subprocess and imports seekpath; it fails without this change). The trailing-whitespace, end-of-file, quote-fixer, flynt and ruff hooks pass on the changed files.Written with AI assistance. The runs above are real.