I'm trying to build a custom python package, with pyproject.toml
. I added a setup.py
just for a development and editable environment. (see https://snarky.ca/what-the-heck-is-pyproject-toml/)
pyproject-toml
file :
[build-system]
requires = ["setuptools == 44.1.1", "wheel"]
build-backend = "setuptools.build_meta"
[tool.pytest.ini_options]
testpaths = ["tests"]
I upgraded python build with python3 -m pip install --upgrade build
When i run python3 -m build
I get this error :
...
Successfully installed setuptools-44.1.1 wheel-0.36.2
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pep517/_in_process.py", line 280, in <module>
main()
File "/usr/lib/python3/dist-packages/pep517/_in_process.py", line 263, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/usr/lib/python3/dist-packages/pep517/_in_process.py", line 114, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/build_meta.py", line 146, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/build_meta.py", line 127, in _get_build_requires
self.run_setup()
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/build_meta.py", line 142, in run_setup
exec(compile(code, __file__, 'exec'), locals())
File "setup.py", line 6, in <module>
setuptools.setup()
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/__init__.py", line 162, in setup
return distutils.core.setup(**attrs)
File "/usr/lib/python3.9/distutils/core.py", line 121, in setup
dist.parse_config_files()
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/_virtualenv.py", line 21, in parse_config_files
result = old_parse_config_files(self, *args, **kwargs)
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/dist.py", line 701, in parse_config_files
parse_configuration(self, self.command_options,
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/config.py", line 121, in parse_configuration
meta.parse()
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/config.py", line 426, in parse
section_parser_method(section_options)
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/config.py", line 399, in parse_section
self[name] = value
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/config.py", line 184, in __setitem__
value = parser(value)
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/config.py", line 515, in _parse_version
version = self._parse_attr(value, self.package_dir)
File "/tmp/build-env-qw5973cj/lib/python3.9/site-packages/setuptools/config.py", line 349, in _parse_attr
module = import_module(module_name)
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'version'
ERROR Backend subproccess exited when trying to invoke get_requires_for_build_wheel
I don't understand the source of the error, which seems to not have a link with my code.
People usually set the variable __version__
in a module, a file named version.py
, to specify the version informattion and make it available to the world to inspect, see pep-0396 for detailed explanation. So the traceback might indicate the lack of version file in your package.