Skip to content

Commit

Permalink
[NEW] Modern Build Backend, as in PEP 517
Browse files Browse the repository at this point in the history
  • Loading branch information
boromir674 committed May 24, 2022
2 parents fd307d9 + 0bfe3c6 commit 223e65b
Show file tree
Hide file tree
Showing 20 changed files with 549 additions and 211 deletions.
13 changes: 6 additions & 7 deletions .github/workflows/generate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,26 +83,25 @@ jobs:
run: |
cd cloned/biskotaki
chmod +x ./scripts/parse_version.py
echo "BISKOTAKI_VERSION=$(scripts/parse_version.py)" >> $GITHUB_ENV
echo "PKG_VERSION=$(scripts/parse_version.py)" >> $GITHUB_ENV
- name: Generate Biskotaki from Template
run: |
pip install --user -e .
echo " version: \"${{ env.BISKOTAKI_VERSION }}\"" >> .github/biskotaki.yaml
echo " version: \"${{ env.PKG_VERSION }}\"" >> .github/biskotaki.yaml
generate-python -o gen --config-file ./.github/biskotaki.yaml --no-input
- name: Test against multiple 'installation' scenarios
run: |
cd gen/biskotaki
tox -e "py38{, -path, -sdist, -wheel, -dev}"
env:
PKG_VERSION: ${{ env.BISKOTAKI_VERSION }}
tox -e "py38{-path, -sdist, -wheel, -dev}"
- name: Test Operations such as 'build process' and 'linting'
run: |
cd gen/biskotaki
tox -e check
tox -e build
tox -e lint
tox -e type
tox -e build
tox -e check
tox -e graphs
- name: Push to dedicated branch in biskotaki repo
Expand Down
51 changes: 40 additions & 11 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ jobs:
strategy:
matrix:
platform: [ubuntu-latest, macos-latest]
# platform: [macos-latest]
# python-version: ["3.6"]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
Expand All @@ -40,9 +42,6 @@ jobs:
- name: Do Type Checking
run: tox -e type -vv -s false

- name: Check for compliance with Python Best Practices
run: tox -e check -vv -s false

- name: Specify current package version to assist build tool
run: echo "PKG_VERSION=$(python scripts/parse_version.py)" >> $GITHUB_ENV

Expand All @@ -51,22 +50,52 @@ jobs:
env:
PLATFORM: ${{ matrix.platform }}

- name: Install coverage.py
run: python -m pip install coverage
- name: Check for compliance with Python Best Practices
run: |
DIST_DIR=dist
echo "DIST_DIR=dist" >> $GITHUB_ENV
mkdir "$DIST_DIR"
mv ".tox/${DIST_DIR}/cookiecutter_python-${PKG_VERSION}.tar.gz" "${DIST_DIR}"
mv ".tox/${DIST_DIR}/cookiecutter_python-${PKG_VERSION}-py3-none-any.whl" "${DIST_DIR}"
tox -e check -vv -s false
- name: Aggregate Test Suite Coverage Data
- name: Upload Source & Wheel distributions as Artefacts
uses: actions/upload-artifact@v2
with:
# name: dist-${{ env.OS }}-${{ env.PYTHON }} # TODO enable this
name: dist-${{ matrix.platform }}-${{ matrix.python-version }}
path: ${{ env.DIST_DIR }}
if-no-files-found: error

- name: Aggregate Test Coverage Data
run: |
python -m pip install coverage
tox -e coverage --sitepackages -vv -s false
# TODO Delegate uploading to codecov to a another Job
- name: Upload coverage to Codecov
- name: Upload Coverage Data as Artefacts
uses: actions/upload-artifact@v2
with:
name: coverage-xml-data
path: ./.tox/coverage.xml
if-no-files-found: error

host_coverage_results:
needs: test_suite
runs-on: ubuntu-latest
steps:
- name: Download Coverage Data
uses: actions/download-artifact@v2
with:
name: coverage-xml-data
- name: Send Coverage Data to Codecov
uses: codecov/codecov-action@v2
with:
directory: ./.tox/
directory: .
env_vars: OS,PYTHON
fail_ci_if_error: true
files: ./.tox/coverage.xml
files: coverage.xml
flags: unittests
name: codecov-umbrella
verbose: true
Expand Down
30 changes: 30 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,36 @@
Changelog
=========

1.2.0 (2022-05-24)
==================

Changes
^^^^^^^

feature
"""""""
- migrate to poetry from setuptools as 'build-backend'

fix
"""
- add rule in MANIFEST to match tox.ini similar to *.md, etc non-python files
- replace hardcoded values with templated variables
test
""""
- sanity check to double check that 'tox.ini' gets put in generated dir

documentation
"""""""""""""
- rewrite module docstring

ci
""
- use checkout@v3 instead of @v1
- upload sdist & wheel as artefacts
- separate codecov data exchange into dedicated job


1.1.1 (2022-05-17)
==================

Expand Down
23 changes: 0 additions & 23 deletions MANIFEST.in

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,9 @@ For more complex use cases, you can modify the Template and also leverage all of

.. Github Releases & Tags
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.1.1/master?color=blue&logo=github
.. |commits_since_specific_tag_on_master| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/v1.2.0/master?color=blue&logo=github
:alt: GitHub commits since tagged version (branch)
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.1.1..master
:target: https://github.com/boromir674/cookiecutter-python-package/compare/v1.2.0..master

.. |commits_since_latest_github_release| image:: https://img.shields.io/github/commits-since/boromir674/cookiecutter-python-package/latest?color=blue&logo=semver&sort=semver
:alt: GitHub commits since latest release (by SemVer)
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
author = 'Konstantinos Lampridis'

# The full version, including alpha/beta/rc tags
release = '0.9.0'
release = '1.2.0'

# -- General configuration ---------------------------------------------------

Expand Down
172 changes: 169 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,181 @@
# BUILD

[build-system]
requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

# TODO switch setuptools build backend to something like 'poetry' or 'build'
# Poetry

# Information required for building (sdist/wheel)
## Also renders on pypi as 'subtitle'
[tool.poetry]
name = "cookiecutter_python"
version = "1.2.0"
description = "Yet another modern Python Package (pypi) with emphasis in CI/CD and automation."
authors = ["Konstantinos Lampridis <[email protected]>"]
maintainers = ["Konstantinos Lampridis <[email protected]>"]
license = "AGPL-3.0-only"
readme = "README.rst"

homepage = "https://github.com/boromir674/cookiecutter-python-package"
repository = "https://github.com/boromir674/cookiecutter-python-package"
documentation = "https://python-package-generator.readthedocs.io/"

keywords = [
"python package generator",
"python package template",
"cookiecutter",
"python package",
"automation"
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: GNU Affero General Public License v3",
"Natural Language :: English",
"Operating System :: Unix",
"Operating System :: POSIX :: Linux",
"Operating System :: MacOS",
"Programming Language :: Python",
"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",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: System :: Software Distribution",
"Typing :: Typed"
]

packages = [
{ include = "cookiecutter_python", from = "src" },
]

include = [
{ path = "tests", format = "sdist" },
{ path = "docs/**/*.rst", format = "sdist" },
{ path = "docs/conf.py", format = "sdist" },
{ path = "src/**/*.typed", format = "sdist" },
{ path = "src/stubs/*.pyi", format = "sdist" },
"pyproject.toml",
"LICENSE",
"README.rst",
"CONTRIBUTING.md",
"CHANGELOG.rst",
]

exclude = [
"docs/*",
"requirements/*",
"scripts/*.py",
"tox.ini",
".bettercodehub.yml",
".circleci/config.yml",
".coveragerc",
".DS_Store",
".gitignore",
".prospector.yml",
".pylintrc",
".readthedocs.yml",
".scrutinizer.yml",
".travis.yml"
]


[tool.poetry.scripts]
generate-python = 'cookiecutter_python.__main__:main'


[tool.poetry.dependencies]
python = "^3.6"
click = "^8"
cookiecutter = "^1.7.3"
software-patterns = "^1.2.1"
requests-futures = "^1.0.0"


# A list of all of the optional dependencies, some of which are included in the
# below `extras`. They can be opted into by apps.

# Test: packages imported in test code and packages required for the "test runner"
pytest = { version = ">= 6.2.4", optional = true }
pytest-click = { version = "~= 1.1.0", optional = true }
pytest-cov = { version = ">= 2.12", optional = true }
pytest-explicit = { version = "~= 1.0.1", optional = true }
pytest-xdist = { version = ">= 1.34", optional = true }

# Docs: development and build dependencies
sphinx = { version = "~= 4.0", optional = true }
sphinx-autodoc-typehints = { version = ">= 1.10", optional = true }
sphinx-rtd-theme = { version = "== 0.5.0", optional = true }
sphinxcontrib-spelling = { version = "~= 7.3.3", optional = true }

# Type Checking: packages required for the type check (ie mypy) to pass
mypy = { version = "~= 0.950", optional = true }
types-requests = { version = "~= 2.27.26", optional = true }

[tool.poetry.extras]
test = [
"pytest",
"pytest-click",
"pytest-cov",
"pytest-explicit",
"pytest-xdist",
]
docs = [
"sphinx",
"sphinx-autodoc-typehints",
"sphinx-rtd-theme",
"sphinxcontrib-spelling",
]
typing = [
"mypy",
"types-requests",
"pytest",
"pytest-click",
]


# PyPi url links, that appear in 'Project Links' section
[tool.poetry.urls]
"Bug Tracker" = "https://github.com/boromir674/cookiecutter-python-package/issues"
"CI: Github Actions" = "https://github.com/boromir674/cookiecutter-python-package/actions"
"Documentation" = "https://python-package-generator.readthedocs.io/"
"Source Code" = "https://github.com/boromir674/cookiecutter-python-package"
# TODO Improve: add changelog in Docs and use that link below
# https://cookiecutter-python-package.readthedocs.io/en/stable/changelog.html
"Changelog" = "https://github.com/boromir674/cookiecutter-python-package/blob/master/CHANGELOG.rst"
"Code of Conduct" = "https://github.com/boromir674/cookiecutter-python-package/blob/master/CONTRIBUTING.rst"
# Mailing lists =



# TOOLS

## Pytest & Plugins

[tool.pytest.ini_options]
minversion = "6.2"
addopts = "--strict-markers"
markers = [
"slow: Marks a slow test",
"integration: Tests applicable to a newly Generated Project, running with tox",
"network_bound: Require internet connection",
]
testpaths = [
"tests",
]
explicit-only = [
"integration",
"network_bound",
]


## Black formatting/linting

[tool.black]
line-length = 95
include = '\.pyi?$'
Expand Down
Loading

0 comments on commit 223e65b

Please sign in to comment.