Poetry build is naming the wheel incorrectly
See original GitHub issue-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvv
option). -
macOS 10.15.7
-
1.1.4
-
poetry-core 1.0.0
Issue
This is a spin off of #3508 as further investigation revealed there were two problems uncovered. This is about the naming of the wheels when using poetry build
.
Poetry is giving the wrong version tag to the built wheel. The following is the output of Poetry build:
$ poetry build
Building build_test (0.1.0)
- Building sdist
- Built build_test-0.1.0.tar.gz
- Building wheel
A setup.py file already exists. Using it.
running build
running build_py
- Built build_test-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl
- Note that the Py version is 3.9 but below, the project is shown to be exclusively 3.8. In fact, the only place where Python 3.9 is installed on my system is either through brew as a dependency for something or through the pipx isolated environment used to install Poetry.
- Even though the build script does nothing, and even if there was something to do, the build would be executed in the correct venv (I’ve verified this) meaning that the issue really is just with the name of the wheel.
Here is how poetry is installed:
$ pipx list
venvs are in /Users/alexifm/.local/pipx/venvs
apps are exposed on your $PATH at /Users/alexifm/.local/bin
package poetry 1.1.4, Python 3.9.1
- poetry
Poetry config:
$ poetry config --list
cache-dir = "/Users/alexifm/Library/Caches/pypoetry"
experimental.new-installer = true
installer.parallel = true
virtualenvs.create = false
virtualenvs.in-project = null
virtualenvs.path = "{cache-dir}/virtualenvs" # /Users/alexifm/Library/Caches/pypoetry/virtualenvs
And here is the project definition that requires a build (note that the project is exclusively Python 3.8).
Project virtual environment:
$ pyenv versions
system
3.8.5
3.8.5/envs/build_test
* build_test (set by /Users/alexifm/Projects/build_test/.python-version)
pyproject.toml
:
[tool.poetry]
name = "build_test"
version = "0.1.0"
description = ""
authors = ["Alex Papanicolaou <alex@infima.io>"]
build = "build.py"
[tool.poetry.dependencies]
python = "~3.8"
[tool.poetry.dev-dependencies]
pytest = "^5.2"
[build-system]
requires = ["poetry_core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
build.py
:
"""No build."""
def build(setup_kwargs):
"""Build."""
pass
Probable Reason
poetry-core
generates the information for the wheel tag here:
https://github.com/python-poetry/poetry-core/blob/master/poetry/core/masonry/builders/wheel.py#L244
The vendored packaged packaging
produces the tags here:
https://github.com/python-poetry/poetry-core/blob/master/poetry/core/_vendor/packaging/tags.py#L744
Finally, it looks like since no kwargs are passed to sys_tags
, then the argument python_version
isn’t passed to cpython_tags
and it defaults to the system Python, ie whatever is running Poetry.
https://github.com/python-poetry/poetry-core/blob/master/poetry/core/_vendor/packaging/tags.py#L234
Issue Analytics
- State:
- Created 3 years ago
- Comments:29
I just replicated using Poetry’s own virtual environments so it’s not a pyenv thing.
ETA: It’s also not a pipx thing as I can replicate it with Poetry installed through homebrew.
To be honest though I strongly recommend just not using poetry for building your stuff. It’s too buggy and opinionated around local environments so it doesn’t offer what’s needed to true publishing. Utilizing the build project has been a much nicer experience.