summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonny Pfannschmidt <opensource@ronnypfannschmidt.de>2023-02-24 16:29:58 +0100
committerGitHub <noreply@github.com>2023-02-24 16:29:58 +0100
commit3914aaa17321f887ccf9baa566108c51d0131c8b (patch)
treeaaec82df1ce0b634c1af1d5e2cde306b163efc87
parent1fcb0cdf6a8d65cffd9fa63b61b6d87670585bb7 (diff)
parent3996d3e6757260b2e4c04b72314375d36946f374 (diff)
downloadsetuptools-scm-3914aaa17321f887ccf9baa566108c51d0131c8b.tar.gz
Merge pull request #807 from RonnyPfannschmidt/ronny/minor
packaging refinements
-rw-r--r--.github/workflows/python-tests.yml65
-rw-r--r--.gitignore3
-rw-r--r--.pre-commit-config.yaml1
-rw-r--r--CHANGELOG.rst26
-rw-r--r--pyproject.toml17
-rw-r--r--scm_hack_build_backend.py60
-rw-r--r--setup.py58
-rw-r--r--testing/check_self_install.py8
8 files changed, 115 insertions, 123 deletions
diff --git a/.github/workflows/python-tests.yml b/.github/workflows/python-tests.yml
index af4126b..a9d4eed 100644
--- a/.github/workflows/python-tests.yml
+++ b/.github/workflows/python-tests.yml
@@ -16,7 +16,20 @@ env:
FORCE_COLOR: 1
jobs:
+
+ package:
+ name: Build & inspect our package.
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ with:
+ fetch-depth: 0
+
+ - uses: hynek/build-and-inspect-python-package@v1
+
test:
+ needs: [package]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
@@ -66,9 +79,14 @@ jobs:
echo "C:\Program Files (x86)\gnupg\bin" >> $env:GITHUB_PATH
git config --system gpg.program "C:\Program Files (x86)\gnupg\bin\gpg.exe"
if: runner.os == 'Windows'
- - run: pip install -U 'setuptools>=45'
+ - run: pip install -U 'setuptools>=60'
if: matrix.python_version != 'msys2'
- - run: pip install -e .[toml,test]
+ - uses: actions/download-artifact@v3
+ with:
+ name: Packages
+ path: dist
+ - shell: bash
+ run: pip install "$(echo -n dist/*whl)[toml,test]"
- run: |
$(hg debuginstall --template "{pythonexe}") -m pip install hg-git --user
if: matrix.os == 'ubuntu-latest'
@@ -81,58 +99,21 @@ jobs:
- name: Setup python
uses: actions/setup-python@v4
with:
- python-version: "3.7"
+ python-version: "3.8"
architecture: x64
- run: pip install -e .[toml,test] pytest virtualenv
- run: pytest --test-legacy testing/test_setuptools_support.py || true # ignore fail flaky on ci
- dist:
- runs-on: ubuntu-latest
-
- needs: [test]
- name: Python sdist/wheel
- steps:
- - uses: actions/checkout@v3
- - uses: actions/setup-python@v4
- with:
- python-version: "3.8"
- - name: Install dependencies
- run: |
- python -m pip install --upgrade pip
- pip install --upgrade wheel setuptools build
-
- - name: Build package
- run: python -m build -o dist/
- - uses: actions/upload-artifact@v3
- with:
- name: dist
- path: dist
-
-
- dist_check:
- runs-on: ubuntu-latest
- needs: [dist]
- steps:
- - uses: actions/setup-python@v4
- with:
- python-version: "3.8"
- - name: Install dependencies
- run: pip install twine
- - uses: actions/download-artifact@v3
- with:
- name: dist
- path: dist
- - run: twine check --strict dist/*
dist_upload:
runs-on: ubuntu-latest
if: github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')
- needs: [dist_check]
+ needs: [test]
steps:
- uses: actions/download-artifact@v3
with:
- name: dist
+ name: Packages
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
diff --git a/.gitignore b/.gitignore
index b66b65a..529a7a2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,7 +8,7 @@
### Other editors
.*.swp
-
+.vscode/
### Python template
# Byte-compiled / optimized
@@ -41,6 +41,7 @@ htmlcov/
.coverage.*
.cache
.pytest_cache
+.mypy_cache/
nosetests.xml
coverage.xml
*,cover
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index ced36e7..c32c140 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -22,6 +22,7 @@ repos:
rev: 6.0.0
hooks:
- id: flake8
+ exclude: scm_hack_build_backend.py
- repo: https://github.com/asottile/pyupgrade
rev: v3.3.1
hooks:
diff --git a/CHANGELOG.rst b/CHANGELOG.rst
index 34aeee5..155cb30 100644
--- a/CHANGELOG.rst
+++ b/CHANGELOG.rst
@@ -6,7 +6,7 @@ breaking
--------
* remove legacy version parser api - config arg always required
* turn Configuration into a dataclass
-* require confiuration to always pass into helpers
+* require configuration to always pass into helpers
features
--------
@@ -27,7 +27,7 @@ features
v7.1.0
======
-* #748: use tomllib from stdlib
+* #748: use ``tomllib`` from stdlib
* fix #762: handle non-ascii in setup.cfg
* #752: implement fallback file finders for archives
* #765: removed coding header in python template
@@ -44,7 +44,7 @@ v7.0.5
v7.0.4
=======
-* fix #727: correctly handle incomplete archivals from setuptools_scm_git_archival
+* fix #727: correctly handle incomplete archival from setuptools_scm_git_archival
* fix #691: correctly handle specifying root in pyproject.toml
* correct root override check condition (to ensure absolute path matching)
* allow root by the cli to be considered relative to the cli (using abspath)
@@ -79,7 +79,7 @@ v7.0.0
v6.4.2
======
-* fix #671 : NoReturn is not avaliable in painfully dead python 3.6
+* fix #671 : NoReturn is not available in painfully dead python 3.6
v6.4.1
@@ -87,7 +87,7 @@ v6.4.1
* fix regression #669: restore get_version signature
-* fix #668: harden the selftest for distribution extras
+* fix #668: harden the self-test for distribution extras
6.4.0
======
@@ -198,7 +198,7 @@ v5.0.0
Breaking changes:
-* fix #339: strict errors on missing scms when parsing a scm dir to avoid false version lookups
+* fix #339: strict errors on missing scm when parsing a scm dir to avoid false version lookups
* fix #337: if relative_to is a directory instead of a file,
consider it as direct target instead of the containing folder and print a warning
@@ -282,7 +282,7 @@ v3.4.1
======
* pull in #377 to fix #374: correctly set up the default version scheme for pyproject usage.
- this bugfix got missed when ruushing the release.
+ this bugfix got missed when rushing the release.
v3.4.0
======
@@ -290,7 +290,7 @@ v3.4.0
* fix #181 - add support for projects built under setuptools declarative config
by way of the setuptools.finalize_distribution_options hook in Setuptools 42.
-* fix #305 - ensure the git file finder closes filedescriptors even when errors happen
+* fix #305 - ensure the git file finder closes file descriptors even when errors happen
* fix #381 - clean out env vars from the git hook system to ensure correct function from within
@@ -338,7 +338,7 @@ v3.1.0
v3.0.6
======
-* fix #295 - correctly handle selfinstall from tarballs
+* fix #295 - correctly handle self install from tarballs
v3.0.5
======
@@ -350,12 +350,12 @@ v3.0.5
v3.0.4
=======
-* rerelease of 3.0.3 after fixing the release process
+* re-release of 3.0.3 after fixing the release process
v3.0.3 (pulled from pypi due to a packaging issue)
======
-* fix #286 - duo an oversight a helper functio nwas returning a generator instead of a list
+* fix #286 - duo an oversight a helper function was returning a generator instead of a list
v3.0.2
@@ -404,7 +404,7 @@ v2.0.0
v1.17.0
========
-* fix regression in git support - use a function to ensure it works in egg isntalled mode
+* fix regression in git support - use a function to ensure it works in egg installed mode
* actually fail if file finding fails in order to see broken setups instead of generating broken dists
(thanks Mehdi ABAAKOUK for both)
@@ -427,7 +427,7 @@ v1.16.0
=======
* drop support for eol python versions
-* #214 - fix misuse in surogate-escape api
+* #214 - fix misuse in surrogate-escape api
* add the node-and-timestamp local version scheme
* respect git export ignores
* avoid shlex.split on windows
diff --git a/pyproject.toml b/pyproject.toml
index 93a1e44..f8cb696 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,10 +1,14 @@
[build-system]
-build-backend = "setuptools.build_meta"
+build-backend = "scm_hack_build_backend"
requires = [
"packaging>=20",
"setuptools>=55",
+ 'tomli; python_version < "3.11"',
"typing_extensions",
]
+backend-path = [
+ ".",
+]
[project]
name = "setuptools-scm"
@@ -42,6 +46,14 @@ dependencies = [
'tomli>=1; python_version < "3.11"',
"typing-extensions",
]
+[project.optional-dependencies]
+test = [
+ "pytest",
+ "virtualenv>20",
+]
+toml = [
+]
+
[project.urls]
repository = "https://github.com/pypa/setuptools_scm/"
@@ -90,5 +102,8 @@ pip-egg-info = "setuptools_scm.hacks:parse_pip_egg_info"
+[tool.setuptools.dynamic]
+version = {attr = "scm_hack_build_backend.dynamic_version"}
+
[tool.setuptools.packages.find]
where = ["src"]
diff --git a/scm_hack_build_backend.py b/scm_hack_build_backend.py
new file mode 100644
index 0000000..08c8fae
--- /dev/null
+++ b/scm_hack_build_backend.py
@@ -0,0 +1,60 @@
+"""
+this module is a hack only in place to allow for setuptools
+to use the attribute for the versions
+"""
+from __future__ import annotations
+
+import os
+import sys
+from pathlib import Path
+
+root = Path(__file__).parent
+sys.path.insert(0, os.fspath(root / "src"))
+
+from setuptools.build_meta import ( # type: ignore[attr-defined]
+ get_requires_for_build_wheel,
+ get_requires_for_build_sdist,
+ prepare_metadata_for_build_wheel,
+ build_wheel,
+ build_sdist,
+ get_requires_for_build_editable,
+ prepare_metadata_for_build_editable,
+ build_editable,
+)
+
+
+from setuptools_scm import get_version
+from setuptools_scm.hacks import parse_pkginfo
+from setuptools_scm import git
+from setuptools_scm import hg
+from setuptools_scm.version import guess_next_dev_version, get_local_node_and_date
+from setuptools_scm import Configuration
+
+from setuptools_scm.version import ScmVersion
+
+
+dynamic_version: str
+
+
+def parse(root: str, config: Configuration) -> ScmVersion | None:
+ try:
+ return parse_pkginfo(root, config)
+ except OSError:
+ return git.parse(root, config=config) or hg.parse(root, config=config)
+
+
+def scm_version() -> str:
+ return get_version(
+ root=str(root),
+ parse=parse,
+ version_scheme=guess_next_dev_version,
+ local_scheme=get_local_node_and_date,
+ )
+
+
+def __getattr__(name: str) -> str:
+ if name == "dynamic_version":
+ global dynamic_version
+ dynamic_version = scm_version()
+ return dynamic_version
+ raise AttributeError(name)
diff --git a/setup.py b/setup.py
deleted file mode 100644
index 124b944..0000000
--- a/setup.py
+++ /dev/null
@@ -1,58 +0,0 @@
-"""\
-important note:
-
-the setup of setuptools_scm is self-using,
-the first execution of `python setup.py egg_info`
-will generate partial data
-its critical to run `python setup.py egg_info`
-once before running sdist or easy_install on a fresh checkouts
-
-pip usage is recommended
-"""
-from __future__ import annotations
-
-import os
-import sys
-
-import setuptools
-
-
-def scm_version() -> str:
- here = os.path.dirname(os.path.abspath(__file__))
- src = os.path.join(here, "src")
-
- sys.path.insert(0, src)
-
- from setuptools_scm import get_version
- from setuptools_scm.hacks import parse_pkginfo
- from setuptools_scm import git
- from setuptools_scm import hg
- from setuptools_scm.version import guess_next_dev_version, get_local_node_and_date
- from setuptools_scm import Configuration
-
- from setuptools_scm.version import ScmVersion
-
- def parse(root: str, config: Configuration) -> ScmVersion | None:
- try:
- return parse_pkginfo(root, config)
- except OSError:
- return git.parse(root, config=config) or hg.parse(root, config=config)
-
- return get_version(
- root=here,
- parse=parse,
- version_scheme=guess_next_dev_version,
- local_scheme=get_local_node_and_date,
- )
-
-
-if __name__ == "__main__":
- setuptools.setup(
- version=scm_version(),
- extras_require={
- "toml": [
- "setuptools>=42",
- ],
- "test": ["pytest>=6.2", "virtualenv>20"],
- },
- )
diff --git a/testing/check_self_install.py b/testing/check_self_install.py
deleted file mode 100644
index 0cfab33..0000000
--- a/testing/check_self_install.py
+++ /dev/null
@@ -1,8 +0,0 @@
-from __future__ import annotations
-
-import pkg_resources
-
-import setuptools_scm
-
-dist = pkg_resources.get_distribution("setuptools_scm")
-assert dist.version == setuptools_scm.get_version(), dist.version