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..0ac83ba --- /dev/null +++ b/py.requirements/packaging.txt @@ -0,0 +1,21 @@ +# ============================================================================ +# PYTHON PACKAGE REQUIREMENTS: packaging support +# ============================================================================ +# DESCRIPTION: +# pip install -r +# +# 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' diff --git a/pyproject.toml b/pyproject.toml index ba02098..cc40bde 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,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", @@ -97,9 +106,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 +116,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.py b/setup.py index e44d7ee..a2d1a5c 100644 --- a/setup.py +++ b/setup.py @@ -4,8 +4,6 @@ Setup script for "parse_type" package. USAGE: - python setup.py install - # OR: pip install . SEE ALSO: @@ -16,6 +14,7 @@ RELATED: * https://setuptools.readthedocs.io/en/latest/history.html +* https://setuptools-scm.readthedocs.io/en/latest/usage/ """ import sys @@ -24,6 +23,8 @@ # -- USE: setuptools from setuptools import setup, find_packages +# DISABLED: from setuptools_scm import ScmVersion + # ----------------------------------------------------------------------------- @@ -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 = "jenisys@noreply.github.com", url = "https://github.com/jenisys/parse_type", @@ -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'", @@ -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", 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}