You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to use dynamic metadata (as described in the docs here) to load the version of my package in pyproject.toml from a file. I first tried using version = { file = "src/VERSION" }, and I found that if i do this, setuptools includes / in the SOURCES.txt; however, pip/setuptools can't handle this and will fail to build the package when installing it from source.
After some trial and error, a colleague of mine identified that if we make file into a list, the problem goes away:
[tool.setuptools.dynamic]
version = {file = ["src/VERSION"]}
Looking in the documentation, i see other examples of files being specified as lists (e.g. requirements.txt dynamic loading) but there is no example of specifying the version using a file.
Expected behavior
I could imagine two potential outcomes that would make sense in my head
setuptools metadata interprets {file = "src/VERSION"} the same as {file = ["src/VERSION"]}
setuptools throws an error if it does not get a list. To me, this is less intuitive (i can't imagine why anyone would need more than one file to specify the version) however it does provide quicker feedback about what is wrong and how to fix it.
How to Reproduce
download and unzip the attached MWE and cd into the directory
install build: pip install build
run the build command: python -m build --sdist
(in a virtualenv) install the resulting sdist: pip install dist/sample_project-0.1.0.tar.gz
Output
Output of step 3 (note '/' not a regular file -- skipping 2/3 of the way down):
$ python -m build --sdist* Creating venv isolated environment...* Installing packages in isolated environment... (setuptools >= 61.0.0)* Getting build dependencies for sdist.../private/var/folders/fx/35b0z9051xz_8hmylnf2j4b80000gn/T/build-env-sjxd0z_i/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*. warnings.warn(msg, _BetaConfiguration)running egg_infowriting src/sample_project.egg-info/PKG-INFOwriting dependency_links to src/sample_project.egg-info/dependency_links.txtwriting top-level names to src/sample_project.egg-info/top_level.txtreading manifest file 'src/sample_project.egg-info/SOURCES.txt'reading manifest template 'MANIFEST.in'writing manifest file 'src/sample_project.egg-info/SOURCES.txt'* Building sdist.../private/var/folders/fx/35b0z9051xz_8hmylnf2j4b80000gn/T/build-env-sjxd0z_i/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*. warnings.warn(msg, _BetaConfiguration)running sdistrunning egg_infowriting src/sample_project.egg-info/PKG-INFOwriting dependency_links to src/sample_project.egg-info/dependency_links.txtwriting top-level names to src/sample_project.egg-info/top_level.txtreading manifest file 'src/sample_project.egg-info/SOURCES.txt'reading manifest template 'MANIFEST.in'writing manifest file 'src/sample_project.egg-info/SOURCES.txt'warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.mdrunning checkcreating sample_project-0.1.0creating sample_project-0.1.0/srccreating sample_project-0.1.0/src/sample_project.egg-infocopying files to sample_project-0.1.0...copying MANIFEST.in -> sample_project-0.1.0copying pyproject.toml -> sample_project-0.1.0'/' not a regular file -- skippingcopying src/VERSION -> sample_project-0.1.0/srccopying src/__init__.py -> sample_project-0.1.0/srccopying src/sample_project.egg-info/PKG-INFO -> sample_project-0.1.0/src/sample_project.egg-infocopying src/sample_project.egg-info/SOURCES.txt -> sample_project-0.1.0/src/sample_project.egg-infocopying src/sample_project.egg-info/dependency_links.txt -> sample_project-0.1.0/src/sample_project.egg-infocopying src/sample_project.egg-info/top_level.txt -> sample_project-0.1.0/src/sample_project.egg-infoWriting sample_project-0.1.0/setup.cfgCreating tar archiveremoving 'sample_project-0.1.0' (and everything under it)Successfully built sample_project-0.1.0.tar.gz
Contents of dist/sample_project-0.1.0.tar.gz/src/sample_project.egg_info/SOURCES.txt produced by step 3:
$ python -m pip install dist/sample_project-0.1.0.tar.gzLooking in indexes: https://pypi.org/simple, https://dig-grid-artifactory.apps.ge.com/artifactory/api/pypi/opus-one-pypi-virtual/simpleProcessing ./dist/sample_project-0.1.0.tar.gz Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... doneBuilding wheels for collected packages: sample-project Building wheel for sample-project (pyproject.toml) ... error error: subprocess-exited-with-error × Building wheel for sample-project (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [22 lines of output] /private/var/folders/fx/35b0z9051xz_8hmylnf2j4b80000gn/T/pip-build-env-wlxo9tub/overlay/lib/python3.10/site-packages/setuptools/config/pyprojecttoml.py:108: _BetaConfiguration: Support for `[tool.setuptools]` in `pyproject.toml` is still *beta*. warnings.warn(msg, _BetaConfiguration) running bdist_wheel running build running build_py creating build creating build/lib copying src/__init__.py -> build/lib running egg_info writing src/sample_project.egg-info/PKG-INFO writing dependency_links to src/sample_project.egg-info/dependency_links.txt writing top-level names to src/sample_project.egg-info/top_level.txt reading manifest file 'src/sample_project.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' writing manifest file 'src/sample_project.egg-info/SOURCES.txt' error: Error: setup script specifies an absolute path: / setup() arguments must *always* be /-separated paths relative to the setup.py directory, *never* absolute paths. [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for sample-projectFailed to build sample-projectERROR: Could not build wheels for sample-project, which is required to install pyproject.toml-based projects
The text was updated successfully, but these errors were encountered:
@AnjoMan CI is working in a new patch release (it may take some time), but soon it should be available on PyPI, please let me know if the fix does not work as intended.
Ok nice, i was able to install 66.1.1 and the sample project now builds as expected, and i can pip install the resulting sdist. I think the issue is addressed! Thanks so much!
setuptools version
setuptools==66.1.0
Python version
Python 3.10
OS
macOS
Additional environment information
No response
Description
I am trying to use dynamic metadata (as described in the docs here) to load the version of my package in
pyproject.toml
from a file. I first tried usingversion = { file = "src/VERSION" }
, and I found that if i do this, setuptools includes/
in theSOURCES.txt
; however, pip/setuptools can't handle this and will fail to build the package when installing it from source.I've attached an MWE (sample_project.zip), but the key files are below:
My
pyproject.toml
:Contents of
src/VERSION
:After some trial and error, a colleague of mine identified that if we make
file
into a list, the problem goes away:Looking in the documentation, i see other examples of files being specified as lists (e.g.
requirements.txt
dynamic loading) but there is no example of specifying the version using a file.Expected behavior
I could imagine two potential outcomes that would make sense in my head
setuptools
metadata interprets{file = "src/VERSION"}
the same as{file = ["src/VERSION"]}
setuptools
throws an error if it does not get a list. To me, this is less intuitive (i can't imagine why anyone would need more than one file to specify the version) however it does provide quicker feedback about what is wrong and how to fix it.How to Reproduce
cd
into the directorybuild
:pip install build
python -m build --sdist
pip install dist/sample_project-0.1.0.tar.gz
Output
Output of step 3 (note
'/' not a regular file -- skipping
2/3 of the way down):Contents of
dist/sample_project-0.1.0.tar.gz/src/sample_project.egg_info/SOURCES.txt
produced by step 3:Output of step 4:
The text was updated successfully, but these errors were encountered: