Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce "hatch" to build & release #435

Merged
merged 7 commits into from
Jul 4, 2024
Merged

Introduce "hatch" to build & release #435

merged 7 commits into from
Jul 4, 2024

Conversation

jbbarth
Copy link
Collaborator

@jbbarth jbbarth commented Oct 28, 2023

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.

@jbbarth jbbarth force-pushed the fix-git-install branch 2 times, most recently from 7659cdb to 9fa2145 Compare October 28, 2023 20:28
@ybastide
Copy link
Contributor

ybastide commented Oct 29, 2023

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 🙂

@@ -100,3 +100,6 @@ addopts = "--doctest-modules --ignore=setup.py --ignore=tasks.py --ignore=docs/

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

[tool.hatch.build]
include = ["/simpleflow"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we need an exclude rule; if you look at the artefacts I published on test.pypi.org, there are *.pyi~ files that were loitering around

script/release Outdated
@@ -18,13 +18,29 @@ VERSION_FILE = "simpleflow/__init__.py"
MAIN_BRANCH = "main"
CHANGELOG_FILE = "CHANGELOG.md"

# This is not the full list, we removed some abbreviations that are not super explicit.
# Hatch does not expose does as constants, so we have to duplicate them here.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Hatch does not expose does as constants, so we have to duplicate them here.
# Hatch does not expose them as constants, so we have to duplicate them here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(I think he meant "those", but "them" works too)

@ybastide
Copy link
Contributor

ybastide commented Jun 4, 2024

👋 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 added 3 commits July 4, 2024 12:12
Signed-off-by: Yves Bastide <[email protected]>
Update to the last versions supporting Python 3.7

Signed-off-by: Yves Bastide <[email protected]>
Signed-off-by: Yves Bastide <[email protected]>
@ybastide
Copy link
Contributor

ybastide commented Jul 4, 2024

I managed yet again to push a broken rc 🙄; let's use your work

@ybastide ybastide merged commit 418b5f8 into main Jul 4, 2024
7 checks passed
@ybastide ybastide deleted the fix-git-install branch July 4, 2024 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants