astral-sh / rye

a Hassle-Free Python Experience
https://rye.astral.sh
MIT License
13.82k stars 467 forks source link

Support for full hatchling versioning. #1026

Open jeeftor opened 7 months ago

jeeftor commented 7 months ago

It looks like hatchling is being used under the hood. In my use case I'd like to utilize test.pypi and when I was using poetry I could do .dev versions.

The first one here was uploaded with rye but I found I couldn't easily support .dev versions

image

However to the best of my knowledge you are using hatchling under the hood.

I did the following:

Modified my pyproject:

image

Then I ran

image

So it looks like it wouldn't be to hard to implement a -dev version flag somehow.

jeeftor commented 7 months ago

image

Also here it looks like Rye can build fine with the modified version string in the pyproject.toml

jeeftor commented 7 months ago

I see I can call this directly as well:

image

So I guess I'm adding for an additional option to add a -dev version in

jeeftor commented 7 months ago

In any case this is my work around in GitHub action:

image

geodab commented 7 months ago

If you tag your releases then an alternative workaround to consider might be to switch the backend from hatchling to setuptools and then use the standard configuration of setuptools_scm to dynamically generate the version based on the latest tagged version and commit state. Between tagged releases the default versioning scheme for that setup will automatically include a devN component based on the commit distance from the latest version tag, and you can run rye version to see the dynamically computed version. Here's the relevant snippets of configuration required in the pyproject.toml to enable that:

[project]
#version = "dynamic"
dynamic = ["version"]

[build-system]
requires = ["setuptools>=69", "setuptools_scm>=8"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
# can be empty if no extra settings are needed, presence enables setuptools_scm
ofek commented 6 months ago

Hatchling supports that directly and the maintainer uses this as well https://github.com/ofek/hatch-vcs