8000 Update to modern packaging by tamird · Pull Request #141 · mystor/git-revise · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Update to modern packaging #141

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

Merged
merged 2 commits into from
Apr 16, 2025
Merged

Update to modern packaging #141

merged 2 commits into from
Apr 16, 2025

Conversation

tamird
Copy link
Contributor
@tamird tamird commented Feb 11, 2025

See individual commits.

I think this likely fixes #140 after a new release.

@tamird
Copy link
Contributor Author
tamird commented Feb 11, 2025

Oops, sorry about the CI failures, I had neglected to update the Github Actions config. Could you give it another go?

@tamird
Copy link
Contributor Author
tamird commented Feb 11, 2025

Alright, this should be green for real now. I worked out the kinks by running CI in my fork.

Use pyproject.toml, uv, and hatchling.

This produces the following layout using

  uv pip install --no-deps --prefix=/tmp/test-prefix .`

  /tmp/test-prefix/.lock
  /tmp/test-prefix/bin/git-revise
  /tmp/test-prefix/lib/python3.12/site-packages/gitrevise/merge.py
  /tmp/test-prefix/lib/python3.12/site-packages/gitrevise/odb.py
  /tmp/test-prefix/lib/python3.12/site-packages/gitrevise/__init__.py
  /tmp/test-prefix/lib/python3.12/site-packages/gitrevise/utils.py
  /tmp/test-prefix/lib/python3.12/site-packages/gitrevise/tui.py
  /tmp/test-prefix/lib/python3.12/site-packages/gitrevise/todo.py
  /tmp/test-prefix/lib/pyth
8000
on3.12/site-packages/gitrevise/__main__.py
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/INSTALLER
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/REQUESTED
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/licenses/LICENSE
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/direct_url.json
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/RECORD
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/entry_points.txt
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/WHEEL
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/METADATA
  /tmp/test-prefix/lib/python3.12/site-packages/git_revise-0.7.0.dist-info/uv_cache.json
  /tmp/test-prefix/share/man/man1/git-revise.1
Batch all updates (per ecosystem) into a single PR once a month.
@tamird
Copy link
Contributor Author
tamird commented Mar 24, 2025

@mystor does this look reasonable to you?

@tamird
Copy link
Contributor Author
tamird commented Apr 7, 2025

@mystor gentle ping.

$ isort . # sort imports
$ black . # format all python code
$ uv run isort . # sort imports
$ uv run ruff format # format all python code
Copy link
Owner

Choose a reason for hiding this comment

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

I take it here ruff is a new replacement for black? Is the formatting the same as the existing code?

Choose a reason for hiding this comment

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

Yes, ruff format is mostly the same apart form some obscure edge cases. Thy actually have some testing against black formatting.

You can probably also remove isort, that's also taken care of by check --fix-only --select I --fixable I ("I" are the isort rules). If you have any other linters (flake8, pylint), you can probably also replace them with ruff check --select 'ALL'...

Copy link
Owner

Choose a reason for hiding this comment

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

Yeah, It does appear that this patch adds a call to ruff check, though it does not remove the pylint check (which appears to still be called). Is ruff check preferable to pylint nowadays?

https://github.com/mystor/git-revise/pull/141/files#diff-ef2cef9f88b4fe09ca3082140e67f5ad34fb65fb6e228f119d3812261ae51449R31-L35

Choose a reason for hiding this comment

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

It depends: ruff check (replacement for a lot of flake8 thingies and parts of pylint; an isort) is different from ruff format (replacement for black), so IMO the patch is right to not remove pylint (or at least not remove it without a replacement)

Re comparison with pylint: I would guess it implements about 2/3 of pylints rules (source). Mostly everything which needs context which is outside of the current file is not implmented: ruff is strictly one file only. They have some chatter that multiple files linting is on the radar, but thats seems to be still a bit off as well: "red not", which also will be a mypy replacement, if I understand that right).

My personal take: ruff format + ruff check --select ALL + mypy catches about everything what I care to catch. We have implemented that setup at work (with mypy in struct modusl and a handful of explicitly ignored ruff rules), where it runs against sonarqube and mostly leaves nothing for sonarqube to find. And it's so damn fast that running linter and formatter is fun again :-)

@@ -31,6 +31,8 @@
if TYPE_CHECKING:
from subprocess import _FILE

from typing_extensions import Self
Copy link
Owner

Choose a reason for hiding this comment

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

I don't love needing to pull in a dependency for Self when we can do the existing TypeVar stuff and it looks like it should work OK? What does this do differently?

Choose a reason for hiding this comment

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

Depends how recent you wanna be: it's included in python proper as of py3.11: https://peps.python.org/pep-0673/

from typing import Self

Copy link
Owner

Choose a reason for hiding this comment

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

Oh that's nice.

Looks like I last increased the minimum python version in 2022 from 3.6 to 3.8 (4a7e852). I imagine we can get away with bumping the minimum version again so long as the major LTS distros (debian stable / ubuntu) are shipping that version of Python or newer.

Copy link
@jankatins jankatins Apr 15, 2025

Choose a reason for hiding this comment

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

debian stable (bookworm) is 3.11
Ubuntu 22.04 is on 3.10 and 24.04 on 3.12

Not sure how dependent you are on system python for installing a newer version of any python package though: if you can install a newer python package you probably also can install (and probably already are installing) a newer python :-)

With uv, you simply do a uv tool install git-revise@latest you probably anyway get a py 3.13^W3.12 installed:

[16:34:18] λ  uv tool install git-revise@latest
Resolved 1 package in 282ms
Audited 1 package in 0.00ms
Installed 1 executable: git-revise

[23:04:45] λ  which git-revise
~/.local/bin/git-revise

[23:05:32] λ  /home/jankatins/.local/share/uv/tools/git-revise/bin/python --version
Python 3.12.8

(That 3.12 is downloaded and installed by uv -> In this case it was already downloaded and extracted/hardlinked)

Copy link
Owner

Choose a reason for hiding this comment

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

Cool. I'll admit I'm out-of-the-loop on these modern python packaging changes, and so I worry about things like "can someone on the Ubuntu LTS do pip3 install --user git-revise and have it work", but I suppose that's less of a thing folks are doing nowadays?

I think I'd definitely be OK with bumping the python version to 3.10, less certain about 3.11 given 22.04 is still on 3.10, but perhaps that is also OK.

Comment on lines +1 to +4
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

Copy link
Owner

Choose a reason for hiding this comment

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

What is hatchling, and how is it connected to uv? On first look it appears it's another different build system?

Copy link
@jankatins jankatins Apr 15, 2025

Choose a reason for hiding this comment

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

uv as of today has no officially released build backend: poetry has poetry-core, hatch has hatchling, pip has .. build? There is also a setuptools one. So essentially you have to pick one and some more.

uv us currently developing one, but that looks still a bit rough. astral-sh/uv#3957 Might already be enough though...

Copy link
Contributor

Choose a reason for hiding this comment

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

Arch Linux packager here...

I fully support the switch to a proper PEP 517 build, and the ruff and uv tooling is almost universally recognized as better these days than black and pip and such. I don't have strong feelings about hatch/hatchling over poetry, flit, setuptools, or others, so that's fine I suppose.

On the other hand just a warning that the uv build backend is not only rough but controversial. I would avoid it for the foreseeable future as it introduces lots of binary requirements on the host environment when pure Python would do fine. It's very heavy weight for an application like this.

Copy link
Owner

Choose a reason for hiding this comment

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

That works for me, happy to use whatever works best for folks building the actual packages :-)

$ twine upload dist/*
$ uv build
$ uv run twine check dist/*
$ uv run twine upload dist/*

Choose a reason for hiding this comment

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

uv also has some upload capabilities: uv publish... https://docs.astral.sh/uv/guides/package/#publishing-your-package

Copy link
Owner

Choose a reason for hiding this comment

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

That's good to know, might be worth switching to that, but I'd want to look into it more.

@@ -7,21 +7,24 @@ jobs:
name: Test on python ${{ matrix.python-version }} and ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.9", "3.10"]

Choose a reason for hiding this comment

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

I guess this could also get an update? https://devguide.python.org/versions/ -> 3.8 is EOL, 3.11-3.13 are missing

Copy link
Owner

Choose a reason for hiding this comment

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

If 3.8 is EOL, I think we can probably drop support, and it'd be nice to start running tests on some more recent python releases, though perhaps that should be a separate PR.

Copy link
Contributor Author
@tamird tamird left a comment

Choose a reason for hiding this comment

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

Are there any remaining concerns waiting on responses from me?

@tamird
Copy link
Contributor Author
tamird commented Apr 15, 2025

Please let me know if changes are required - or go ahead and make what changes you see fit. I've allowed edits by maintainers and you have my explicit consent to edit directly.

@mystor mystor merged commit 2d48b2a into mystor:main Apr 16, 2025
9 checks passed
@mystor
Copy link
Owner
mystor commented Apr 16, 2025

Thanks! This seems like a solid direction for modernizing the tooling we're using.

@tamird tamird deleted the tooling branch April 16, 2025 18:49
mystor pushed a commit that referenced this pull request Apr 17, 2025
This is a new feature that appeared after #141.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

homebrew formula doesn't provide man git-revise nor git revise --help
4 participants
0