diff --git a/.github/workflows/tox.yml b/.github/workflows/tox.yml index 090b9a5..ab1407c 100644 --- a/.github/workflows/tox.yml +++ b/.github/workflows/tox.yml @@ -14,7 +14,7 @@ on: workflow_call: jobs: - unit: + tox_envs: name: ${{ matrix.tox_env }} runs-on: ${{ matrix.os }} strategy: @@ -24,7 +24,12 @@ jobs: os: # https://help.github.com/en/actions/reference/virtual-environments-for-github-hosted-runners - ubuntu-20.04 + unit: ["true"] include: + - tox_env: packaging + os: ubuntu-20.04 + python-version: 3.7 + unit: false - tox_env: py37 os: ubuntu-20.04 python-version: 3.7 @@ -69,10 +74,12 @@ jobs: run: python3 -m tox - name: Combine coverage data + if: ${{ matrix.unit }} # produce a single .coverage file at repo root run: coverage combine .tox/.coverage.* - name: Upload coverage data + if: ${{ matrix.unit }} uses: codecov/codecov-action@v1 with: name: ${{ matrix.tox_env }} @@ -95,7 +102,7 @@ jobs: if: always() needs: - - unit + - tox_envs runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index a8d55fa..4dc217b 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ Vagrantfile /build/ /dist/ /python_vagrant.egg-info/ +*.egg-info/ diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2f2aa27 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,26 @@ +[build-system] +requires = [ + "setuptools >= 45.0.0", # required by pyproject+setuptools_scm integration + "setuptools_scm >= 6.3.1", # required for "no-local-version" scheme + "setuptools_scm_git_archive >= 1.0", + "wheel", +] +build-backend = "setuptools.build_meta" + +[tool.coverage.run] +source = ["src"] +branch = true + +[tool.coverage.report] +exclude_lines = ["pragma: no cover", "if TYPE_CHECKING:"] + +[tool.isort] +profile = "black" + +[tool.pytest.ini_options] +addopts = "--no-success-flaky-report" +# ensure we treat warnings as error +filterwarnings = ["error"] + +[tool.setuptools_scm] +local_scheme = "no-local-version" diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..36c7f8e --- /dev/null +++ b/setup.cfg @@ -0,0 +1,39 @@ +[metadata] +name = python-vagrant +url = https://github.com/pycontribs/python-vagrant +project_urls = + Bug Tracker = https://github.com/pycontribs/python-vagrant/issues + CI: GitHub = https://github.com/pycontribs/python-vagrant/actions?query=workflow:gh+branch:main+event:push + Source Code = https://github.com/pycontribs/python-vagrant +description = Python bindings for interacting with Vagrant virtual machines. +long_description = file: README.md +long_description_content_type = text/markdown +author = Todd Francis DeLuca +author_email = todddeluca@yahoo.com +license = MIT +license_file = LICENSE.txt +classifiers = + Development Status :: 4 - Beta + License :: OSI Approved :: MIT License + Operating System :: OS Independent + Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 + Topic :: Utilities +keywords = + box + vagrant + vagrantfile + virtual-machine + virtualbox + +[options] +use_scm_version = True +python_requires = >=3.7 +; package_dir = +; = src +; packages = find: + +; [options.packages.find] +; where = src diff --git a/setup.py b/setup.py deleted file mode 100644 index 7882502..0000000 --- a/setup.py +++ /dev/null @@ -1,32 +0,0 @@ -import os -import re -from setuptools import setup - -# parse version from package/module without importing or evaluating the code -with open('vagrant/__init__.py') as fh: - for line in fh: - m = re.search(r"^__version__ = '(?P[^']+)'$", line) - if m: - version = m.group('version') - break - -setup( - name = 'python-vagrant', - version = version, - license = 'MIT', - description = 'Python bindings for interacting with Vagrant virtual machines.', - long_description = open(os.path.join(os.path.dirname(__file__), - 'README.md')).read(), - keywords = 'python virtual machine box vagrant virtualbox vagrantfile', - url = 'https://github.com/todddeluca/python-vagrant', - author = 'Todd Francis DeLuca', - author_email = 'todddeluca@yahoo.com', - classifiers = ['License :: OSI Approved :: MIT License', - 'Development Status :: 4 - Beta', - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', - 'Programming Language :: Python :: 3.3', - 'Programming Language :: Python :: 3.4', - ], - packages = ['vagrant'], -) diff --git a/tox.ini b/tox.ini index 6ce15b8..8235db1 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,6 @@ [tox] envlist = + packaging py [testenv] @@ -13,7 +14,31 @@ passenv = # Pass HOME to the test environment as it is required by # vagrant. Otherwise error happens due to missing HOME env variable. HOME +allowlist_externals = + sh [testenv:dev] - commands = {posargs} + +[testenv:packaging] +description = + Build package, verify metadata, install package and assert behavior when ansible is missing. +deps = + build >= 0.7.0 + twine +skip_install = true +# Ref: https://twitter.com/di_codes/status/1044358639081975813 +commands = + # build wheel and sdist using PEP-517 + {envpython} -c 'import os.path, shutil, sys; \ + dist_dir = os.path.join("{toxinidir}", "dist"); \ + os.path.isdir(dist_dir) or sys.exit(0); \ + print("Removing \{!s\} contents...".format(dist_dir), file=sys.stderr); \ + shutil.rmtree(dist_dir)' + {envpython} -m build \ + --outdir {toxinidir}/dist/ \ + {toxinidir} + # Validate metadata using twine + twine check --strict {toxinidir}/dist/* + # Install the wheel + sh -c "python3 -m pip install {toxinidir}/dist/*.whl"