Skip to content

Commit 07270fc

Browse files
Merge pull request #580 from RonnyPfannschmidt/git-archives-full-support
Git archives full support
2 parents 5ae39d4 + 6707c4f commit 07270fc

Some content is hidden

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

49 files changed

+1392
-940
lines changed

.git_archival.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe)$
4+
ref-names: $Format:%D$

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.git_archival.txt export-subst

.github/workflows/python-tests.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@ jobs:
2020
strategy:
2121
fail-fast: false
2222
matrix:
23-
python_version: [ '3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.6' ]
23+
python_version: ['3.7', '3.8', '3.9', '3.10', '3.11.0-alpha - 3.11.0', 'pypy-3.8' ]
2424
os: [windows-latest, ubuntu-latest] #, macos-latest]
2525
include:
2626
- os: windows-latest
2727
python_version: 'msys2'
2828

2929
name: ${{ matrix.os }} - Python ${{ matrix.python_version }}
3030
steps:
31-
- uses: actions/checkout@v1
31+
- uses: actions/checkout@v3
3232
- name: Setup python
33-
uses: actions/setup-python@v2
33+
uses: actions/setup-python@v4
3434
if: matrix.python_version != 'msys2'
3535
with:
3636
python-version: ${{ matrix.python_version }}
@@ -83,7 +83,7 @@ jobs:
8383
- name: Setup python
8484
uses: actions/setup-python@v2
8585
with:
86-
python-version: "3.6"
86+
python-version: "3.7"
8787
architecture: x64
8888
- run: pip install -e .[toml,test] pytest virtualenv
8989
- run: pytest --test-legacy testing/test_setuptools_support.py || true # ignore fail flaky on ci
@@ -92,11 +92,11 @@ jobs:
9292
strategy:
9393
fail-fast: false
9494
matrix:
95-
python_version: [ '3.6', '3.9', 'pypy-3.6' ]
95+
python_version: [ '3.7', '3.9', 'pypy-3.8' ]
9696
installer: ["pip install"]
9797
name: check self install - Python ${{ matrix.python_version }} via ${{ matrix.installer }}
9898
steps:
99-
- uses: actions/checkout@v1
99+
- uses: actions/checkout@v3
100100
- name: Setup python
101101
uses: actions/setup-python@v2
102102
with:
@@ -105,7 +105,7 @@ jobs:
105105
# self install testing needs some clarity
106106
# so its being executed without any other tools running
107107
# setuptools smaller 52 is needed to do easy_install
108-
- run: pip install -U "setuptools<52" tomli packaging
108+
- run: pip install -U "setuptools<52" tomli packaging typing_extensions importlib_metadata
109109
- run: python setup.py egg_info
110110
- run: python setup.py sdist
111111
- run: ${{ matrix.installer }} dist/*

.pre-commit-config.yaml

+11-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1+
default_language_version:
2+
python: python3.9
13
repos:
24
- repo: https://github.com/psf/black
35
rev: 22.3.0
46
hooks:
57
- id: black
68
args: [--safe, --quiet]
79
- repo: https://github.com/asottile/reorder_python_imports
8-
rev: v3.0.1
10+
rev: v3.1.0
911
hooks:
1012
- id: reorder-python-imports
11-
args: [ "--application-directories=.:src" , --py3-plus]
13+
args: [ "--application-directories=.:src" , --py37-plus, --add-import, 'from __future__ import annotations']
1214
- repo: https://github.com/pre-commit/pre-commit-hooks
1315
rev: v4.2.0
1416
hooks:
@@ -21,19 +23,22 @@ repos:
2123
hooks:
2224
- id: flake8
2325
- repo: https://github.com/asottile/pyupgrade
24-
rev: v2.32.0
26+
rev: v2.32.1
2527
hooks:
2628
- id: pyupgrade
27-
args: [--py36-plus]
29+
args: [--py37-plus]
2830
- repo: https://github.com/asottile/setup-cfg-fmt
2931
rev: v1.20.1
3032
hooks:
3133
- id: setup-cfg-fmt
3234
- repo: https://github.com/pre-commit/mirrors-mypy
33-
rev: 'v0.942'
35+
rev: 'v0.960'
3436
hooks:
3537
- id: mypy
38+
args: [--strict]
39+
language_version: "3.10"
3640
additional_dependencies:
3741
- types-setuptools
3842
- tokenize-rt==3.2.0
39-
- pytest == 6.2.5
43+
- pytest == 7.1
44+
- importlib_metadata

CHANGELOG.rst

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
v7.0.0
2+
=======
3+
4+
* drop python 3.6 support
5+
* include git archival support
6+
7+
18
v6.4.3
29
======
310

MANIFEST.in

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
exclude *.nix
22
exclude .pre-commit-config.yaml
3+
exclude .git_archival.txt
34
include *.py
45
include testing/*.py
56
include tox.ini

mypy.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
[mypy]
2-
python_version = 3.6
2+
python_version = 3.7
33
warn_return_any = True
44
warn_unused_configs = True
55
mypy_path = $MYPY_CONFIG_FILE_DIR/src
66

77
[mypy-setuptools_scm.*]
88
# disabled as it will take a bit
99
# disallow_untyped_defs = True
10-
# strict = true
10+
strict = true

pyproject.toml

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
requires = [
33
"setuptools>=45",
44
"tomli>=1.0",
5-
"packaging>=20.0"
5+
"packaging>=20.0",
6+
"typing_extensions",
7+
"importlib_metadata",
68
]
79
build-backend = "setuptools.build_meta"

setup.cfg

+3-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ classifiers =
1515
Programming Language :: Python
1616
Programming Language :: Python :: 3
1717
Programming Language :: Python :: 3 :: Only
18-
Programming Language :: Python :: 3.6
1918
Programming Language :: Python :: 3.7
2019
Programming Language :: Python :: 3.8
2120
Programming Language :: Python :: 3.9
@@ -31,7 +30,8 @@ install_requires =
3130
packaging>=20.0
3231
setuptools
3332
tomli>=1.0.0 # keep in sync
34-
python_requires = >=3.6
33+
typing-extensions
34+
python_requires = >=3.7
3535
package_dir =
3636
=src
3737
zip_safe = true
@@ -59,6 +59,7 @@ setuptools_scm.parse_scm =
5959
.git = setuptools_scm.git:parse
6060
setuptools_scm.parse_scm_fallback =
6161
.hg_archival.txt = setuptools_scm.hg:parse_archival
62+
.git_archival.txt = setuptools_scm.git:parse_archival
6263
PKG-INFO = setuptools_scm.hacks:parse_pkginfo
6364
pip-egg-info = setuptools_scm.hacks:parse_pip_egg_info
6465
setup.py = setuptools_scm.hacks:fallback_version

setup.py

+7-17
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,15 @@
99
1010
pip usage is recommended
1111
"""
12+
from __future__ import annotations
13+
1214
import os
1315
import sys
1416

1517
import setuptools
16-
from setuptools.command.bdist_egg import bdist_egg as original_bdist_egg
17-
18-
19-
class bdist_egg(original_bdist_egg):
20-
def run(self):
21-
raise SystemExit(
22-
"%s is forbidden, "
23-
"please update to setuptools>=45 which uses pip" % type(self).__name__
24-
)
2518

2619

27-
def scm_version():
28-
29-
if sys.version_info < (3, 6):
30-
raise RuntimeError(
31-
"support for python < 3.6 has been removed in setuptools_scm>=6.0.0"
32-
)
20+
def scm_version() -> str:
3321
here = os.path.dirname(os.path.abspath(__file__))
3422
src = os.path.join(here, "src")
3523

@@ -40,8 +28,11 @@ def scm_version():
4028
from setuptools_scm import git
4129
from setuptools_scm import hg
4230
from setuptools_scm.version import guess_next_dev_version, get_local_node_and_date
31+
from setuptools_scm.config import Configuration
32+
33+
from setuptools_scm.version import ScmVersion
4334

44-
def parse(root, config):
35+
def parse(root: str, config: Configuration) -> ScmVersion | None:
4536
try:
4637
return parse_pkginfo(root, config)
4738
except OSError:
@@ -64,5 +55,4 @@ def parse(root, config):
6455
],
6556
"test": ["pytest>=6.2", "virtualenv>20"],
6657
},
67-
cmdclass={"bdist_egg": bdist_egg},
6858
)

src/setuptools_scm/.git_archival.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node: $Format:%H$
2+
node-date: $Format:%cI$
3+
describe-name: $Format:%(describe)$
4+
ref-names: $Format:%D$

src/setuptools_scm/__init__.py

+34-31
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
:copyright: 2010-2015 by Ronny Pfannschmidt
33
:license: MIT
44
"""
5+
from __future__ import annotations
6+
57
import os
68
import warnings
7-
from typing import Optional
9+
from typing import Any
10+
from typing import Callable
811
from typing import TYPE_CHECKING
912

10-
from . import _types
13+
from . import _types as _t
1114
from ._entrypoints import _call_entrypoint_fn
1215
from ._entrypoints import _version_from_entrypoints
1316
from ._overrides import _read_pretended_version_for
@@ -36,14 +39,14 @@
3639
# coding: utf-8
3740
# file generated by setuptools_scm
3841
# don't change, don't track in version control
39-
version = {version!r}
40-
version_tuple = {version_tuple!r}
42+
__version__ = version = {version!r}
43+
__version_tuple__ = version_tuple = {version_tuple!r}
4144
""",
4245
".txt": "{version}",
4346
}
4447

4548

46-
def version_from_scm(root):
49+
def version_from_scm(root: _t.PathT) -> ScmVersion | None:
4750
warnings.warn(
4851
"version_from_scm is deprecated please use get_version",
4952
category=DeprecationWarning,
@@ -54,11 +57,11 @@ def version_from_scm(root):
5457

5558

5659
def dump_version(
57-
root: _types.PathT,
60+
root: _t.PathT,
5861
version: str,
59-
write_to: _types.PathT,
60-
template: "str | None" = None,
61-
):
62+
write_to: _t.PathT,
63+
template: str | None = None,
64+
) -> None:
6265
assert isinstance(version, str)
6366
target = os.path.normpath(os.path.join(root, write_to))
6467
ext = os.path.splitext(target)[1]
@@ -76,7 +79,7 @@ def dump_version(
7679
fp.write(template.format(version=version, version_tuple=version_tuple))
7780

7881

79-
def _do_parse(config: Configuration) -> "ScmVersion|None":
82+
def _do_parse(config: Configuration) -> ScmVersion | None:
8083
pretended = _read_pretended_version_for(config)
8184
if pretended is not None:
8285
return pretended
@@ -85,9 +88,9 @@ def _do_parse(config: Configuration) -> "ScmVersion|None":
8588
parse_result = _call_entrypoint_fn(config.absolute_root, config, config.parse)
8689
if isinstance(parse_result, str):
8790
raise TypeError(
88-
"version parse result was a string\nplease return a parsed version"
91+
f"version parse result was {str!r}\nplease return a parsed version"
8992
)
90-
version: Optional[ScmVersion]
93+
version: ScmVersion | None
9194
if parse_result:
9295
assert isinstance(parse_result, ScmVersion)
9396
version = parse_result
@@ -102,7 +105,7 @@ def _do_parse(config: Configuration) -> "ScmVersion|None":
102105
return version
103106

104107

105-
def _version_missing(config) -> "NoReturn":
108+
def _version_missing(config: Configuration) -> NoReturn:
106109
raise LookupError(
107110
f"setuptools-scm was unable to detect version for {config.absolute_root}.\n\n"
108111
"Make sure you're either building from a fully intact git repository "
@@ -116,23 +119,23 @@ def _version_missing(config) -> "NoReturn":
116119

117120

118121
def get_version(
119-
root=".",
120-
version_scheme=DEFAULT_VERSION_SCHEME,
121-
local_scheme=DEFAULT_LOCAL_SCHEME,
122-
write_to=None,
123-
write_to_template=None,
124-
relative_to=None,
125-
tag_regex=DEFAULT_TAG_REGEX,
126-
parentdir_prefix_version=None,
127-
fallback_version=None,
128-
fallback_root=".",
129-
parse=None,
130-
git_describe_command=None,
131-
dist_name=None,
132-
version_cls=None,
133-
normalize=True,
134-
search_parent_directories=False,
135-
):
122+
root: str = ".",
123+
version_scheme: Callable[[ScmVersion], str] | str = DEFAULT_VERSION_SCHEME,
124+
local_scheme: Callable[[ScmVersion], str] | str = DEFAULT_LOCAL_SCHEME,
125+
write_to: _t.PathT | None = None,
126+
write_to_template: str | None = None,
127+
relative_to: str | None = None,
128+
tag_regex: str = DEFAULT_TAG_REGEX,
129+
parentdir_prefix_version: str | None = None,
130+
fallback_version: str | None = None,
131+
fallback_root: _t.PathT = ".",
132+
parse: Any | None = None,
133+
git_describe_command: Any | None = None,
134+
dist_name: str | None = None,
135+
version_cls: Any | None = None,
136+
normalize: bool = True,
137+
search_parent_directories: bool = False,
138+
) -> str:
136139
"""
137140
If supplied, relative_to should be a file from which root may
138141
be resolved. Typically called by a script or module that is not
@@ -147,7 +150,7 @@ def get_version(
147150
return maybe_version
148151

149152

150-
def _get_version(config: Configuration) -> "str|None":
153+
def _get_version(config: Configuration) -> str | None:
151154
parsed_version = _do_parse(config)
152155
if parsed_version is None:
153156
return None

0 commit comments

Comments
 (0)