question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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:open
  • Created 3 years ago
  • Comments:29

github_iconTop GitHub Comments

3reactions
alexifmcommented, Dec 28, 2020

I just replicated using Poetry’s own virtual environments so it’s not a pyenv thing.

$ poetry build -vvv                     
Using virtualenv: /Users/alexifm/Library/Caches/pypoetry/virtualenvs/build-test-9tgLzTmA-py3.8   # <- Poetry's Py3.8 environment
Building build_test (0.1.0)
  - Building sdist
  - Adding: /Users/alexifm/Projects/build_test/build_test/__init__.py
  - Adding: pyproject.toml
  - Built build_test-0.1.0.tar.gz
  - Building wheel
  - Adding: /Users/alexifm/Projects/build_test/build_test/__init__.py
running build
running build_py
Skipping: /Users/alexifm/Projects/build_test/COPYING
Skipping: /Users/alexifm/Projects/build_test/LICENSE
  - Built build_test-0.1.0-cp39-cp39-macosx_10_15_x86_64.whl   # <- Named with 3.9 used to run Poetry (pipx)

ETA: It’s also not a pipx thing as I can replicate it with Poetry installed through homebrew.

2reactions
tedivmcommented, Dec 19, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Configuration | Documentation | Poetry - Python dependency ...
The environment variables must be prefixed by POETRY_ and are comprised of the uppercase name of the setting and with dots and dashes...
Read more >
How do I properly change package name built with poetry?
Change the name field in pyproject.toml , run poetry update (not sure that's needed but do it just in case?) and change the...
Read more >
Dependency Management With Python Poetry
You can create a new Poetry project by using the new command and a project name as an argument. In this tutorial, the...
Read more >
4. Package structure and distribution
wheel }. The build steps here are where packaging tools like poetry , flit , or setuptools ...
Read more >
Poetry Advance - Python Biella Group
create a project in python using Poetry ... **poetry add [package-name]** ... you encouter problem when installing deps # Add and install dependency...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found