-
Notifications
You must be signed in to change notification settings - Fork 32
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Please see the documentation for all configuration options: | ||
# https://docs.github.com/en/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file | ||
|
||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
- package-ecosystem: "pip" | ||
directory: "/" | ||
schedule: | ||
interval: "monthly" | ||
groups: | ||
pip-packages: | ||
patterns: | ||
- "*" |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,14 +10,14 @@ for testing, and :command:`black` for code formatting. | |
|
||
.. code-block:: shell | ||
$ tox # All python versions | ||
$ tox -e py38 # Python 3.8 | ||
$ tox -e py39 # Python 3.9 | ||
$ tox -e py310 # Python 3.10 | ||
$ uv run tox # All python versions | ||
$ uv run tox -e py38 # Python 3.8 | ||
$ uv run tox -e py39 # Python 3.9 | ||
$ uv run tox -e py310 # Python 3.10 | ||
$ tox -e mypy # Mypy Typechecking | ||
$ tox -e lint # Linting | ||
$ tox -e format # Check Formatting | ||
$ uv run tox -e mypy # Mypy Typechecking | ||
$ uv run tox -e lint # Linting | ||
$ uv run tox -e format # Check Formatting | ||
Code Formatting | ||
--------------- | ||
|
@@ -26,8 +26,8 @@ This project uses ``isort`` and ``black`` for code formatting. | |
|
||
.. code-block:: shell | ||
$ isort . # sort imports | ||
$ black . # format all python code | ||
$ uv run isort . # sort imports | ||
$ uv run ruff format # format all python code | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I take it here There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, You can probably also remove isort, that's also taken care of by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, It does appear that this patch adds a call to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It depends: 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: |
||
Building Documentation | ||
---------------------- | ||
|
@@ -44,6 +44,6 @@ Publishing | |
|
||
.. code-block:: shell | ||
$ python3 setup.py sdist bdist_wheel | ||
$ twine check dist/* | ||
$ twine upload dist/* | ||
$ uv build | ||
$ uv run twine check dist/* | ||
$ uv run twine upload dist/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. uv also has some upload capabilities: There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
if TYPE_CHECKING: | ||
from subprocess import _FILE | ||
|
||
from typing_extensions import Self | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't love needing to pull in a dependency for There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. debian stable (bookworm) is 3.11 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
(That 3.12 is downloaded and installed by uv -> In this case it was already downloaded and extracted/hardlinked) There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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. |
||
|
||
|
||
class MissingObject(Exception): | ||
"""Exception raised when a commit cannot be found in the ODB""" | ||
|
@@ -57,7 +59,7 @@ class Oid(bytes): | |
def __new__(cls, b: bytes) -> Oid: | ||
if len(b) != 20: | ||
raise ValueError("Expected 160-bit SHA1 hash") | ||
return super().__new__(cls, b) # type: ignore | ||
return super().__new__(cls, b) | ||
|
||
@classmethod | ||
def fromhex(cls, instr: str) -> Oid: | ||
|
@@ -165,8 +167,8 @@ class Repository: | |
"""path to GnuPG binary""" | ||
|
||
_objects: Dict[int, Dict[Oid, GitObj]] | ||
_catfile: Popen | ||
_tempdir: Optional[TemporaryDirectory] | ||
_catfile: Popen[bytes] | ||
_tempdir: Optional[TemporaryDirectory[str]] | ||
|
||
__slots__ = [ | ||
"workdir", | ||
|
@@ -480,7 +482,7 @@ class GitObj: | |
|
||
__slots__ = ("repo", "body", "oid", "persisted") | ||
|
||
def __new__(cls: Type[GitObjT], repo: Repository, body: bytes) -> GitObjT: | ||
def __new__(cls, repo: Repository, body: bytes) -> "Self": | ||
oid = Oid.for_object(cls._git_type(), body) | ||
cache = repo._objects[oid[0]] # pylint: disable=protected-access | ||
if oid in cache: | ||
|
@@ -495,7 +497,7 @@ def __new__(cls: Type[GitObjT], repo: Repository, body: bytes) -> GitObjT: | |
self.persisted = False | ||
cache[oid] = self | ||
self._parse_body() # pylint: disable=protected-access | ||
return cast(GitObjT, self) | ||
return self | ||
|
||
@classmethod | ||
def _git_type(cls) -> str: | ||
|
@@ -834,7 +836,7 @@ def git( | |
trim_newline: bool = True, | ||
) -> bytes: | ||
"""Invoke git with the given index as active""" | ||
env = dict(**env) if env is not None else dict(**os.environ) | ||
env = {**env} if env is not None else {**os.environ} | ||
env["GIT_INDEX_FILE"] = str(self.index_file) | ||
return self.repo.git( | ||
*cmd, | ||
|
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
[build-system] | ||
requires = ["hatchling"] | ||
build-backend = "hatchling.build" | ||
|
||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is There was a problem hiding this comment. Choose a reason for hiding this commentThe 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... There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 :-) |
||
[project] | ||
name = "git-revise" | ||
dynamic = ["version"] | ||
requires-python = ">=3.8" | ||
authors = [{ name = "Nika Layzell", email = "[email protected]" }] | ||
description = "Efficiently update, split, and rearrange git commits" | ||
readme = "README.md" | ||
license = { file = "LICENSE" } | ||
keywords = ["git", "revise", "rebase", "amend", "fixup"] | ||
classifiers = [ | ||
"Development Status :: 4 - Beta", | ||
"Intended Audience :: Developers", | ||
"Environment :: Console", | ||
"Topic :: Software Development :: Version Control", | ||
"Topic :: Software Development :: Version Control :: Git", | ||
"License :: OSI Approved :: MIT License", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.8", | ||
"Programming Language :: Python :: 3.9", | ||
"Programming Language :: Python :: 3.10", | ||
] | ||
|
||
[project.scripts] | ||
git-revise = "gitrevise.tui:main" | ||
|
||
[dependency-groups] | ||
dev = [ | ||
"isort~=5.13.2", | ||
"mypy~=1.14.1", | ||
"pylint~=3.2.7", | ||
"pytest-xdist~=3.6.1", | ||
"pytest~=8.3.4", | ||
"ruff~=0.9.6", | ||
"sphinx~=7.1.2", | ||
"tox-uv~=1.13.1", | ||
"tox~=4.24.1", | ||
"twine~=6.1.0", | ||
"typing-extensions~=4.12.2", | ||
] | ||
|
||
[project.urls] | ||
Homepage = "https://github.com/mystor/git-revise/" | ||
Issues = "https://github.com/mystor/git-revise/issues/" | ||
Repository = "https://github.com/mystor/git-revise/" | ||
Documentation = "https://git-revise.readthedocs.io/en/latest/" | ||
|
||
[tool.hatch.version] | ||
path = "gitrevise/__init__.py" | ||
|
||
[tool.hatch.build.targets.wheel] | ||
packages = ["/gitrevise"] | ||
|
||
[tool.hatch.build.targets.wheel.shared-data] | ||
"git-revise.1" = "share/man/man1/git-revise.1" | ||
|
||
[tool.hatch.build.targets.sdist] | ||
include = ["/gitrevise"] | ||
|
||
[tool.pylint.messages_control] | ||
disable = [ | ||
"missing-docstring", | ||
"too-few-public-methods", | ||
"too-many-arguments", | ||
"too-many-branches", | ||
"too-many-instance-attributes", | ||
"too-many-return-statements", | ||
"cyclic-import", | ||
"fixme", | ||
|
||
# Currently broken analyses which are also handled (better) by mypy | ||
"class-variable-slots-conflict", | ||
"no-member", | ||
] | ||
|
||
good-names = [ | ||
# "Exception as e" is perfectly fine. | ||
"e", | ||
# "with open(…) as f" is idiomatic. | ||
"f", | ||
# Other contextually-unambiguous names. | ||
"fn", | ||
"repo", | ||
"ed", | ||
] | ||
|
||
# TODO(https://github.com/astral-sh/ruff/issues/14813): Remove this once ruff properly respects | ||
# requires-python. | ||
[tool.ruff] |
This file was deleted.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.