Skip to content

Commit

Permalink
Use setuptools-scm
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
jenisys committed Oct 3, 2024
1 parent e0f2a91 commit cf10d27
Show file tree
Hide file tree
Showing 15 changed files with 120 additions and 88 deletions.
6 changes: 0 additions & 6 deletions .bumpversion.cfg

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*.py[cod]

# -- TEMPORARY PYTHON PACKAGE PARTS:
parse_type/_version.py
MANIFEST
*.egg
*.egg-info
Expand Down
33 changes: 33 additions & 0 deletions .repos
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ===========================================================================
# vcs: Multi-repo configuration
# ===========================================================================
# USAGE:
# vcs --commands # Show available commands
#
# vcs import < .repos
# vcs import --input=.repos
# vcs import --input=https://github.com/jenisys/cxx.simplelog/blob/master/.repos
# vcs import --input=https://github.com/jenisys/cxx.simplelog/blob/master/.rosinstall
# vcs import --shallow --input=.repos
# vcs import lib/ --input=.repos
#
# vcs pull
# vcs status
#
# vcs export --nested # Use branch-name
# vcs export --nested --exact # Use commit-hashes instead of branch-name
# vcs export --nested --exact-with-tags # Use tags or commit-hashes
# vcs export --nested lib/doctest # For a specific path instead of ".".
#
# BAD: vcs-export adds basename of current-directory to repositories.
#
# SEE ALSO:
# * https://github.com/dirk-thomas/vcstool
# ===========================================================================
# REQUIRES: pip install vcstool

repositories:
lib/parse:
type: git
url: https://github.com/r1chardj0n3s/parse.git
version: master
6 changes: 0 additions & 6 deletions .rosinstall

This file was deleted.

8 changes: 0 additions & 8 deletions bin/invoke

This file was deleted.

9 changes: 0 additions & 9 deletions bin/invoke.cmd

This file was deleted.

1 change: 0 additions & 1 deletion parse_type/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@
from parse_type.builder import TypeBuilder, build_type_dict

__all__ = ["Cardinality", "TypeBuilder", "build_type_dict"]
__version__ = "0.6.3"
1 change: 1 addition & 0 deletions py.requirements/all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
# ============================================================================

-r basic.txt
-r packaging.txt
-r develop.txt
-r testing.txt
9 changes: 4 additions & 5 deletions py.requirements/develop.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,9 @@
# -- BUILD-SYSTEM SUPPORT: Using invoke
-r ../tasks/py.requirements.txt

# -- PROJECT ADMIN SUPPORT:
bump2version >= 0.5.6

# -- RELEASE MANAGEMENT: Push package to pypi.
build >= 0.5.1
twine >= 1.13.0
wheel
-r packaging.txt

# -- PYTHON2/PYTHON3 COMPATIBILITY:
modernize >= 0.5
Expand All @@ -20,6 +16,9 @@ modernize >= 0.5
typing-extensions; python_version >= '3.8'
typer >= 0.12.5; python_version >= '3.7'

# -- MULTI-REPO TOOL:
vcstool >= 0.3.0

# -- LINTERS:
ruff; python_version >= '3.7'
pylint
Expand Down
21 changes: 21 additions & 0 deletions py.requirements/packaging.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# ============================================================================
# PYTHON PACKAGE REQUIREMENTS: packaging support
# ============================================================================
# DESCRIPTION:
# pip install -r <THIS_FILE>
#
# SEE ALSO:
# * http://www.pip-installer.org/
# ============================================================================

# -- PACKAGING SUPPORT:
build >= 0.5.1
setuptools
setuptools-scm
wheel

# -- DISABLED:
# setuptools >= 64.0.0; python_version >= '3.5'
# setuptools < 45.0.0; python_version < '3.5' # DROP: Python2, Python 3.4 support.
# setuptools_scm >= 8.0.0; python_version >= '3.7'
# setuptools_scm < 8.0.0; python_version < '3.7'
31 changes: 22 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# =============================================================================
# PACKAGING: parse_type
# =============================================================================
# SEE: https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
# SEE: https://pypi.org/classifiers/
# MAYBE: requires = ["setuptools", "setuptools-scm"]
# SEE ALSO:
# * https://setuptools.pypa.io/en/latest/userguide/pyproject_config.html
# * https://setuptools-scm.readthedocs.io/en/latest/usage/
# * https://pypi.org/classifiers/
# =============================================================================
# PYTHON3: requires = ["setuptools>=64", "setuptools_scm>=8", "wheel"]
[build-system]
requires = ["setuptools"]
requires = ["setuptools", "setuptools_scm", "wheel"]
build-backend = "setuptools.build_meta"


Expand All @@ -15,6 +18,7 @@ authors = [
{name = "Jens Engel", email = "[email protected]"},
]
description = "Simplifies to build parse types based on the parse module"
dynamic = ["version"]
readme = "README.rst"
requires-python = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
keywords = ["parse", "parsing"]
Expand Down Expand Up @@ -48,8 +52,6 @@ dependencies = [
"enum34; python_version < '3.4'",
"six >= 1.15",
]
# PREPARED:
dynamic = ["version"]


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

[project.optional-dependencies]
develop = [
# -- DISABLED:
# "setuptools >= 64.0.0; python_version >= '3.5'",
# "setuptools < 45.0.0; python_version < '3.5'", # DROP: Python2, Python 3.4 support.
# "setuptools_scm >= 8.0.0; python_version >= '3.7'",
# "setuptools_scm < 8.0.0; python_version < '3.7'",
"setuptools",
"setuptools-scm",
"wheel",
"build >= 0.5.1",
"twine >= 1.13.0",
"coverage >= 4.4",
Expand Down Expand Up @@ -97,16 +106,20 @@ universal = true
platforms = ["any"]
zip-safe = true

# -- PREPARED:
[tool.setuptools.dynamic]
version = {attr = "parse_type.__version__"}
# -- DISABLED:
# [tool.setuptools.dynamic]
# version = {attr = "parse_type._version.version"}

[tool.setuptools.packages.find]
where = ["."]
include = ["parse_type*"]
exclude = ["tests*"]
namespaces = false

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


# =============================================================================
# OTHER TOOLS
Expand Down
29 changes: 25 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
Setup script for "parse_type" package.
USAGE:
python setup.py install
# OR:
pip install .
SEE ALSO:
Expand All @@ -16,6 +14,7 @@
RELATED:
* https://setuptools.readthedocs.io/en/latest/history.html
* https://setuptools-scm.readthedocs.io/en/latest/usage/
"""

import sys
Expand All @@ -24,6 +23,8 @@

# -- USE: setuptools
from setuptools import setup, find_packages
# DISABLED: from setuptools_scm import ScmVersion



# -----------------------------------------------------------------------------
Expand All @@ -48,12 +49,23 @@ def find_packages_by_root_package(where):
return packages


# -- SEE: https://setuptools-scm.readthedocs.io/en/latest/customizing/
# HINT: get_version_func(version: ScmVersion) -> str:
def get_this_package_version(version):
from setuptools_scm.version import guess_next_version
if version.distance is None:
# -- FIX: Python 2.7 problem w/ setuptools-scm v5.0.2
version.distance = 0
return version.format_next_version(guess_next_version, "{guessed}b{distance}")


# -----------------------------------------------------------------------------
# SETUP:
# -----------------------------------------------------------------------------
setup(
name = "parse_type",
version = "0.6.3",
# DISABLED: version = "0.6.3",
use_scm_version={"version_scheme": get_this_package_version},
author = "Jens Engel",
author_email = "[email protected]",
url = "https://github.com/jenisys/parse_type",
Expand All @@ -67,6 +79,16 @@ def find_packages_by_root_package(where):

# -- REQUIREMENTS:
python_requires=">=2.7, !=3.0.*, !=3.1.*",
setup_requires=[
# -- DISABLED:
# "setuptools >= 64.0.0; python_version >= '3.5'",
# "setuptools < 45.0.0; python_version < '3.5'", # DROP: Python2, Python 3.4 support.
# "setuptools_scm >= 8.0.0; python_version >= '3.7'",
# "setuptools_scm < 8.0.0; python_version < '3.7'",
"setuptools",
"setuptools-scm",
"wheel",
],
install_requires=[
"parse >= 1.18.0; python_version >= '3.0'",
"parse >= 1.13.1; python_version <= '2.7'",
Expand All @@ -84,7 +106,6 @@ def find_packages_by_root_package(where):
"sphinx_bootstrap_theme >= 0.6.0"
],
"develop": [
"setuptools",
"build >= 0.5.1",
"twine >= 1.13.0",
"coverage >= 4.4",
Expand Down
29 changes: 0 additions & 29 deletions tasks/__main__.py

This file was deleted.

20 changes: 10 additions & 10 deletions tasks/release.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ def checklist(ctx=None): # pylint: disable=unused-argument
[ ] All tests pass w/ tox
RELEASE CHECKLIST:
[{x1}] Bump version to new-version and tag repository (via bump_version)
[{x1}] Bump version to new-version by adding tag to the repository
[{x2}] Build packages (sdist, bdist_wheel via prepare)
[{x3}] Register and upload packages to testpypi repository (first)
[{x4}] Verify release is OK and packages from testpypi are usable
[{x5}] Register and upload packages to pypi repository
[{x6}] Push last changes to Github repository
POST-RELEASE CHECKLIST:
[ ] Bump version to new-develop-version (via bump_version)
[ ] Bump version to new-develop-version by adding tag to the repository
[ ] Adapt CHANGES (if necessary)
[ ] Commit latest changes to Github repository
"""
Expand All @@ -86,29 +86,29 @@ def checklist(ctx=None): # pylint: disable=unused-argument


@task(name="bump_version")
def bump_version(ctx, new_version, version_part=None, dry_run=False):
def bump_version(ctx, new_version, dry_run=False):
"""Bump version (to prepare a new release)."""
version_part = version_part or "minor"
if not new_version.startswith("v"):
new_version = "v{version}".format(version=new_version)

if dry_run:
ctx = DryRunContext(ctx)
ctx.run("bumpversion --new-version={} {}".format(new_version,
version_part))
ctx.run("git tag {version}".format(version=new_version))


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


@task
def prepare(ctx, new_version=None, version_part=None, hide=True,
def prepare(ctx, new_version=None, hide=True,
dry_run=False):
"""Prepare the release: bump version, build packages, ..."""
if new_version is not None:
bump_version(ctx, new_version, version_part=version_part,
dry_run=dry_run)
bump_version(ctx, new_version, dry_run=dry_run)
build_packages(ctx, hide=hide)
packages = ensure_packages_exist(ctx, check_only=True)
print_packages(packages)
Expand Down
4 changes: 3 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
minversion = 3.10.0
envlist = py312, py311, py310, py39, doctest, pypy3
skip_missing_interpreters = True
isolated_build = True
# DISABLED: sitepackages = False


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

0 comments on commit cf10d27

Please sign in to comment.