Skip to content

Commit cf10d27

Browse files
committed
Use setuptools-scm
* Use "parse_type/_version.py" as temporary file * Packaging tweaks: Related to Python 2.7 OTHERWISE: * REMOVE: bumpversion * HINT: setup.py -- Needed for: Python 2.7, pypy
1 parent e0f2a91 commit cf10d27

File tree

15 files changed

+120
-88
lines changed

15 files changed

+120
-88
lines changed

.bumpversion.cfg

Lines changed: 0 additions & 6 deletions
This file was deleted.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
*.py[cod]
22

33
# -- TEMPORARY PYTHON PACKAGE PARTS:
4+
parse_type/_version.py
45
MANIFEST
56
*.egg
67
*.egg-info

.repos

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ===========================================================================
2+
# vcs: Multi-repo configuration
3+
# ===========================================================================
4+
# USAGE:
5+
# vcs --commands # Show available commands
6+
#
7+
# vcs import < .repos
8+
# vcs import --input=.repos
9+
# vcs import --input=https://github.com/jenisys/cxx.simplelog/blob/master/.repos
10+
# vcs import --input=https://github.com/jenisys/cxx.simplelog/blob/master/.rosinstall
11+
# vcs import --shallow --input=.repos
12+
# vcs import lib/ --input=.repos
13+
#
14+
# vcs pull
15+
# vcs status
16+
#
17+
# vcs export --nested # Use branch-name
18+
# vcs export --nested --exact # Use commit-hashes instead of branch-name
19+
# vcs export --nested --exact-with-tags # Use tags or commit-hashes
20+
# vcs export --nested lib/doctest # For a specific path instead of ".".
21+
#
22+
# BAD: vcs-export adds basename of current-directory to repositories.
23+
#
24+
# SEE ALSO:
25+
# * https://github.com/dirk-thomas/vcstool
26+
# ===========================================================================
27+
# REQUIRES: pip install vcstool
28+
29+
repositories:
30+
lib/parse:
31+
type: git
32+
url: https://github.com/r1chardj0n3s/parse.git
33+
version: master

.rosinstall

Lines changed: 0 additions & 6 deletions
This file was deleted.

bin/invoke

Lines changed: 0 additions & 8 deletions
This file was deleted.

bin/invoke.cmd

Lines changed: 0 additions & 9 deletions
This file was deleted.

parse_type/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,3 @@
1111
from parse_type.builder import TypeBuilder, build_type_dict
1212

1313
__all__ = ["Cardinality", "TypeBuilder", "build_type_dict"]
14-
__version__ = "0.6.3"

py.requirements/all.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
# ============================================================================
1010

1111
-r basic.txt
12+
-r packaging.txt
1213
-r develop.txt
1314
-r testing.txt

py.requirements/develop.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
# -- BUILD-SYSTEM SUPPORT: Using invoke
66
-r ../tasks/py.requirements.txt
77

8-
# -- PROJECT ADMIN SUPPORT:
9-
bump2version >= 0.5.6
10-
118
# -- RELEASE MANAGEMENT: Push package to pypi.
12-
build >= 0.5.1
139
twine >= 1.13.0
14-
wheel
10+
-r packaging.txt
1511

1612
# -- PYTHON2/PYTHON3 COMPATIBILITY:
1713
modernize >= 0.5
@@ -20,6 +16,9 @@ modernize >= 0.5
2016
typing-extensions; python_version >= '3.8'
2117
typer >= 0.12.5; python_version >= '3.7'
2218

19+
# -- MULTI-REPO TOOL:
20+
vcstool >= 0.3.0
21+
2322
# -- LINTERS:
2423
ruff; python_version >= '3.7'
2524
pylint

py.requirements/packaging.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# ============================================================================
2+
# PYTHON PACKAGE REQUIREMENTS: packaging support
3+
# ============================================================================
4+
# DESCRIPTION:
5+
# pip install -r <THIS_FILE>
6+
#
7+
# SEE ALSO:
8+
# * http://www.pip-installer.org/
9+
# ============================================================================
10+
11+
# -- PACKAGING SUPPORT:
12+
build >= 0.5.1
13+
setuptools
14+
setuptools-scm
15+
wheel
16+
17+
# -- DISABLED:
18+
# setuptools >= 64.0.0; python_version >= '3.5'
19+
# setuptools < 45.0.0; python_version < '3.5' # DROP: Python2, Python 3.4 support.
20+
# setuptools_scm >= 8.0.0; python_version >= '3.7'
21+
# setuptools_scm < 8.0.0; python_version < '3.7'

pyproject.toml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# =============================================================================
22
# PACKAGING: parse_type
33
# =============================================================================
4-
# SEE: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
5-
# SEE: https://pypi.org/classifiers/
6-
# MAYBE: requires = ["setuptools", "setuptools-scm"]
4+
# SEE ALSO:
5+
# * https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
6+
# * https://setuptools-scm.readthedocs.io/en/latest/usage/
7+
# * https://pypi.org/classifiers/
8+
# =============================================================================
9+
# PYTHON3: requires = ["setuptools>=64", "setuptools_scm>=8", "wheel"]
710
[build-system]
8-
requires = ["setuptools"]
11+
requires = ["setuptools", "setuptools_scm", "wheel"]
912
build-backend = "setuptools.build_meta"
1013

1114

@@ -15,6 +18,7 @@ authors = [
1518
{name = "Jens Engel", email = "jenisys@noreply.github.com"},
1619
]
1720
description = "Simplifies to build parse types based on the parse module"
21+
dynamic = ["version"]
1822
readme = "README.rst"
1923
requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
2024
keywords = ["parse", "parsing"]
@@ -48,8 +52,6 @@ dependencies = [
4852
"enum34; python_version < '3.4'",
4953
"six >= 1.15",
5054
]
51-
# PREPARED:
52-
dynamic = ["version"]
5355

5456

5557
[project.urls]
@@ -61,7 +63,14 @@ Download = "https://pypi.org/project/parse_type/"
6163

6264
[project.optional-dependencies]
6365
develop = [
66+
# -- DISABLED:
67+
# "setuptools >= 64.0.0; python_version >= '3.5'",
68+
# "setuptools < 45.0.0; python_version < '3.5'", # DROP: Python2, Python 3.4 support.
69+
# "setuptools_scm >= 8.0.0; python_version >= '3.7'",
70+
# "setuptools_scm < 8.0.0; python_version < '3.7'",
6471
"setuptools",
72+
"setuptools-scm",
73+
"wheel",
6574
"build >= 0.5.1",
6675
"twine >= 1.13.0",
6776
"coverage >= 4.4",
@@ -97,16 +106,20 @@ universal = true
97106
platforms = ["any"]
98107
zip-safe = true
99108

100-
# -- PREPARED:
101-
[tool.setuptools.dynamic]
102-
version = {attr = "parse_type.__version__"}
109+
# -- DISABLED:
110+
# [tool.setuptools.dynamic]
111+
# version = {attr = "parse_type._version.version"}
103112

104113
[tool.setuptools.packages.find]
105114
where = ["."]
106115
include = ["parse_type*"]
107116
exclude = ["tests*"]
108117
namespaces = false
109118

119+
# -- SETUPTOOLS-SCM: Generate version info from git-tag(s).
120+
[tool.setuptools_scm]
121+
version_file = "parse_type/_version.py"
122+
110123

111124
# =============================================================================
112125
# OTHER TOOLS

setup.py

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
Setup script for "parse_type" package.
55
66
USAGE:
7-
python setup.py install
8-
# OR:
97
pip install .
108
119
SEE ALSO:
@@ -16,6 +14,7 @@
1614
RELATED:
1715
1816
* https://setuptools.readthedocs.io/en/latest/history.html
17+
* https://setuptools-scm.readthedocs.io/en/latest/usage/
1918
"""
2019

2120
import sys
@@ -24,6 +23,8 @@
2423

2524
# -- USE: setuptools
2625
from setuptools import setup, find_packages
26+
# DISABLED: from setuptools_scm import ScmVersion
27+
2728

2829

2930
# -----------------------------------------------------------------------------
@@ -48,12 +49,23 @@ def find_packages_by_root_package(where):
4849
return packages
4950

5051

52+
# -- SEE: https://setuptools-scm.readthedocs.io/en/latest/customizing/
53+
# HINT: get_version_func(version: ScmVersion) -> str:
54+
def get_this_package_version(version):
55+
from setuptools_scm.version import guess_next_version
56+
if version.distance is None:
57+
# -- FIX: Python 2.7 problem w/ setuptools-scm v5.0.2
58+
version.distance = 0
59+
return version.format_next_version(guess_next_version, "{guessed}b{distance}")
60+
61+
5162
# -----------------------------------------------------------------------------
5263
# SETUP:
5364
# -----------------------------------------------------------------------------
5465
setup(
5566
name = "parse_type",
56-
version = "0.6.3",
67+
# DISABLED: version = "0.6.3",
68+
use_scm_version={"version_scheme": get_this_package_version},
5769
author = "Jens Engel",
5870
author_email = "jenisys@noreply.github.com",
5971
url = "https://github.com/jenisys/parse_type",
@@ -67,6 +79,16 @@ def find_packages_by_root_package(where):
6779

6880
# -- REQUIREMENTS:
6981
python_requires=">=2.7, !=3.0.*, !=3.1.*",
82+
setup_requires=[
83+
# -- DISABLED:
84+
# "setuptools >= 64.0.0; python_version >= '3.5'",
85+
# "setuptools < 45.0.0; python_version < '3.5'", # DROP: Python2, Python 3.4 support.
86+
# "setuptools_scm >= 8.0.0; python_version >= '3.7'",
87+
# "setuptools_scm < 8.0.0; python_version < '3.7'",
88+
"setuptools",
89+
"setuptools-scm",
90+
"wheel",
91+
],
7092
install_requires=[
7193
"parse >= 1.18.0; python_version >= '3.0'",
7294
"parse >= 1.13.1; python_version <= '2.7'",
@@ -84,7 +106,6 @@ def find_packages_by_root_package(where):
84106
"sphinx_bootstrap_theme >= 0.6.0"
85107
],
86108
"develop": [
87-
"setuptools",
88109
"build >= 0.5.1",
89110
"twine >= 1.13.0",
90111
"coverage >= 4.4",

tasks/__main__.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

tasks/release.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,15 @@ def checklist(ctx=None): # pylint: disable=unused-argument
6666
[ ] All tests pass w/ tox
6767
6868
RELEASE CHECKLIST:
69-
[{x1}] Bump version to new-version and tag repository (via bump_version)
69+
[{x1}] Bump version to new-version by adding tag to the repository
7070
[{x2}] Build packages (sdist, bdist_wheel via prepare)
7171
[{x3}] Register and upload packages to testpypi repository (first)
7272
[{x4}] Verify release is OK and packages from testpypi are usable
7373
[{x5}] Register and upload packages to pypi repository
7474
[{x6}] Push last changes to Github repository
7575
7676
POST-RELEASE CHECKLIST:
77-
[ ] Bump version to new-develop-version (via bump_version)
77+
[ ] Bump version to new-develop-version by adding tag to the repository
7878
[ ] Adapt CHANGES (if necessary)
7979
[ ] Commit latest changes to Github repository
8080
"""
@@ -86,29 +86,29 @@ def checklist(ctx=None): # pylint: disable=unused-argument
8686

8787

8888
@task(name="bump_version")
89-
def bump_version(ctx, new_version, version_part=None, dry_run=False):
89+
def bump_version(ctx, new_version, dry_run=False):
9090
"""Bump version (to prepare a new release)."""
91-
version_part = version_part or "minor"
91+
if not new_version.startswith("v"):
92+
new_version = "v{version}".format(version=new_version)
93+
9294
if dry_run:
9395
ctx = DryRunContext(ctx)
94-
ctx.run("bumpversion --new-version={} {}".format(new_version,
95-
version_part))
96+
ctx.run("git tag {version}".format(version=new_version))
9697

9798

9899
@task(name="build", aliases=["build_packages"])
99100
def build_packages(ctx, hide=False):
100101
"""Build packages for this release."""
101102
print("build_packages:")
102-
ctx.run("python setup.py sdist bdist_wheel", echo=True, hide=hide)
103+
ctx.run("python -m build", echo=True, hide=hide)
103104

104105

105106
@task
106-
def prepare(ctx, new_version=None, version_part=None, hide=True,
107+
def prepare(ctx, new_version=None, hide=True,
107108
dry_run=False):
108109
"""Prepare the release: bump version, build packages, ..."""
109110
if new_version is not None:
110-
bump_version(ctx, new_version, version_part=version_part,
111-
dry_run=dry_run)
111+
bump_version(ctx, new_version, dry_run=dry_run)
112112
build_packages(ctx, hide=hide)
113113
packages = ensure_packages_exist(ctx, check_only=True)
114114
print_packages(packages)

tox.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
minversion = 3.10.0
2323
envlist = py312, py311, py310, py39, doctest, pypy3
2424
skip_missing_interpreters = True
25+
isolated_build = True
2526
# DISABLED: sitepackages = False
2627

2728

@@ -49,7 +50,8 @@ setenv =
4950
# * pip-install seems to need "--user" option.
5051
# * Script(s) do not seem to be installed any more (actually to $HOME/User area).
5152
[testenv:py27]
52-
install_command = pip install --user -U {opts} {packages}
53+
# DISABLED: install_command = pip install --user -U {opts} {packages}
54+
install_command = pip install -U {opts} {packages}
5355
changedir = {toxinidir}
5456
commands=
5557
python -m pytest {posargs:tests}

0 commit comments

Comments
 (0)