build ignores specified version value
Question:
I am building a python project using this pyproject.toml
file
[tool.poetry]
name = "my_package"
version = "1.0.0"
description = "My precious"
readme = "README.md"
[tool.poetry.dependencies]
pandas = "1.4.3"
numpy = "1.22.4"
scikit-learn = "1.1.2"
xgboost = "1.6.1"
holidays = "0.14.2"
matplotlib = "3.4.3"
matplotlib-inline = "0.1.6"
numba = "0.56.4"
shap = "0.41.0"
pytest = "7.3.1"
[tool.pytest.ini_options]
testpaths = [
"tests"
]
[tool.poetry.build]
script = "build.py"
generate-setup-file=true
When running py -m build --wheel --outdir ..wheels
the wheel is correctly created but the filename is
my_package-0.0.0-py3-none-any.whl
So the version number seems to be ignored.
How do I correct this behavior?
EDIT:
I have noticed that by default build
uses setuptool, not poetry. However, changing the .toml file removing ".poetry" (ex. [tool.poetry]
to [tool]
) did not change the behavior.
WORKING SOLUTION:
[project]
name = "my_package"
version = "1.0.0"
description = "My precious"
readme = "README.md"
dependencies = [
"pandas==1.4.3",
"numpy==1.22.4",
"scikit-learn==1.1.2",
"xgboost==1.7.4",
"holidays==0.14.2",
"matplotlib==3.4.3",
"matplotlib-inline==0.1.6",
"numba==0.56.4",
"shap==0.41.0",
"pytest==7.3.1",
]
[tool.pytest.ini_options]
testpaths = [
"tests"
]
Note: another solution would have been to go with poetry but as for now xgboost does not get along with it (but from release 1.7.5 it will)
Answers:
I was just about to say, that you’re using setuptools rather than ‘poetry build …’
If you want to go with setuptools, then it is not [tool.poetry] or [tool], but [project] according to the specs
Edit: In this case, you’d need to declare dependencies inside [project] unless they’re optional, like so:
[project]
name = "my_package"
version = "1.0.0"
dependencies = [
"pandas==1.4.3"
"numpy==1.22.4"
...
]
I am building a python project using this pyproject.toml
file
[tool.poetry]
name = "my_package"
version = "1.0.0"
description = "My precious"
readme = "README.md"
[tool.poetry.dependencies]
pandas = "1.4.3"
numpy = "1.22.4"
scikit-learn = "1.1.2"
xgboost = "1.6.1"
holidays = "0.14.2"
matplotlib = "3.4.3"
matplotlib-inline = "0.1.6"
numba = "0.56.4"
shap = "0.41.0"
pytest = "7.3.1"
[tool.pytest.ini_options]
testpaths = [
"tests"
]
[tool.poetry.build]
script = "build.py"
generate-setup-file=true
When running py -m build --wheel --outdir ..wheels
the wheel is correctly created but the filename is
my_package-0.0.0-py3-none-any.whl
So the version number seems to be ignored.
How do I correct this behavior?
EDIT:
I have noticed that by default build
uses setuptool, not poetry. However, changing the .toml file removing ".poetry" (ex. [tool.poetry]
to [tool]
) did not change the behavior.
WORKING SOLUTION:
[project]
name = "my_package"
version = "1.0.0"
description = "My precious"
readme = "README.md"
dependencies = [
"pandas==1.4.3",
"numpy==1.22.4",
"scikit-learn==1.1.2",
"xgboost==1.7.4",
"holidays==0.14.2",
"matplotlib==3.4.3",
"matplotlib-inline==0.1.6",
"numba==0.56.4",
"shap==0.41.0",
"pytest==7.3.1",
]
[tool.pytest.ini_options]
testpaths = [
"tests"
]
Note: another solution would have been to go with poetry but as for now xgboost does not get along with it (but from release 1.7.5 it will)
I was just about to say, that you’re using setuptools rather than ‘poetry build …’
If you want to go with setuptools, then it is not [tool.poetry] or [tool], but [project] according to the specs
Edit: In this case, you’d need to declare dependencies inside [project] unless they’re optional, like so:
[project]
name = "my_package"
version = "1.0.0"
dependencies = [
"pandas==1.4.3"
"numpy==1.22.4"
...
]