Skip to content

Commit 99a9de7

Browse files
committed
Merge remote-tracking branch 'upstream/master' into pretend-version2
2 parents 10c4116 + 6cc54bc commit 99a9de7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+217
-79
lines changed

.github/workflows/install-git-url.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ jobs:
2727
- ubuntu-latest
2828
- windows-latest
2929
python-version:
30-
- '3.7'
3130
- '3.8'
3231
- '3.9'
3332
- '3.10'
3433
- '3.11'
3534
- '3.12'
36-
- 'pypy-3.7'
3735
- 'pypy-3.8'
3836
- 'pypy-3.9'
3937
- 'pypy-3.10'

.github/workflows/install-zip-url.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,11 @@ jobs:
2727
- ubuntu-latest
2828
- windows-latest
2929
python-version:
30-
- '3.7'
3130
- '3.8'
3231
- '3.9'
3332
- '3.10'
3433
- '3.11'
3534
- '3.12'
36-
- 'pypy-3.7'
3735
- 'pypy-3.8'
3836
- 'pypy-3.9'
3937
- 'pypy-3.10'

.github/workflows/test.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,25 +23,23 @@ jobs:
2323
- ubuntu-latest
2424
- windows-latest
2525
python-version:
26-
- '3.7'
2726
- '3.8'
2827
- '3.9'
2928
- '3.10'
3029
- '3.11'
3130
- '3.12'
32-
- 'pypy-3.7'
3331
- 'pypy-3.8'
3432
- 'pypy-3.9'
3533
- 'pypy-3.10'
3634
toxenv: [py]
3735
include:
38-
- python-version: '3.7'
36+
- python-version: '3.8'
3937
toxenv: lint
4038
os: ubuntu-latest
41-
- python-version: '3.7'
39+
- python-version: '3.8'
4240
toxenv: typing
4341
os: ubuntu-latest
44-
- python-version: '3.7'
42+
- python-version: '3.8'
4543
toxenv: py-oldsetup
4644
os: ubuntu-latest
4745
steps:
@@ -52,7 +50,7 @@ jobs:
5250
# Mercurial seems to be broken on PyPy, so we need to install it before
5351
# overriding the default Python.
5452
if: startsWith(matrix.os, 'macos-')
55-
run: python3 -m pip install mercurial
53+
run: brew install mercurial
5654

5755
- name: Set up Python
5856
uses: actions/setup-python@v5

.github/workflows/tools/minimum-vcs/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.7-buster
1+
FROM python:3.8-buster
22
RUN set -ex; \
33
cd tmp; \
44
wget http://snapshot.debian.org/archive/debian/20121102T092448Z/pool/main/g/git/git-man_1.8.0-1_all.deb; \
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM python:3.7-slim
1+
FROM python:3.8-slim
22
RUN set -ex; \
33
pip install --upgrade pip wheel; \
44
pip install --upgrade --upgrade-strategy=eager tox

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.6.0
44
hooks:
55
- id: check-added-large-files
66
- id: check-json
@@ -12,19 +12,19 @@ repos:
1212
exclude: '\.eml$'
1313

1414
- repo: https://github.com/psf/black
15-
rev: 23.1.0
15+
rev: 24.4.2
1616
hooks:
1717
- id: black
1818
exclude: ^test/data
1919

2020
- repo: https://github.com/PyCQA/isort
21-
rev: 5.12.0
21+
rev: 5.13.2
2222
hooks:
2323
- id: isort
2424
exclude: ^test/data
2525

2626
- repo: https://github.com/PyCQA/flake8
27-
rev: 6.0.0
27+
rev: 7.0.0
2828
hooks:
2929
- id: flake8
3030
additional_dependencies:

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
v3.1.2 (2024-07-20)
2+
-------------------
3+
- Drop support for Python 3.7
4+
- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild`
5+
step for editable builds
6+
7+
v3.1.1 (2024-04-29)
8+
-------------------
9+
- Correctly mark a certain test as requiring Mercurial
10+
11+
v3.1.0 (2024-03-16)
12+
-------------------
13+
- When `git describe` fails to retrieve a tag, the resulting log/error message
14+
now includes all options passed to the command (based on contribution by
15+
[@jenshnielsen](https://github.com/jenshnielsen))
16+
- When `hg log` fails to retrieve a tag, the resulting log/error message now
17+
includes the tag pattern passed to `latesttag()`, if any
18+
119
v3.0.0 (2023-12-13)
220
-------------------
321
- Migrated from setuptools to hatch

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) 2021-2023 John Thorvald Wodder II and contributors
3+
Copyright (c) 2021-2024 John Thorvald Wodder II and contributors
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.rst

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
1-
.. image:: https://www.repostatus.org/badges/latest/active.svg
1+
|repostatus| |ci-status| |coverage| |pyversions| |conda| |license|
2+
3+
.. |repostatus| image:: https://www.repostatus.org/badges/latest/active.svg
24
:target: https://www.repostatus.org/#active
35
:alt: Project Status: Active — The project has reached a stable, usable
46
state and is being actively developed.
57

6-
.. image:: https://github.com/jwodder/versioningit/actions/workflows/test.yml/badge.svg
8+
.. |ci-status| image:: https://github.com/jwodder/versioningit/actions/workflows/test.yml/badge.svg
79
:target: https://github.com/jwodder/versioningit/actions/workflows/test.yml
810
:alt: CI Status
911

10-
.. image:: https://codecov.io/gh/jwodder/versioningit/branch/master/graph/badge.svg
12+
.. |coverage| image:: https://codecov.io/gh/jwodder/versioningit/branch/master/graph/badge.svg
1113
:target: https://codecov.io/gh/jwodder/versioningit
1214

13-
.. image:: https://img.shields.io/pypi/pyversions/versioningit.svg
15+
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/versioningit.svg
1416
:target: https://pypi.org/project/versioningit/
1517

16-
.. image:: https://img.shields.io/conda/vn/conda-forge/versioningit.svg
18+
.. |conda| image:: https://img.shields.io/conda/vn/conda-forge/versioningit.svg
1719
:target: https://anaconda.org/conda-forge/versioningit
1820
:alt: Conda Version
1921

20-
.. image:: https://img.shields.io/github/license/jwodder/versioningit.svg
22+
.. |license| image:: https://img.shields.io/github/license/jwodder/versioningit.svg
2123
:target: https://opensource.org/licenses/MIT
2224
:alt: MIT License
2325

@@ -71,7 +73,7 @@ extraction & calculation.
7173

7274
Installation & Setup
7375
====================
74-
``versioningit`` requires Python 3.7 or higher. Just use `pip
76+
``versioningit`` requires Python 3.8 or higher. Just use `pip
7577
<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install
7678
``versioningit`` and its dependencies::
7779

docs/changelog.rst

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
Changelog
44
=========
55

6+
v3.1.2 (2024-07-20)
7+
-------------------
8+
- Drop support for Python 3.7
9+
- **Bugfix**: When using `versioningit` with Hatch, don't run the `onbuild`
10+
step for editable builds
11+
12+
13+
v3.1.1 (2024-04-29)
14+
-------------------
15+
- Correctly mark a certain test as requiring Mercurial
16+
17+
18+
v3.1.0 (2024-03-16)
19+
-------------------
20+
- When :command:`git describe` fails to retrieve a tag, the resulting log/error
21+
message now includes all options passed to the command (based on contribution
22+
by `@jenshnielsen <https://github.com/jenshnielsen>`_)
23+
- When :command:`hg log` fails to retrieve a tag, the resulting log/error
24+
message now includes the tag pattern passed to ``latesttag()``, if any
25+
26+
627
v3.0.0 (2023-12-13)
728
-------------------
829
- Migrated from setuptools to hatch

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
project = "versioningit"
44
author = "John Thorvald Wodder II"
5-
copyright = "2021-2023 John Thorvald Wodder II" # noqa: A001
5+
copyright = "2021-2024 John Thorvald Wodder II" # noqa: A001
66

77
extensions = [
88
"sphinx.ext.autodoc",

docs/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ extraction & calculation.
6666

6767
Installation & Setup
6868
====================
69-
``versioningit`` requires Python 3.7 or higher. Just use `pip
69+
``versioningit`` requires Python 3.8 or higher. Just use `pip
7070
<https://pip.pypa.io>`_ for Python 3 (You have pip, right?) to install
7171
``versioningit`` and its dependencies::
7272

docs/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Sphinx~=7.0
1+
Sphinx~=8.0
22
sphinx-copybutton~=0.5.0
33
sphinx-inline-tabs
4-
sphinx_rtd_theme~=2.0
4+
sphinx_rtd_theme~=3.0

pyproject.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "versioningit"
77
dynamic = ["version"]
88
description = "Versioning It with your Version In Git"
99
readme = "README.rst"
10-
requires-python = ">=3.7"
10+
requires-python = ">=3.8"
1111
license = "MIT"
1212
license-files = { paths = ["LICENSE"] }
1313
authors = [
@@ -26,7 +26,6 @@ classifiers = [
2626
"Development Status :: 5 - Production/Stable",
2727
"Programming Language :: Python :: 3 :: Only",
2828
"Programming Language :: Python :: 3",
29-
"Programming Language :: Python :: 3.7",
3029
"Programming Language :: Python :: 3.8",
3130
"Programming Language :: Python :: 3.9",
3231
"Programming Language :: Python :: 3.10",

src/versioningit/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
<https://versioningit.rtfd.io> for more information.
4444
"""
4545

46-
__version__ = "3.0.0"
46+
__version__ = "3.1.2"
4747
__author__ = "John Thorvald Wodder II"
4848
__author_email__ = "[email protected]"
4949
__license__ = "MIT"

src/versioningit/core.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ def from_config(cls, project_dir: str | Path, config: Config) -> Versioningit:
190190
format=config.format.load(project_dir),
191191
template_fields=config.template_fields.load(project_dir),
192192
write=config.write.load(project_dir) if config.write is not None else None,
193-
onbuild=config.onbuild.load(project_dir)
194-
if config.onbuild is not None
195-
else None,
193+
onbuild=(
194+
config.onbuild.load(project_dir) if config.onbuild is not None else None
195+
),
196196
)
197197

198198
def get_version(self, write: bool = False, fallback: bool = True) -> str:

src/versioningit/git.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from datetime import datetime
44
from pathlib import Path
55
import re
6+
import shlex
67
import subprocess
78
from typing import Any, NamedTuple, Optional
89
from .core import VCSDescription
@@ -128,6 +129,11 @@ def as_args(self) -> list[str]:
128129
args.append(f"--exclude={pat}")
129130
return args
130131

132+
def as_cmdline_str(self) -> str:
133+
return "git describe --long --dirty --always" + "".join(
134+
" " + shlex.quote(a) for a in self.as_args()
135+
)
136+
131137

132138
@dataclass
133139
class GitRepo:
@@ -194,7 +200,9 @@ def describe(self, opts: DescribeOpts) -> str:
194200
except subprocess.CalledProcessError as e:
195201
# As far as I'm aware, this only happens in a repo without any
196202
# commits or a corrupted repo.
197-
raise NoTagError(f"`git describe` command failed: {e.stderr.strip()}")
203+
raise NoTagError(
204+
f"`{opts.as_cmdline_str()}` command failed: {e.stderr.strip()}"
205+
)
198206

199207
def get_branch(self) -> Optional[str]:
200208
"""
@@ -338,15 +346,16 @@ def describe_git_core(
338346
except ValueError:
339347
if default_tag is not None:
340348
log.info(
341-
"`git describe` returned a hash instead of a tag; falling back to"
342-
" default tag %r",
349+
"`%s` returned a hash instead of a tag; falling back to default"
350+
" tag %r",
351+
opts.as_cmdline_str(),
343352
default_tag,
344353
)
345354
tag = default_tag
346355
distance = int(repo.read("rev-list", "--count", "HEAD")) - 1
347356
rev = description
348357
else:
349-
raise NoTagError("`git describe` could not find a tag")
358+
raise NoTagError(f"`{opts.as_cmdline_str()}` could not find a tag")
350359
if distance and dirty:
351360
state = "distance-dirty"
352361
elif distance:

src/versioningit/hatch.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,11 @@ def __init__(self, *args: Any, **kwargs: Any) -> None:
7676
super().__init__(*args, **kwargs)
7777
self.__tmpdir = Path(tempfile.mkdtemp())
7878

79-
def initialize(self, _version: str, build_data: dict[str, Any]) -> None:
79+
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
8080
init_logging()
81+
if self.target_name == "wheel" and version == "editable":
82+
log.debug("Not running onbuild step for editable build")
83+
return None
8184
version_source = self.metadata.hatch.version.source
8285
if not isinstance(version_source, VersioningitSource):
8386
raise RuntimeError(

src/versioningit/hg.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,23 @@ def describe_hg(*, project_dir: str | Path, params: dict[str, Any]) -> VCSDescri
102102
else:
103103
dirty = False
104104
if tag == "null":
105+
if pattern is None:
106+
suffix = ""
107+
else:
108+
suffix = f" (pattern = {pattern!r})"
109+
# Unlike the Git methods, don't show the full `hg log` command run, as
110+
# shlex.quote() on `--template` arguments returns something *ugly*.
105111
if default_tag is not None:
106-
log.info("No latest tag; falling back to default tag %r", default_tag)
112+
log.info(
113+
"No latest tag%s; falling back to default tag %r", suffix, default_tag
114+
)
107115
tag = default_tag
108116
# Act as though the first commit is the one with the default tag,
109117
# i.e., don't count it (unless there is no first commit, of course)
110118
if distance > 0:
111119
distance -= 1
112120
else:
113-
raise NoTagError("No latest tag in Mercurial repository")
121+
raise NoTagError(f"No latest tag in Mercurial repository{suffix}")
114122
if distance and dirty:
115123
state = "distance-dirty"
116124
elif distance:

0 commit comments

Comments
 (0)