From 6584edf35eef338b0f9dcf03e22c8ed0e9f4914a Mon Sep 17 00:00:00 2001 From: Stephen McDowell Date: Sun, 22 Aug 2021 13:52:07 -0600 Subject: [PATCH] fix project tooling (#31) adopt as much of `pyproject.toml` as possible --- .github/workflows/dist.yml | 28 +++++++++++ README.rst | 20 -------- ci_exec/__init__.py | 2 +- docs/source/index.rst | 15 +----- pyproject.toml | 27 +++++++++++ setup.cfg | 79 +++++++++++++++---------------- setup.py | 95 ++------------------------------------ tox.ini | 19 +++++++- 8 files changed, 119 insertions(+), 166 deletions(-) create mode 100644 .github/workflows/dist.yml create mode 100644 pyproject.toml diff --git a/.github/workflows/dist.yml b/.github/workflows/dist.yml new file mode 100644 index 0000000..5b71f5c --- /dev/null +++ b/.github/workflows/dist.yml @@ -0,0 +1,28 @@ +name: Dist +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.9] + steps: + - uses: actions/checkout@v2 + - name: Use Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install Dependencies + run: | + pip install -U pip + pip install tox + - name: Build Distribution + run: | + tox -e dist diff --git a/README.rst b/README.rst index 88f3deb..ef80ef6 100644 --- a/README.rst +++ b/README.rst @@ -34,15 +34,9 @@ ci_exec .. end_badges -.. begin_brief_desc - A wrapper package designed for running continuous integration (CI) build steps using Python 3.6+. -.. end_brief_desc - -.. begin_long_desc - Managing cross platform build scripts for CI can become tedious at times when you need to e.g., maintain two nearly identical scripts ``install_deps.sh`` and ``install_deps.bat`` due to incompatible syntaxes. ``ci_exec`` enables a single file @@ -77,20 +71,9 @@ specifically for running build steps on CI providers. It is cmake("..", "-G", "Ninja", "-DCMAKE_BUILD_TYPE=Release") ninja("-j", "2", "test") -.. end_long_desc - -.. begin_final_desc - -Please refer to the `full documentation `_ -for more information. - -.. end_final_desc - Installation ======================================================================================== -.. begin_install - ``ci_exec`` is `available on PyPI `_. It can be installed using your python package manager of choice: @@ -108,10 +91,7 @@ There is also a ``setup.py`` here, so you can also install it from source: $ pip install git+https://github.com/svenevs/ci_exec.git@master -.. end_install - License ======================================================================================== This software is licensed under the Apache 2.0 license. - diff --git a/ci_exec/__init__.py b/ci_exec/__init__.py index 2b7ea46..8c677d9 100644 --- a/ci_exec/__init__.py +++ b/ci_exec/__init__.py @@ -29,7 +29,7 @@ from .provider import Provider from .utils import cd, merge_kwargs, set_env, unset_env -__version__ = "0.1.2.dev" +__version__ = "0.1.2.dev.1" __all__ = [ # Core imports from ci_exec.colorize module. "Ansi", "Colors", "Styles", "colorize", "log_stage", diff --git a/docs/source/index.rst b/docs/source/index.rst index 712b305..efd4076 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -2,26 +2,13 @@ ci_exec ======================================================================================== .. contents:: - :local: :backlinks: none About ---------------------------------------------------------------------------------------- .. include:: ../../README.rst - :start-after: begin_brief_desc - :end-before: end_brief_desc - -.. include:: ../../README.rst - :start-after: begin_long_desc - :end-before: end_long_desc - -Installation ----------------------------------------------------------------------------------------- - -.. include:: ../../README.rst - :start-after: begin_install - :end-before: end_install + :start-after: end_badges Intended Audience ---------------------------------------------------------------------------------------- diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..cdb0230 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,27 @@ +[build-system] +requires = ["setuptools >= 40.6.0", "wheel"] +build-backend = "setuptools.build_meta" + +################################################################################ +[tool.coverage.run] +data_file = ".coverage" +include = [ + "ci_exec/**", + "tests/**", + "demos/**"] + +################################################################################ +[[tool.mypy.overrides]] +module = [ + "pytest", + "pygments", + "setuptools"] + +################################################################################ +[tool.pytest.ini_options] +cache_dir = "tests/.cache" +norecursedirs = [ + ".git/", + "docs/", + "ci_exec/"] +python_files = ["tests/**.py"] diff --git a/setup.cfg b/setup.cfg index 09021da..3abec8e 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,45 +1,46 @@ -[flake8] -max-line-length = 88 -exclude = - .git - .eggs - .tox -ignore = - # Missing blank line after last section (waste of space...) - D413, - # I document the class, not __init__ - D107, - # Lining up operators is less important than making it easy for users to understand. - W504 - -[tool:pytest] -cache_dir = tests/.cache -norecursedirs = - .git/ - docs/ - ci_exec/ -python_files = - tests/**.py +[metadata] +name = ci_exec +version = attr: ci_exec.__version__ +python_requires = >=3.6 +license = Apache v2.0 +author = Stephen McDowell +author_email = svenevs.pypi@gmail.com -[coverage:run] -data_file = .coverage -include = - ci_exec/** - tests/** - demos/** +description = + A wrapper package designed for running continuous integration (CI) build steps using + Python 3.6+. +long_description = file: README.rst +long_description_content_type = text/x-rst -[mypy-setuptools] -ignore_missing_imports = true +url = https://github.com/svenevs/ci_exec +project_urls = + Documentation = https://ci-exec.readthedocs.io/en/latest/ + Source = https://github.com/svenevs/ci_exec + Tracker = https://github.com/svenevs/ci_exec/issues +classifiers = + Development Status :: 3 - Alpha + Intended Audience :: Developers + Topic :: Software Development :: Build Tools + License :: OSI Approved :: Apache Software License + Programming Language :: Python :: 3.6 + Programming Language :: Python :: 3.7 + Programming Language :: Python :: 3.8 + Programming Language :: Python :: 3.9 -[mypy-pytest] -ignore_missing_imports = true -[mypy-pygments] -ignore_missing_imports = true +[options] +zip_safe = False +include_package_data = True +packages = find: -[mypy-youtube] -ignore_missing_imports = true +[options.package_data] +ci_exec = py.typed -# NOTE: see docs/requirements.txt, this will not be needed in future. -[mypy-sphinx.ext.autodoc] -ignore_missing_imports = true +[options.packages.find] +exclude = + demos + demos.* + docs + docs.* + tests + tests.* diff --git a/setup.py b/setup.py index 4b0cc52..bac24a4 100644 --- a/setup.py +++ b/setup.py @@ -1,93 +1,6 @@ -# noqa: D100 -import os -import sys +#!/usr/bin/env python -from setuptools import find_packages, setup +import setuptools - -if sys.version_info < (3, 6): - raise RuntimeError("ci_exec needs Python 3.6+") - -sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) -import ci_exec # noqa: E402, I100 - -# Extract the descriptions from README.rst. -try: - in_brief = False - brief = "" - in_long = False - in_final = False - long = "" - with open("README.rst") as readme: - for line in readme: - if line.startswith(".. begin_brief_desc"): - in_brief = True - continue - elif line.startswith(".. end_brief_desc"): - in_brief = False - continue - elif line.startswith(".. begin_long_desc"): - in_long = True - continue - elif line.startswith(".. end_long_desc"): - in_long = False - continue - elif line.startswith(".. begin_final_desc"): - in_final = True - continue - elif line.startswith(".. end_final_desc"): - in_final = False - continue - - if in_brief: - brief += line.replace("\n", " ") # so it is all on one line. - elif in_long: - long += line - elif in_final: - long += line - - if not brief: - raise RuntimeError("Internal error: could not extract brief description.") - if not long: - raise RuntimeError("Internal error: could not extract long description.") -except Exception as e: - raise RuntimeError(f"CRITICAL: {e}") - -brief_description = brief.rstrip() -long_description = long.rstrip() - -setup( - name="ci_exec", - version=ci_exec.__version__, - requires_python=">=3.6", - author="Stephen McDowell", - author_email="svenevs.pypi@gmail.com", - license="Apache v2.0", - description=brief_description, - long_description=long_description, - long_description_content_type="text/x-rst", - project_urls={ - "Documentation": "https://ci-exec.readthedocs.io/en/latest/", - "Source": "https://github.com/svenevs/ci_exec" - }, - url="https://github.com/svenevs/ci_exec", - packages=find_packages(exclude=[ - "demos", "demos.*", - "docs", "docs.*", - "tests", "tests.*", - ]), - package_data={"ci_exec": ["py.typed"]}, - include_package_data=True, - zip_safe=False, - python_requires=">=3.6", - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "Topic :: Software Development :: Build Tools", - "License :: OSI Approved :: Apache Software License", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Programming Language :: Python :: 3.8", - "Programming Language :: Python :: 3.9" - ] -) +if __name__ == "__main__": + setuptools.setup() diff --git a/tox.ini b/tox.ini index 8f6999b..e048d5c 100644 --- a/tox.ini +++ b/tox.ini @@ -2,6 +2,23 @@ # Default environments to run with vanilla `tox` envlist = py, lint +# See: https://flake8.pycqa.org/en/latest/user/configuration.html#project-configuration +# and: https://github.com/PyCQA/flake8/issues/234 +# TL;DR: keep in tox.ini until ? +[flake8] +max-line-length = 88 +exclude = + .git + .eggs + .tox +ignore = + # Missing blank line after last section (waste of space...) + D413, + # I document the class, not __init__ + D107, + # Lining up operators is less important than making it easy for users to understand. + W504 + [testenv] # Required to be able to send coverage reports from Travis to codecov passenv = PYTHONWARNINGS TOXENV CI TRAVIS TRAVIS_* @@ -68,7 +85,7 @@ setenv = CI_EXEC_DEMOS_COVERAGE = YES skip_install = true deps = - coverage + coverage[toml] commands = # Intended use case of this in CI is to do multiple passes, e.g.: #