botify-labs / simpleflow

Python library for dataflow programming.
https://botify-labs.github.com/simpleflow/
MIT License
68 stars 24 forks source link

Introduce "hatch" to build & release #435

Closed jbbarth closed 1 month ago

jbbarth commented 10 months ago

Description

This PR introduces the "hatch" library to build eggs/wheels, publish, increment versions. It works a lot better (imho) than setuptools so we should use it πŸš€

Details

I was polluted on my computer by weird behaviours (probably related to my PYTHONPATH pyenv setup, previously installed simpleflow, etc. etc.). So I tested on a docker containers, see below.

Installing from git (first commit)

Basically this is enough:

[build-system]
requires = ["hatchling>=1.5.0"]
build-backend = "hatchling.build"

[tool.hatch.version]
path = "simpleflow/__init__.py"

Test:

docker run -v $(pwd)/dist:/tmp/dist -it python bash -c 'pip install --verbose git+https://github.com/botify-labs/simpleflow@fix-git-install >/dev/null; python -c "import simpleflow; print(simpleflow.__version__); print(simpleflow);"; ls /usr/local/lib/python3.12/site-packages/; ls /usr/local/lib/python3.12/site-packages/simpleflow/'

=> we can import simpleflow => no extra directory (default config of hatchling is nice!) => we have the subdirectories

Building an egg or wheel (second commit)

We need to add this so the resulting tarball egg (tar.gz) or wheel (whl) only contain the "simpleflow" folder.

[tool.hatch.build]
include = ["/simpleflow"]

Test:

rm -rf dist/s*
hatch build -c
docker run -v $(pwd)/dist:/tmp/dist -it python bash -c 'pip install /tmp/dist/simpleflow-0.33.1rc1-py3-none-any.whl >/dev/null; python -c "import simpleflow; print(simpleflow.__version__); print(simpleflow);"; ls /usr/local/lib/python3.12/site-packages/'

=> we get simpleflow installed, with no extra directory.

Releasing (third commit)

I adapted the "script/release" script and tested the best I could, but didn't get to the "publish" step yet. I'm curious @ybastide if this could work for you: the version now doesn't preview an automated increment, but you can provide a specific version or rely on hatch goodies to update the number you want ("minor", "patch", etc.).

I think it will work. If you're OK with the rest I can test further of course.

ybastide commented 10 months ago

Nice! I was about to suggest trying

hatch publish -r test

but can't add you to the project (no verified primary email)

Edit: ran the command successfully πŸ™‚

ybastide commented 2 months ago

πŸ‘‹ Hi @jbbarth πŸ™‚

I had forgotten about this branch and redid one using build (Joachim noticed the presence of other unwanted artifacts in the previous versions I pushed, but feel free to merge them

ybastide commented 1 month ago

I managed yet again to push a broken rc πŸ™„; let's use your work