Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 16743

How to set dynamic version for tool.setuptools_scm in pyproject.toml

$
0
0

I'm trying to test the pyproject.toml by building an example.

If I deleted the line "[tool.setuptools_scm]", the build will success, but adding that line, the build will fail with the following error.

Here is the pyproject.toml: /test/example/pyproject.toml

[project]name = "example"dynamic = ["version"][tool.setuptools.dynamic]version = {attr = "example.__version__"}[tool.setuptools_scm]

When building with this command:

# cd /test/example# python -m build --no-isolation

Here is the error:

* Getting build dependencies for sdist...Traceback (most recent call last):  File "/usr/local/lib/python3.10/dist-packages/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>    main()  File "/usr/local/lib/python3.10/dist-packages/pyproject_hooks/_in_process/_in_process.py", line 335, in main    json_out['return_val'] = hook(**hook_input['kwargs'])  File "/usr/local/lib/python3.10/dist-packages/pyproject_hooks/_in_process/_in_process.py", line 287, in get_requires_for_build_sdist    return hook(config_settings)  File "/usr/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 328, in get_requires_for_build_sdist    return self._get_build_requires(config_settings, requirements=[])  File "/usr/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 295, in _get_build_requires    self.run_setup()  File "/usr/local/lib/python3.10/dist-packages/setuptools/build_meta.py", line 311, in run_setup    exec(code, locals())  File "<string>", line 1, in <module>  File "/usr/local/lib/python3.10/dist-packages/setuptools/__init__.py", line 103, in setup    return distutils.core.setup(**attrs)  File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/core.py", line 147, in setup    _setup_distribution = dist = klass(attrs)  File "/usr/local/lib/python3.10/dist-packages/setuptools/dist.py", line 303, in __init__    _Distribution.__init__(self, dist_attrs)  File "/usr/local/lib/python3.10/dist-packages/setuptools/_distutils/dist.py", line 283, in __init__    self.finalize_options()  File "/usr/local/lib/python3.10/dist-packages/setuptools/dist.py", line 654, in finalize_options    ep(self)  File "/usr/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py", line 121, in infer_version    _assign_version(dist, config)  File "/usr/local/lib/python3.10/dist-packages/setuptools_scm/_integration/setuptools.py", line 56, in _assign_version    _version_missing(config)  File "/usr/local/lib/python3.10/dist-packages/setuptools_scm/_get_version_impl.py", line 112, in _version_missing    raise LookupError(LookupError: setuptools-scm was unable to detect version for /test/example.Make sure you're either building from a fully intact git repository or PyPI tarballs. Most other sources (such as GitHub's tarballs, a git checkout without the .git folder) don't contain the necessary metadata and will not work.For example, if you're using pip, instead of https://github.com/user/proj/archive/master.zip use git+https://github.com/user/proj.git#egg=projERROR Backend subprocess exited when trying to invoke get_requires_for_build_sdist

What's the correct configuration for [tool.setuptools_scm] in pyproject.toml?


Viewing all articles
Browse latest Browse all 16743

Trending Articles