Misleading exception message, bug?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 1.4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 1
Description
setuptools version
setuptools==78.1.0
Python version
Python 3.10.12
OS
Linux, Ubuntu 22.04.5 LTS
Additional environment information
Path info:
.../build_bug_poc
pyprojec.toml
/src
/build_bug_poc
main.py
/config
about.py
pyproject.toml contains the following:
[project]
name = "build-bug-poc"
dynamic = ["version"]
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.10"
dependencies = []
[tool.setuptools.dynamic]
version = {attr = "build_bug_poc.__about__.__version__"}
Description
Python 3.10.12
Upon building this project the build fails with this exception error:
ModuleNotFoundError: No module named 'build_bug_poc'
ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist
This is clearly false, as several lines before going into the crash it shows this information:
discovered packages -- ['build_bug_poc', 'build_bug_poc.config'] so it's detecting things just fine.
Expected behavior
I expect an error message saying that there is a problem in pyproject.toml, specifically that the file "about.py" isn't found in the location defined.
i.e. a file not found error rather than a module not found, and with the correct name about instead of "buid_bug_poc".
How to Reproduce
with this pyproject.toml issue python3 -m build and it'll crash with the error.
Output
python3 -m build --verbose
* Creating isolated environment: venv+pip...
> /tmp/build-env-u65zu66r/bin/python -Im pip uninstall -y setuptools
< Found existing installation: setuptools 59.6.0
< Uninstalling setuptools-59.6.0:
< Successfully uninstalled setuptools-59.6.0
* Installing packages in isolated environment:
- setuptools >= 40.8.0
> /tmp/build-env-u65zu66r/bin/python -Im pip install --use-pep517 --no-warn-script-location --no-compile -r
/tmp/build-reqs-wt42rltx.txt
< Collecting setuptools>=40.8.0
< Using cached setuptools-78.1.0-py3-none-any.whl (1.3 MB)
< Installing collected packages: setuptools
< Successfully installed setuptools-78.1.0
* Getting build dependencies for sdist...
No `packages` or `py_modules` configuration, performing automatic discovery.
`src-layout` detected -- analysing ./src
discovered packages -- ['build_bug_poc', 'build_bug_poc.config']
discovered py_modules -- []
Traceback (most recent call last):
File "/proj/python/build_bug_poc/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
main()
File "/proj/python/build_bug_poc/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 373, in main
json_out["return_val"] = hook(**hook_input["kwargs"])
File "/proj/python/build_bug_poc/.venv/lib/python3.10/site-packages/pyproject_hooks/_in_process/_in_process.py", line 317, in get_requires_for_build_sdist
return hook(config_settings)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/build_meta.py", line 337, in get_requires_for_build_sdist
return self._get_build_requires(config_settings, requirements=[])
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/build_meta.py", line 304, in _get_build_requires
self.run_setup()
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/build_meta.py", line 522, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/build_meta.py", line 320, in run_setup
exec(code, locals())
File "<string>", line 1, in <module>
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup
return distutils.core.setup(**attrs)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 160, in setup
dist.parse_config_files()
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/dist.py", line 756, in parse_config_files
pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 72, in apply_configuration
config = read_configuration(filepath, True, ignore_option_errors, dist)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 144, in read_configuration
return expand_configuration(asdict, root_dir, ignore_option_errors, dist)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 169, in expand_configuration
return _ConfigExpander(config, root_dir, ignore_option_errors, dist).expand()
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 217, in expand
self._expand_all_dynamic(dist, package_dir)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 262, in _expand_all_dynamic
version=self._obtain_version(dist, package_dir),
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 313, in _obtain_version
self._obtain(dist, "version", package_dir) # pyright: ignore[reportArgumentType]
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 300, in _obtain
return self._expand_directive(
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py", line 294, in _expand_directive
return _expand.read_attr(directive["attr"], package_dir, root_dir)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/expand.py", line 182, in read_attr
spec = _find_spec(module_name, path)
File "/tmp/build-env-u65zu66r/lib/python3.10/site-packages/setuptools/config/expand.py", line 196, in _find_spec
spec = spec or importlib.util.find_spec(module_name)
File "/usr/lib/python3.10/importlib/util.py", line 94, in find_spec
parent = __import__(parent_name, fromlist=['__path__'])
ModuleNotFoundError: No module named 'build_bug_poc'
ERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The traceback points to setuptools/config/pyprojecttoml.py and setuptools/config/expand.py; begin at _obtain_version and read_attr, then reproduce the failure with the supplied pyproject.toml and src layout. Check how the dynamic version attribute is resolved after package discovery. Done means the error identifies the missing about.py or attribute accurately, with regression coverage for this reproduction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100