setuptools: build_meta doesn't use a fresh dist directory, which causes ValueError unpacking tuple
If you use pip install .
on a source directory that already has a dist
, the existing directory structure is used when preparing the wheel. This causes an exception if an existing wheel with a different name exists, because build_meta assumes there’s only one wheel in dist
.
Here’s a script to create a MWE repo:
#!/usr/bin/bash
mkdir /tmp/demo_dist_517
cd /tmp/demo_dist_517
echo "from setuptools import setup; setup()" > setup.py
echo "0.0.1" > VERSION
cat > setup.cfg << EOF
[metadata]
name = foo
version = file: VERSION
EOF
cat > pyproject.toml << EOF
[build-system]
requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta"
EOF
At this point your repo looks like this:
$ tree
├── pyproject.toml
├── setup.cfg
├── setup.py
└── VERSION
Create a wheel in dist
, then change the version:
pip wheel . --no-deps -w dist
echo "0.0.2" > VERSION
Now try to create a wheel from the repo:
pip wheel . -w dist
This will trigger an error in
build_meta
: File “/tmp/pip-build-env-plomixa1/overlay/…/setuptools/build_meta.py”, line 157, in _file_with_extension file, = matching ValueError: too many values to unpack (expected 1) Building wheel for foo (PEP 517) … error Failed building wheel for foo
This is pretty easy to work around, obviously, since the user can just remove dist
before invoking any pip
commands, but it might be better to do the wheel build in a clean directory if possible.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 2
- Comments: 33 (31 by maintainers)
Commits related to this issue
- Ignore dists/ for now Because of a bug in setuptools (https://github.com/pypa/setuptools/issues/1671), building our files in `dist/` can cause build failures if dist/ is not cleaned out between build... — committed to pganssle/grid-strategy by pganssle 5 years ago
- Ignore dists/ for now Because of a bug in setuptools (https://github.com/pypa/setuptools/issues/1671), building our files in `dist/` can cause build failures if dist/ is not cleaned out between build... — committed to pganssle/grid-strategy by pganssle 5 years ago
- refactored the circleci wheel building workflow, specifically build_manylinux_wheels.sh, to leave all wheels in the wheelhouse after a run until a final run step in the circle config moves them all in... — committed to rndrr/pymssql by jsmntv 5 years ago
- Improve stability of manylinux1 build script This introduces workaround for setuptools' bug in PEP517 build backend: https://github.com/pypa/setuptools/issues/1671 — committed to aio-libs/aiohttp by webknjaz 5 years ago
- Merge pull request #1726 from florisla/issue-1671-test Add failing test for issue #1671 (ValueError when .whl is present) — committed to pypa/setuptools by mergify[bot] 5 years ago
- Add fix for #1671 — committed to shashanksingh28/setuptools by shashanksingh28 5 years ago
- Fix error when wheels already exist in dist/ `build_meta.build_wheel` assumes that the only wheel in its output directory is the one it builds, but prior to this, it also used the `dist/` folder as i... — committed to shashanksingh28/setuptools by shashanksingh28 5 years ago
- Fix error when wheels already exist in dist/ `build_meta.build_wheel` assumes that the only wheel in its output directory is the one it builds, but prior to this, it also used the `dist/` folder as i... — committed to shashanksingh28/setuptools by shashanksingh28 5 years ago
I’ll do it.
@webknjaz I have no objections, but I won’t have much time until this weekend at the earliest. @benoit-pierre or @jaraco feel free to cut a release.
Er, hold up, I just remembered that #1726 already implements a test for this and was just blocked on a bug that has since been fixed. Let me merge that.
I like @benoit-pierre’s proposal with a tmpdir. It’s clean and easy to understand. One minor suggestion: move the
return
instruction outside of with-block.OK, I don’t think there’s any harm in creating our own temporary directory for this. In that case we’ll probably also want to add a test (we can just parametrize the first test) for the situation where
wheel_directory
already has a wheel in it.It’s not explicitly mentioned in the PEP that it’s a temporary directory, at least not in the
build_wheel
section.That’s what I was thinking: