From d58636c1f2b703ad6ca2c34943b8343aac5f4f02 Mon Sep 17 00:00:00 2001 From: jenisys Date: Thu, 3 Oct 2024 12:31:59 +0200 Subject: [PATCH] Use setuptools-scm * Use "parse_type/_version.py" as temporary file * Packaging tweaks: Related to Python 2.7 OTHERWISE: * REMOVE: bumpversion * REMOVE: setup.py --- .bumpversion.cfg | 6 -- .gitignore | 1 + .repos | 33 +++++++++ .rosinstall | 6 -- bin/invoke | 8 --- bin/invoke.cmd | 9 --- parse_type/__init__.py | 1 - py.requirements/all.txt | 1 + py.requirements/develop.txt | 9 ++- py.requirements/packaging.txt | 17 +++++ pyproject.toml | 30 +++++--- setup.cfg | 5 -- setup.py | 131 ---------------------------------- tasks/__main__.py | 29 -------- tasks/release.py | 20 +++--- tox.ini | 4 +- 16 files changed, 89 insertions(+), 221 deletions(-) delete mode 100644 .bumpversion.cfg create mode 100644 .repos delete mode 100644 .rosinstall delete mode 100755 bin/invoke delete mode 100644 bin/invoke.cmd create mode 100644 py.requirements/packaging.txt delete mode 100644 setup.cfg delete mode 100644 setup.py delete mode 100644 tasks/__main__.py diff --git a/.bumpversion.cfg b/.bumpversion.cfg deleted file mode 100644 index b46eab9..0000000 --- a/.bumpversion.cfg +++ /dev/null @@ -1,6 +0,0 @@ -[bumpversion] -current_version = 0.6.3 -files = setup.py parse_type/__init__.py .bumpversion.cfg -commit = False -tag = False -allow_dirty = True diff --git a/.gitignore b/.gitignore index bdad73b..2967eb4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ *.py[cod] # -- TEMPORARY PYTHON PACKAGE PARTS: +parse_type/_version.py MANIFEST *.egg *.egg-info diff --git a/.repos b/.repos new file mode 100644 index 0000000..40173ad --- /dev/null +++ b/.repos @@ -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 diff --git a/.rosinstall b/.rosinstall deleted file mode 100644 index c13f7c1..0000000 --- a/.rosinstall +++ /dev/null @@ -1,6 +0,0 @@ -# GIT MULTI-REPO TOOL: wstool -# REQUIRES: wstool >= 0.1.17 (better: 0.1.18; not in pypi yet) -- git: - local-name: lib/parse - uri: https://github.com/r1chardj0n3s/parse - version: master diff --git a/bin/invoke b/bin/invoke deleted file mode 100755 index e9800e8..0000000 --- a/bin/invoke +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -#!/bin/bash -# RUN INVOKE: From bundled ZIP file. - -HERE=$(dirname $0) -export INVOKE_TASKS_USE_VENDOR_BUNDLES="yes" - -python ${HERE}/../tasks/_vendor/invoke.zip $* diff --git a/bin/invoke.cmd b/bin/invoke.cmd deleted file mode 100644 index 9303432..0000000 --- a/bin/invoke.cmd +++ /dev/null @@ -1,9 +0,0 @@ -@echo off -REM RUN INVOKE: From bundled ZIP file. - -setlocal -set HERE=%~dp0 -set INVOKE_TASKS_USE_VENDOR_BUNDLES="yes" -if not defined PYTHON set PYTHON=python - -%PYTHON% %HERE%../tasks/_vendor/invoke.zip "%*" diff --git a/parse_type/__init__.py b/parse_type/__init__.py index 8147313..898c5b4 100644 --- a/parse_type/__init__.py +++ b/parse_type/__init__.py @@ -11,4 +11,3 @@ from parse_type.builder import TypeBuilder, build_type_dict __all__ = ["Cardinality", "TypeBuilder", "build_type_dict"] -__version__ = "0.6.3" diff --git a/py.requirements/all.txt b/py.requirements/all.txt index c194520..e5f19e4 100644 --- a/py.requirements/all.txt +++ b/py.requirements/all.txt @@ -9,5 +9,6 @@ # ============================================================================ -r basic.txt +-r packaging.txt -r develop.txt -r testing.txt diff --git a/py.requirements/develop.txt b/py.requirements/develop.txt index d1bc1fb..b3fd26b 100644 --- a/py.requirements/develop.txt +++ b/py.requirements/develop.txt @@ -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 @@ -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 diff --git a/py.requirements/packaging.txt b/py.requirements/packaging.txt new file mode 100644 index 0000000..f53bbd3 --- /dev/null +++ b/py.requirements/packaging.txt @@ -0,0 +1,17 @@ +# ============================================================================ +# PYTHON PACKAGE REQUIREMENTS: packaging support +# ============================================================================ +# DESCRIPTION: +# pip install -r +# +# SEE ALSO: +# * http://www.pip-installer.org/ +# ============================================================================ + +# -- PACKAGING SUPPORT: +build >= 0.5.1 +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' +wheel diff --git a/pyproject.toml b/pyproject.toml index ba02098..a49b7ad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" @@ -15,6 +18,7 @@ authors = [ {name = "Jens Engel", email = "jenisys@noreply.github.com"}, ] 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"] @@ -48,8 +52,6 @@ dependencies = [ "enum34; python_version < '3.4'", "six >= 1.15", ] -# PREPARED: -dynamic = ["version"] [project.urls] @@ -61,7 +63,11 @@ Download = "https://pypi.org/project/parse_type/" [project.optional-dependencies] develop = [ - "setuptools", + "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'", + "wheel", "build >= 0.5.1", "twine >= 1.13.0", "coverage >= 4.4", @@ -97,9 +103,9 @@ 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 = ["."] @@ -107,6 +113,10 @@ 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 diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index ce46fc2..0000000 --- a/setup.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[upload_docs] -upload_dir = build/docs/html - -[bdist_wheel] -universal = 1 diff --git a/setup.py b/setup.py deleted file mode 100644 index e44d7ee..0000000 --- a/setup.py +++ /dev/null @@ -1,131 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -""" -Setup script for "parse_type" package. - -USAGE: - python setup.py install - # OR: - pip install . - -SEE ALSO: - -* https://pypi.org/pypi/parse_type -* https://github.com/jenisys/parse_type - -RELATED: - -* https://setuptools.readthedocs.io/en/latest/history.html -""" - -import sys -import os.path -sys.path.insert(0, os.curdir) - -# -- USE: setuptools -from setuptools import setup, find_packages - - -# ----------------------------------------------------------------------------- -# PREPARE SETUP: -# ----------------------------------------------------------------------------- -HERE = os.path.dirname(__file__) -README = os.path.join(HERE, "README.rst") -long_description = ''.join(open(README).readlines()[4:]) - - -# ----------------------------------------------------------------------------- -# UTILITY: -# ----------------------------------------------------------------------------- -def find_packages_by_root_package(where): - """Better than excluding everything that is not needed, - collect only what is needed. - """ - root_package = os.path.basename(where) - packages = [ "%s.%s" % (root_package, sub_package) - for sub_package in find_packages(where)] - packages.insert(0, root_package) - return packages - - -# ----------------------------------------------------------------------------- -# SETUP: -# ----------------------------------------------------------------------------- -setup( - name = "parse_type", - version = "0.6.3", - author = "Jens Engel", - author_email = "jenisys@noreply.github.com", - url = "https://github.com/jenisys/parse_type", - download_url= "http://pypi.python.org/pypi/parse_type", - description = "Simplifies to build parse types based on the parse module", - long_description = long_description, - keywords= "parse, parsing", - license = "MIT", - packages = find_packages_by_root_package("parse_type"), - include_package_data = True, - - # -- REQUIREMENTS: - python_requires=">=2.7, !=3.0.*, !=3.1.*", - install_requires=[ - "parse >= 1.18.0; python_version >= '3.0'", - "parse >= 1.13.1; python_version <= '2.7'", - "enum34; python_version < '3.4'", - "six >= 1.15", - ], - tests_require=[ - "pytest < 5.0; python_version < '3.0'", # >= 4.2 - "pytest >= 5.0; python_version >= '3.0'", - "pytest-html >= 1.19.0", - ], - extras_require={ - "docs": [ - "Sphinx >=1.6", - "sphinx_bootstrap_theme >= 0.6.0" - ], - "develop": [ - "setuptools", - "build >= 0.5.1", - "twine >= 1.13.0", - "coverage >= 4.4", - "pytest < 5.0; python_version < '3.0'", # >= 4.2 - "pytest >= 5.0; python_version >= '3.0'", - "pytest-html >= 1.19.0", - "pytest-cov", - "tox >=2.8,<4.0", - "virtualenv < 20.22.0; python_version <= '3.6'", # -- SUPPORT FOR: Python 2.7, Python <= 3.6 - "virtualenv >= 20.0.0; python_version > '3.6'", - "ruff; python_version >= '3.7'", - "pylint", - ], - }, - - test_suite = "tests", - test_loader = "setuptools.command.test:ScanningLoader", - zip_safe = True, - - classifiers = [ - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Environment :: Web Environment", - "Intended Audience :: Developers", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.2", - "Programming Language :: Python :: 3.3", - "Programming Language :: Python :: 3.4", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: Implementation :: CPython", - "Programming Language :: Python :: Implementation :: PyPy", - "Topic :: Software Development :: Code Generators", - "Topic :: Software Development :: Libraries :: Python Modules", - ], - platforms = ['any'], -) diff --git a/tasks/__main__.py b/tasks/__main__.py deleted file mode 100644 index d8d9174..0000000 --- a/tasks/__main__.py +++ /dev/null @@ -1,29 +0,0 @@ -# -*- coding: UTF-8 -*- -""" -Provides "invoke" script when invoke is not installed. -Note that this approach uses the "tasks/_vendor/invoke.zip" bundle package. - -Usage:: - - # -- INSTEAD OF: invoke command - # Show invoke version - python -m tasks --version - - # List all tasks - python -m tasks -l - -.. seealso:: - - * http://pyinvoke.org - * https://github.com/pyinvoke/invoke -""" - -from __future__ import absolute_import, print_function - -# ----------------------------------------------------------------------------- -# AUTO-MAIN: -# ----------------------------------------------------------------------------- -if __name__ == "__main__": - from invoke.main import program - import sys - sys.exit(program.run()) diff --git a/tasks/release.py b/tasks/release.py index 6a2594c..4df3eed 100644 --- a/tasks/release.py +++ b/tasks/release.py @@ -66,7 +66,7 @@ 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 @@ -74,7 +74,7 @@ def checklist(ctx=None): # pylint: disable=unused-argument [{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 """ @@ -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) diff --git a/tox.ini b/tox.ini index 264ce1b..307ecaa 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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}