fix: use importlib to load scripts/generate_pyi.py instead of package…#355
Open
Mikezhang001 wants to merge 1 commit into
Open
fix: use importlib to load scripts/generate_pyi.py instead of package…#355Mikezhang001 wants to merge 1 commit into
Mikezhang001 wants to merge 1 commit into
Conversation
… import The top-level 'from scripts.generate_pyi import generate_pyi_file' in setup.py requires scripts/ to be a Python package (with __init__.py), but scripts/ is a utility directory and was never intended to be one. This was introduced in PR deepseek-ai#231 and causes ModuleNotFoundError when running install.sh or 'python setup.py bdist_wheel'. Replace the package-style import with importlib.util.spec_from_file_location to load the module by file path, which does not require __init__.py.
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.
Hi, I ran into an install issue and this PR fixes it.
What happened
Fresh clone +
./install.shblows up with:The root cause is that
setup.pydoesfrom scripts.generate_pyi import generate_pyi_fileat the top level, butscripts/doesn't have an__init__.py— so Python doesn't recognize it as a package.Looks like this was introduced in #231 when
generate_pyi.pywas added toscripts/.How to reproduce
What I changed
Instead of adding a
__init__.pytoscripts/(which feels wrong since it's not really a package), I moved the import intoCustomBuildPy.generate_pyi_file()and usedimportlibto load it by file path:This way
scripts/stays as a plain utility directory and the import only happens at build time when it's actually needed.Tested locally,
./install.shworks fine after the change.