quaint-piano-62770
05/24/2024, 6:17 AMpython_distribution
target to package my project with a pyproject.toml
file. Everything works but I can’t seem to set the version
from the BUILD file. It forces me to fix the version
field in the pyproject.toml
itself. Example in thread.quaint-piano-62770
05/24/2024, 6:21 AMpython_distribution(
name="dist",
dependencies=[":readme", ":pyproject", ":source", ":manifest"],
provides=python_artifact(
name="my-project",
version="0.0.1",
),
generate_setup=False,
)
Except from pyproject.toml
file
[build-system]
requires = ["setuptools", "setuptools-scm", "wheel"]
build-backend = "setuptools.build_meta"
[project]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"Intended Audience :: Science/Research",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3.9",
"Topic :: Scientific/Engineering",
]
name = "my-project"
version = "2024.3"
When I try to pants package path/to/BUILD:dist
the generated package has the version 2024.3
instead of 0.0.1
from the BUILD file. If I try to remove the version
field from the pyproject.toml
file the command complains
ValueError: invalid pyproject.toml config: `project`.
configuration error: `project` must contain ['version'] properties
Eventually, I would like to do some sort of custom automatically generated version numbers so I don’t want to fix them in the pyproject.toml
file.curved-television-6568
05/24/2024, 6:56 AMimportant-hydrogen-79200
05/24/2024, 12:01 PMimportant-hydrogen-79200
05/24/2024, 12:12 PMproject.toml
file:
[project]
name = "oxygen"
dependencies = ["click"]
dynamic = ["version"]
[tool.setuptools.dynamic]
version = { "file" = "VERSION" }
[build-system]
requires = ["setuptools>=64", "setuptools_scm>=8", "wheel"]
build-backend = "setuptools.build_meta"
important-hydrogen-79200
05/24/2024, 12:12 PMpython_sources(name="lib", sources=["oxygen/**/*.py"])
python_requirements(source="pyproject.toml")
# pyproject.toml based distribution
resource(name="pyproject", source="pyproject.toml")
vcs_version(
name="version",
generate_to=str(build_file_dir() / "VERSION"),
template="{version}",
version_scheme="guess-next-dev",
local_scheme="no-local-version",
)
python_distribution(
name="dist",
dependencies=[":pyproject", ":lib", ":version"],
provides=python_artifact(),
generate_setup=False,
)
important-hydrogen-79200
05/24/2024, 12:14 PMquaint-piano-62770
05/24/2024, 1:38 PMquaint-piano-62770
05/24/2024, 5:05 PM0.1.dev64
. How can I specify the base version to bump from, say I wanted it to be 5.1
or something when I am on the main
branch and 5.1.dev64
when I am on dev
branch? Am I asking too much of setuptools-scm + the vcs_version target or is this possible? The setuptools-scm documentation does not clearly specify this.important-hydrogen-79200
05/24/2024, 5:07 PMhappy-kitchen-89482
05/24/2024, 6:42 PMversion
in python_artifact
is injected when Pants generates setup.py
for you, but if you use your own pyproject.toml
, that is treated as a static file, no munging of its fields is donehappy-kitchen-89482
05/24/2024, 6:42 PM