-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ModuleNotFoundError on local import #386
Comments
I have the same symptom but a different package structure. I have my version specified in a $ python -m pip install .
[...]
File "/tmp/pip-build-env-pwmxd890/overlay/lib/python3.8/site-packages/flit_core/common.py", line 165, in get_docstring_and_version_via_import
m = sl.load_module()
File "<frozen importlib._bootstrap_external>", line 462, in _check_name_wrapper
File "<frozen importlib._bootstrap_external>", line 962, in load_module
File "<frozen importlib._bootstrap_external>", line 787, in load_module
File "<frozen importlib._bootstrap>", line 265, in _load_module_shim
File "<frozen importlib._bootstrap>", line 702, in _load
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/pip-req-build-id8hntg4/wn/__init__.py", line 37, in <module>
from wn._meta import __version__
ModuleNotFoundError: No module named 'wn' This happens when I try to install via |
In the latter case, does it work if you use a relative import ( Background: Flit has two ways of getting the version number from your code. It prefers static analysis to find a One thing I've been thinking of is having some way to configure where it looks for the version, so you could use the simpler static analysis method even if [tool.flit.version]
module = "wn._meta" # Or a filename - not sure which is better yet
name = "__version__" # This would be the default
method = "static" # as opposed to "import" |
Yes, that does seem to help when installing with
Glad to see you're thinking of this. I suggested something similar in #253 (comment), but without the option of customizing the variable name or retrieval method. E.g: [tool.flit.metadata]
version-location = "wn._meta" Here I assumed the module would be loaded completely independently of the main module (in which case maybe a filename is better), thus sidestepping the dependency issue with regular imports and also allowing people to use |
The same problem as with |
From my usage so far a clear error message would suffice, e.g. "Can't
find __doc__ and __version__, please specify in pyproject.toml or
__init__.py". I just got a ModuleNotFound error and I searched for a
problem in my package and in virtualenv until I fired pdb and checked
the source.
…On Fri, Apr 9, 2021 at 20:57, Michael Wayne Goodman ***@***.***> wrote:
@smidm good point. Being able to specify a location for all the
metadata that is expected to be in the top __init__.py would also
help with projects where the main package is a namespace package.
That is, this is essentially the same solution as is proposed for
#370. Two birds one stone?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
I've run into this issue too with flit. It is not an issue with setuptools' declarative configuration
the proposed solutions above look like good candidates! |
Bug: pypa/flit#386 Bug: https://gitlab.com/stavros/python-yeelight/-/issues/84 Signed-off-by: Louis Leseur <louis.leseur@gmail.com>
flit
fails on import of local package that is present in subdir.The package
kaitaiStructCompile
is perfectly visible and importable with plain Python 3.Flit settings specify
ksykaitai.py
from root dir.The directory tree is below.
To repeat.
The text was updated successfully, but these errors were encountered: