I successfully built my first Python-Package using a pyproject.toml
with setuptools
. I am able to install it and use it in Python, however I wonder the name of the project is “UNKNOWN
” and the version 0.0.0
, despite set differently in the configuration.
When I reinstall the *.whl
and *.tar.gz
files (some small changes were made from version 1.0 to version 1.1), I get the following output in the console:
> pip3 install myproject_qohelet-1.1.tar.gz
Defaulting to user installation because normal site-packages is not writeable
Processing ./myproject_qohelet-1.1.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: UNKNOWN
Building wheel for UNKNOWN (pyproject.toml) ... done
Created wheel for UNKNOWN: filename=UNKNOWN-0.0.0-py3-none-any.whl size=961 sha256=4e10d08c20a9cd5289d673d0627b53012bd917c1372fe681dd6aaa3f4ab64cb0
Stored in directory: /home/qohelet/.cache/pip/wheels/a8/0a/3d/225cba37f15f2ed307317d99dac03d622d5126e236877dc072
Successfully built UNKNOWN
Installing collected packages: UNKNOWN
Attempting uninstall: UNKNOWN
Found existing installation: UNKNOWN 0.0.0
Uninstalling UNKNOWN-0.0.0:
Successfully uninstalled UNKNOWN-0.0.0
Successfully installed UNKNOWN-0.0.0
Why does it call the package UNKNOWN-0.0.0
? Did I forget something in my configuration?
Here the pyproject.toml
:
title = "myProject"
[owner]
name = "Qohelet"
[build-system]
requires = ["setuptools", "setuptools-scm"]
build-backend = "setuptools.build_meta"
[project]
name = "myproject_qohelet"
version = "1.1"
authors = [
{ name="Qohelet", email="[email protected]" },
]
license = { text = "GPL" }
description = "This is a project that can be installed with pip"
readme = "README.md"
requires-python = ">=3.7"
classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
[project.urls]
"Homepage" = "https://gitlab.com/qohelet/myProject"
"Bug Tracker" = "https://gitlab.com/qohelet/myProject/-/issues"
The project is built with the following commands:
python3 -m pip install --upgrade build
python3 -m build
Edit (1):
This behavior only relates to the .tar.gz
, but the wheel
is less verbose:
> pip3 install myproject_qohelet-1.1-py3-none-any.whl --force-reinstall
Defaulting to user installation because normal site-packages is not writeable
Processing ./myproject_qohelet-1.1-py3-none-any.whl
Installing collected packages: myproject-qohelet
Attempting uninstall: myproject-qohelet
Found existing installation: myproject_qohelet 1.1
Uninstalling myproject_qohelet-1.1:
Successfully uninstalled myproject_qohelet-1.1
Successfully installed myproject-qohelet-1.1
Seems to be a problem of PIP building its own wheels from the tar ball, when it only contains pyproject.toml, and no setup.py or setup.cfg.
Although you are right on that being the correct packaging structure (and you have properly built wheels when using build), pip install from source files seems to have had to adapt iteratively to that change from setup to pyproject.toml.
I ended up solving the problem by upgrading pip from 22.0.2 to 24.0 (pip install --upgrade pip
) and then it worked.
I wonder if the title keyword and owner table are throwing off the metadata extraction from pyproject.toml, as they are not part of the pyproject.toml specification packaging.python.org/en/latest/specifications/pyproject-toml
Removed title keyword and owner table, no changes @LourençoMonteiroRodrigues
Yes, also tested it, and saw that the package info is correct after build, event with those extra fields on the pyproject.toml
and the UNKNOWN error only happens when instaling the tar.gz, but installing the wheel works well
@LourençoMonteiroRodrigues – that is correct. I added the installing of the wheel in the Post