Commit 957b7a19 authored by Jason R. Coombs's avatar Jason R. Coombs Committed by GitHub

Merge pull request #2486 from pypa/feature/skeleton

Adopt jaraco/skeleton
parents 30b66d8d e52ace42
[run]
source=
pkg_resources
setuptools
omit=
*/_vendor/*
omit = .tox/*
[report]
show_missing = True
[flake8]
exclude=
.tox
setuptools/_vendor,
max-line-length = 88
exclude =
setuptools/_vendor
pkg_resources/_vendor
ignore =
# W503 violates spec https://github.com/PyCQA/pycodestyle/issues/513
W503
# W504 has issues https://github.com/OCA/maintainer-quality-tools/issues/545
W504
# Black creates whitespace before colon
E203
setuptools/site-patch.py F821
setuptools/py*compat.py F811
name: Automated Tests
on: [push, pull_request]
jobs:
test:
strategy:
matrix:
python: [3.6, 3.8, 3.9, pypy3]
platform: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.platform }}
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: |
python -m pip install tox
- name: Run tests
run: tox
release:
needs: test
if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: 3.9
- name: Install tox
run: |
python -m pip install tox
- name: Release
run: tox -e release
env:
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
name: >-
👷
Test suite
on:
push:
pull_request:
schedule:
- cron: 1 0 * * * # Run daily at 0:01 UTC
jobs:
tests:
name: >-
${{ matrix.python-version }}
/
${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
# max-parallel: 5
matrix:
python-version:
- 3.9
- 3.8
- pypy3
- 3.7
- 3.6
os:
- ubuntu-18.04
- ubuntu-16.04
- macOS-latest
# - windows-2019
# - windows-2016
include:
# Dev versions (deadsnakes)
- os: ubuntu-20.04
python-version: 3.9-dev
- os: ubuntu-20.04
python-version: 3.8-dev
env:
NETWORK_REQUIRED: 1
PYTHON_VERSION: ${{ matrix.python-version }}
TOX_PARALLEL_NO_SPINNER: 1
TOXENV: python
USE_DEADSNAKES: false
steps:
- uses: actions/checkout@master
- name: Set flag to use deadsnakes
if: >-
endsWith(env.PYTHON_VERSION, '-beta') ||
endsWith(env.PYTHON_VERSION, '-dev')
# FIXME: replace `set-env` with a newer alternative
# Refs:
# * github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/
env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: true
run: |
from __future__ import print_function
import os
python_version = '${{ env.PYTHON_VERSION }}'.replace('-beta', '')
with open(os.environ['GITHUB_ENV'], 'a') as env_file:
env_file.write('PYTHON_VERSION={ver}\n'.format(ver=python_version))
env_file.write('USE_DEADSNAKES=true\n')
shell: python
- name: Set up Python ${{ env.PYTHON_VERSION }} (deadsnakes)
uses: deadsnakes/action@v2.0.1
if: fromJSON(env.USE_DEADSNAKES) && true || false
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v2
if: >-
!fromJSON(env.USE_DEADSNAKES) && true || false
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Log Python version
run: >-
python --version
- name: Log Python location
run: >-
which python
- name: Log Python env
run: >-
python -m sysconfig
- name: Pip cache
uses: actions/cache@v2
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('setup.cfg') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
- name: Upgrade pip/setuptools/wheel
run: >-
python
-m pip install
--disable-pip-version-check
--upgrade
pip setuptools wheel
- name: Install tox
run: >-
python -m pip install --upgrade tox tox-venv
- name: Log installed dists
run: >-
python -m pip freeze --all
- name: Adjust TOXENV for PyPy
if: startsWith(env.PYTHON_VERSION, 'pypy')
run: >-
echo "TOXENV=${{ env.PYTHON_VERSION }}"
>>
"${GITHUB_ENV}"
- name: Log env vars
run: >-
env
- name: Verify that there's no cached Python modules in sources
if: >-
! startsWith(matrix.os, 'windows-')
run: >-
! grep pyc setuptools.egg-info/SOURCES.txt
- name: 'Initialize tox envs: ${{ matrix.env.TOXENV }}'
run: >-
python -m
tox
--parallel auto
--parallel-live
--notest
--skip-missing-interpreters false
- name: Test with tox
run: >-
python -m
tox
--parallel auto
--parallel-live
--
-vvvvv
repos:
- repo: https://github.com/psf/black
rev: stable
hooks:
- id: black
- repo: https://github.com/asottile/blacken-docs
rev: v1.8.0
hooks:
- id: blacken-docs
# Read the Docs configuration file
# https://docs.readthedocs.io/en/stable/config-file/v2.html
version: 2
python:
install:
- requirements: docs/requirements.txt
dist: xenial
language: python
jobs:
fast_finish: true
include:
- python: pypy3
- python: 3.6
- python: 3.7
- &latest_py3
python: 3.8
- <<: *latest_py3
env: LANG=C
- python: 3.8-dev
- python: 3.9-dev
- <<: *latest_py3
env: TOXENV=docs
- arch: ppc64le
python: pypy3
- arch: ppc64le
python: 3.6
- &latest_py3_ppc
arch: ppc64le
python: 3.8
- <<: *latest_py3_ppc
env: LANG=C
- arch: ppc64le
python: 3.9-dev
allow_failures:
# suppress failures due to pypa/setuptools#2000
- python: pypy3
- <<: *latest_py3
env: TOXENV=docs
cache: pip
before_install:
- python tools/ppc64le-patch.py
install:
# ensure we have recent pip/setuptools/wheel
- pip install --disable-pip-version-check --upgrade pip setuptools wheel
# need tox to get started
- pip install --upgrade tox tox-venv
# Output the env, to verify behavior
- pip freeze --all
- env
- "! grep pyc setuptools.egg-info/SOURCES.txt"
script:
- export NETWORK_REQUIRED=1
- tox
after_success:
- export TRAVIS_JOB_NAME="${TRAVIS_PYTHON_VERSION} (LANG=$LANG)" CODECOV_ENV=TRAVIS_JOB_NAME
- tox -e coverage,codecov
Copyright (C) 2016 Jason R Coombs <jaraco@jaraco.com>
Copyright Jason R. Coombs
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to
deal in the Software without restriction, including without limitation the
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
IN THE SOFTWARE.
......@@ -6,14 +6,13 @@
.. _PyPI link: https://pypi.org/project/setuptools
.. image:: https://dev.azure.com/jaraco/setuptools/_apis/build/status/pypa.setuptools?branchName=master
:target: https://dev.azure.com/jaraco/setuptools/_build/latest?definitionId=1&branchName=master
.. image:: https://github.com/jaraco/setuptools/workflows/Automated%20Tests/badge.svg
:target: https://github.com/jaraco/setuptools/actions?query=workflow%3A%22Automated+Tests%22
:alt: Automated Tests
.. image:: https://img.shields.io/travis/pypa/setuptools/master.svg?label=Linux%20CI&logo=travis&logoColor=white
:target: https://travis-ci.org/pypa/setuptools
.. image:: https://img.shields.io/appveyor/ci/pypa/setuptools/master.svg?label=Windows%20CI&logo=appveyor&logoColor=white
:target: https://ci.appveyor.com/project/pypa/setuptools/branch/master
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code style: Black
.. image:: https://img.shields.io/readthedocs/setuptools/latest.svg
:target: https://setuptools.readthedocs.io
......
clone_depth: 50
environment:
APPVEYOR: True
NETWORK_REQUIRED: True
CODECOV_ENV: APPVEYOR_JOB_NAME
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
APPVEYOR_JOB_NAME: "Python38-x64-vs2015"
PYTHON: "C:\\Python38-x64"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
APPVEYOR_JOB_NAME: "Python38-x64-vs2017"
PYTHON: "C:\\Python38-x64"
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
APPVEYOR_JOB_NAME: "Python38-x64-vs2019"
PYTHON: "C:\\Python38-x64"
- APPVEYOR_JOB_NAME: "python37-x64"
PYTHON: "C:\\Python37-x64"
- APPVEYOR_JOB_NAME: "python36-x64"
PYTHON: "C:\\Python36-x64"
install:
# symlink python from a directory with a space
- "mklink /d \"C:\\Program Files\\Python\" %PYTHON%"
- "SET PYTHON=\"C:\\Program Files\\Python\""
- "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
build: off
cache:
- '%LOCALAPPDATA%\pip\Cache'
test_script:
- python --version
- python -m pip install --disable-pip-version-check --upgrade pip setuptools wheel
- pip install --upgrade tox tox-venv virtualenv
- pip freeze --all
- tox -- --junit-xml=test-results.xml
after_test:
- tox -e coverage,codecov
on_finish:
- ps: |
$wc = New-Object 'System.Net.WebClient'
$wc.UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\test-results.xml))
version: '{build}'
# Create the project in Azure with:
# az devops project create --name $name --organization https://dev.azure.com/$org/ --visibility public
# then configure the pipelines (through web UI)
trigger:
branches:
include:
- '*'
tags:
include:
- '*'
pool:
vmImage: $(pool_vm_image)
variables:
- group: Azure secrets
- name: pool_vm_image
value: Ubuntu-18.04
stages:
- stage: Test
jobs:
- job: 'Test'
strategy:
matrix:
Bionic Python 3.6:
python.version: '3.6'
Bionic Python 3.8:
python.version: '3.8'
Windows:
python.version: '3.8'
pool_vm_image: vs2017-win2016
MacOS:
python.version: '3.8'
pool_vm_image: macos-10.15
maxParallel: 4
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '$(python.version)'
architecture: 'x64'
- script: python -m pip install tox
displayName: 'Install tox'
- script: |
tox -- --junit-xml=test-results.xml
displayName: 'run tests'
- task: PublishTestResults@2
inputs:
testResultsFiles: '**/test-results.xml'
testRunTitle: 'Python $(python.version)'
condition: succeededOrFailed()
- stage: Publish
dependsOn: Test
jobs:
- job: 'Publish'
steps:
- task: UsePythonVersion@0
inputs:
versionSpec: '3.8'
architecture: 'x64'
- script: python -m pip install tox
displayName: 'Install tox'
- script: |
tox -e release
env:
TWINE_PASSWORD: $(PyPI-token)
TIDELIFT_TOKEN: $(Tidelift-token)
GITHUB_TOKEN: $(Github-token)
displayName: 'publish to PyPI'
condition: contains(variables['Build.SourceBranch'], 'tags')
Project adopts jaraco/skeleton for shared package maintenance.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import subprocess
import sys
import os
# hack to run the bootstrap script so that jaraco.packaging.sphinx
# can invoke setup.py
'READTHEDOCS' in os.environ and subprocess.check_call(
[sys.executable, '-m', 'bootstrap'],
cwd=os.path.join(os.path.dirname(__file__), os.path.pardir),
)
# -- Project information -----------------------------------------------------
github_url = 'https://github.com'
github_sponsors_url = f'{github_url}/sponsors'
# -- General configuration --
extensions = [
'sphinx.ext.extlinks', # allows to create custom roles easily
'jaraco.packaging.sphinx',
'rst.linker',
]
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The master toctree document.
master_doc = 'index'
# List of directories, relative to source directory, that shouldn't be searched
# for source files.
exclude_trees = []
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# -- Options for extlinks extension ---------------------------------------
extlinks = {
'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323
}
# -- Options for HTML output --
# The theme to use for HTML and HTML Help pages. Major themes that come with
# Sphinx are currently 'default' and 'sphinxdoc'.
html_theme = 'nature'
# Add any paths that contain custom themes here, relative to this directory.
html_theme_path = ['_theme']
# If true, SmartyPants will be used to convert quotes and dashes to
# typographically correct entities.
html_use_smartypants = True
# Custom sidebar templates, maps document names to template names.
html_sidebars = {
'index': [
'relations.html', 'sourcelink.html', 'indexsidebar.html',
'searchbox.html']}
# If false, no module index is generated.
html_use_modindex = False
# If false, no index is generated.
html_use_index = False
extensions = ['sphinx.ext.autodoc', 'jaraco.packaging.sphinx', 'rst.linker']
# -- Options for LaTeX output --
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author,
# documentclass [howto/manual]).
latex_documents = [(
'index', 'Setuptools.tex', 'Setuptools Documentation',
'The fellowship of the packaging', 'manual',
)]
master_doc = "index"
link_files = {
'../CHANGES.rst': dict(
......@@ -148,10 +82,25 @@ link_files = {
}
# hack to run the bootstrap script so that jaraco.packaging.sphinx
# can invoke setup.py
'READTHEDOCS' in os.environ and subprocess.check_call(
[sys.executable, '-m', 'bootstrap'],
cwd=os.path.join(os.path.dirname(__file__), os.path.pardir),
)
# Add support for linking usernames
github_url = 'https://github.com'
github_sponsors_url = f'{github_url}/sponsors'
extlinks = {
'user': (f'{github_sponsors_url}/%s', '@'), # noqa: WPS323
}
extensions += ['sphinx.ext.extlinks']
# Be strict about any broken references:
nitpicky = True
# Ref: https://github.com/python-attrs/attrs/pull/571/files\
# #diff-85987f48f1258d9ee486e3191495582dR82
default_role = 'any'
[mypy]
ignore_missing_imports = True
......@@ -7,6 +7,25 @@ requires = [
build-backend = "setuptools.build_meta"
backend-path = ["."]
[tool.black]
skip-string-normalization = true
[tool.setuptools_scm]
# jaraco/skeleton#22
[tool.jaraco.pytest.plugins.black]
#addopts = "--black"
# jaraco/skeleton#22
[tool.jaraco.pytest.plugins.mypy]
#addopts = "--mypy"
[tool.jaraco.pytest.plugins.flake8]
addopts = "--flake8"
[tool.jaraco.pytest.plugins.cov]
addopts = "--cov"
[tool.towncrier]
package = "setuptools"
package_dir = "setuptools"
......@@ -41,9 +60,3 @@ backend-path = ["."]
directory = "misc"
name = "Misc"
showcontent = true
[tool.jaraco.pytest.plugins.flake8]
addopts = "--flake8"
[tool.jaraco.pytest.plugins.cov]
addopts = "--cov"
[pytest]
addopts=--doctest-modules --doctest-glob=pkg_resources/api_tests.txt -r sxX
norecursedirs=dist build .tox .eggs
doctest_optionflags=ELLIPSIS ALLOW_UNICODE
filterwarnings =
addopts=
--doctest-modules
--doctest-glob=pkg_resources/api_tests.txt
-r sxX
doctest_optionflags=ALLOW_UNICODE ELLIPSIS
# workaround for warning pytest-dev/pytest#6178
junit_family=xunit2
filterwarnings=
# https://github.com/pytest-dev/pytest/issues/6928
ignore:direct construction of .*Item has been deprecated:DeprecationWarning
# Fail on warnings
error
# https://github.com/pypa/setuptools/issues/1823
......
[egg_info]
tag_build = .post
tag_date = 1
[aliases]
clean_egg_info = egg_info -Db ''
release = clean_egg_info sdist bdist_wheel
source = register sdist binary
binary = bdist_egg upload --show-response
[upload]
repository = https://upload.pypi.org/legacy/
[sdist]
formats = zip
[metadata]
license_file = LICENSE
name = setuptools
version = 51.0.0
description = Easily download, build, install, upgrade, and uninstall Python packages
author = Python Packaging Authority
author_email = distutils-sig@python.org
long_description = file: README.rst
long_description_content_type = text/x-rst; charset=UTF-8
license_file = LICENSE
keywords = CPAN PyPI distutils eggs package management
description = Easily download, build, install, upgrade, and uninstall Python packages
long_description = file:README.rst
url = https://github.com/pypa/setuptools
project_urls =
Documentation = https://setuptools.readthedocs.io/
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Operating System :: OS Independent
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Topic :: Software Development :: Libraries :: Python Modules
Topic :: System :: Archiving :: Packaging
Topic :: System :: Systems Administration
Topic :: Utilities
keywords = CPAN PyPI distutils eggs package management
project_urls =
Documentation = https://setuptools.readthedocs.io/
[options]
zip_safe = True
python_requires = >=3.6
py_modules = easy_install
packages = find:
py_modules = easy_install
include_package_data = true
python_requires = >=3.6
install_requires =
[options.packages.find]
exclude = *.tests
[options.extras_require]
ssl =
wincertstore==0.2; sys_platform=='win32'
certs =
certifi==2016.9.26
testing =
# upstream
pytest >= 3.5, !=3.7.3
pytest-checkdocs >= 1.2.3
pytest-flake8
pytest-black >= 0.3.7; python_implementation != "PyPy"
pytest-cov
pytest-mypy; python_implementation != "PyPy"
# jaraco/skeleton#22
jaraco.test >= 3.2.0
tests =
# local
mock
pytest-flake8
flake8-2020
virtualenv>=13.0.0
pytest-virtualenv>=1.2.7
pytest>=3.7
wheel
coverage>=4.5.1
pytest-cov>=2.5.1
paver
pip>=19.1 # For proper file:// URLs support.
jaraco.envs
jaraco.test >= 3.1.1; python_version >= "3.6"
docs =
# Keep these in sync with docs/requirements.txt
# upstream
sphinx
jaraco.packaging>=6.1
rst.linker>=1.9
jaraco.packaging >= 6.1
rst.linker >= 1.9
# local
pygments-github-lexers==0.0.5
ssl =
wincertstore==0.2; sys_platform=='win32'
certs =
certifi==2016.9.26
[options.entry_points]
[egg_info]
tag_build = .post
tag_date = 1
[sdist]
formats = zip
#!/usr/bin/env python
"""
Distutils setup file, used to install or test 'setuptools'
"""
import os
import sys
......
# Overview
This project is merged with [skeleton](https://github.com/jaraco/skeleton). What is skeleton? It's the scaffolding of a Python project jaraco [introduced in his blog](https://blog.jaraco.com/a-project-skeleton-for-python-projects/). It seeks to provide a means to re-use techniques and inherit advances when managing projects for distribution.
## An SCM-Managed Approach
While maintaining dozens of projects in PyPI, jaraco derives best practices for project distribution and publishes them in the [skeleton repo](https://github.com/jaraco/skeleton), a Git repo capturing the evolution and culmination of these best practices.
It's intended to be used by a new or existing project to adopt these practices and honed and proven techniques. Adopters are encouraged to use the project directly and maintain a small deviation from the technique, make their own fork for more substantial changes unique to their environment or preferences, or simply adopt the skeleton once and abandon it thereafter.
The primary advantage to using an SCM for maintaining these techniques is that those tools help facilitate the merge between the template and its adopting projects.
Another advantage to using an SCM-managed approach is that tools like GitHub recognize that a change in the skeleton is the _same change_ across all projects that merge with that skeleton. Without the ancestry, with a traditional copy/paste approach, a [commit like this](https://github.com/jaraco/skeleton/commit/12eed1326e1bc26ce256e7b3f8cd8d3a5beab2d5) would produce notifications in the upstream project issue for each and every application, but because it's centralized, GitHub provides just the one notification when the change is added to the skeleton.
# Usage
## new projects
To use skeleton for a new project, simply pull the skeleton into a new project:
```
$ git init my-new-project
$ cd my-new-project
$ git pull gh://jaraco/skeleton
```
Now customize the project to suit your individual project needs.
## existing projects
If you have an existing project, you can still incorporate the skeleton by merging it into the codebase.
```
$ git merge skeleton --allow-unrelated-histories
```
The `--allow-unrelated-histories` is necessary because the history from the skeleton was previously unrelated to the existing codebase. Resolve any merge conflicts and commit to the master, and now the project is based on the shared skeleton.
## Updating
Whenever a change is needed or desired for the general technique for packaging, it can be made in the skeleton project and then merged into each of the derived projects as needed, recommended before each release. As a result, features and best practices for packaging are centrally maintained and readily trickle into a whole suite of packages. This technique lowers the amount of tedious work necessary to create or maintain a project, and coupled with other techniques like continuous integration and deployment, lowers the cost of creating and maintaining refined Python projects to just a few, familiar Git operations.
For example, here's a session of the [path project](https://pypi.org/project/path) pulling non-conflicting changes from the skeleton:
<img src="https://raw.githubusercontent.com/jaraco/skeleton/gh-pages/docs/refresh.svg">
Thereafter, the target project can make whatever customizations it deems relevant to the scaffolding. The project may even at some point decide that the divergence is too great to merit renewed merging with the original skeleton. This approach applies maximal guidance while creating minimal constraints.
# Features
The features/techniques employed by the skeleton include:
- PEP 517/518-based build relying on Setuptools as the build tool
- Setuptools declarative configuration using setup.cfg
- tox for running tests
- A README.rst as reStructuredText with some popular badges, but with Read the Docs and AppVeyor badges commented out
- A CHANGES.rst file intended for publishing release notes about the project
- Use of [Black](https://black.readthedocs.io/en/stable/) for code formatting (disabled on unsupported Python 3.5 and earlier)
- Integrated type checking through [mypy](https://github.com/python/mypy/).
## Packaging Conventions
A pyproject.toml is included to enable PEP 517 and PEP 518 compatibility and declares the requirements necessary to build the project on Setuptools (a minimum version compatible with setup.cfg declarative config).
The setup.cfg file implements the following features:
- Assumes universal wheel for release
- Advertises the project's LICENSE file (MIT by default)
- Reads the README.rst file into the long description
- Some common Trove classifiers
- Includes all packages discovered in the repo
- Data files in the package are also included (not just Python files)
- Declares the required Python versions
- Declares install requirements (empty by default)
- Declares setup requirements for legacy environments
- Supplies two 'extras':
- testing: requirements for running tests
- docs: requirements for building docs
- these extras split the declaration into "upstream" (requirements as declared by the skeleton) and "local" (those specific to the local project); these markers help avoid merge conflicts
- Placeholder for defining entry points
Additionally, the setup.py file declares `use_scm_version` which relies on [setuptools_scm](https://pypi.org/project/setuptools_scm) to do two things:
- derive the project version from SCM tags
- ensure that all files committed to the repo are automatically included in releases
## Running Tests
The skeleton assumes the developer has [tox](https://pypi.org/project/tox) installed. The developer is expected to run `tox` to run tests on the current Python version using [pytest](https://pypi.org/project/pytest).
Other environments (invoked with `tox -e {name}`) supplied include:
- a `docs` environment to build the documentation
- a `release` environment to publish the package to PyPI
A pytest.ini is included to define common options around running tests. In particular:
- rely on default test discovery in the current directory
- avoid recursing into common directories not containing tests
- run doctests on modules and invoke Flake8 tests
- in doctests, allow Unicode literals and regular literals to match, allowing for doctests to run on Python 2 and 3. Also enable ELLIPSES, a default that would be undone by supplying the prior option.
- filters out known warnings caused by libraries/functionality included by the skeleton
Relies on a .flake8 file to correct some default behaviors:
- disable mutually incompatible rules W503 and W504
- support for Black format
## Continuous Integration
The project is pre-configured to run Continuous Integration tests.
### Github Actions
[Github Actions](https://docs.github.com/en/free-pro-team@latest/actions) are the preferred provider as they provide free, fast, multi-platform services with straightforward configuration. Configured in `.github/workflows`.
Features include:
- test against multiple Python versions
- run on late (and updated) platform versions
- automated releases of tagged commits
### Continuous Deployments
In addition to running tests, an additional publish stage is configured to automatically release tagged commits to PyPI using [API tokens](https://pypi.org/help/#apitoken). The release process expects an authorized token to be configured with each Github project (or org) `PYPI_TOKEN` [secret](https://docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets). Example:
```
pip-run -q jaraco.develop -- -m jaraco.develop.add-github-secrets
```
## Building Documentation
Documentation is automatically built by [Read the Docs](https://readthedocs.org) when the project is registered with it, by way of the .readthedocs.yml file. To test the docs build manually, a tox env may be invoked as `tox -e docs`. Both techniques rely on the dependencies declared in `setup.cfg/options.extras_require.docs`.
In addition to building the Sphinx docs scaffolded in `docs/`, the docs build a `history.html` file that first injects release dates and hyperlinks into the CHANGES.rst before incorporating it as history in the docs.
## Cutting releases
By default, tagged commits are released through the continuous integration deploy stage.
Releases may also be cut manually by invoking the tox environment `release` with the PyPI token set as the TWINE_PASSWORD:
```
TWINE_PASSWORD={token} tox -e release
```
# To run Tox against all supported Python interpreters, you can set:
#
# export TOXENV='py3{5,6,7,8},pypy,pypy3'
[tox]
envlist=python
envlist = python
minversion = 3.2
requires =
tox-pip-version >= 0.0.6
[helpers]
# Custom pip behavior
pip = python {toxinidir}/tools/tox_pip.py
# https://github.com/jaraco/skeleton/issues/6
tox_pip_extensions_ext_venv_update = true
toxworkdir={env:TOX_WORK_DIR:.tox}
[testenv]
pip_version = pip
deps =
commands =
pytest {posargs}
usedevelop = True
extras = testing
install_command = {[helpers]pip} install {opts} {packages}
list_dependencies_command = {[helpers]pip} freeze --all
setenv =
COVERAGE_FILE={toxworkdir}/.coverage.{envname}
# TODO: The passed environment variables came from copying other tox.ini files
# These should probably be individually annotated to explain what needs them.
passenv=APPDATA HOMEDRIVE HOMEPATH windir Program* CommonProgram* VS* APPVEYOR APPVEYOR_* CI CODECOV_* TRAVIS TRAVIS_* NETWORK_REQUIRED
commands = pytest {posargs}
usedevelop=True
extras =
tests
passenv =
windir # required for test_pkg_resources
[testenv:coverage]
description=Combine coverage data and create report
......@@ -49,16 +40,7 @@ extras =
testing
changedir = docs
commands =
{envpython} -m sphinx \
-j auto \
-b html \
--color \
-a \
-n \
-W \
-d "{temp_dir}/.doctrees" \
. \
"{toxinidir}/build/html"
python -m sphinx -W . {toxinidir}/build/html
[testenv:finalize]
skip_install = True
......@@ -72,21 +54,22 @@ commands =
[testenv:release]
skip_install = True
deps =
wheel
pep517>=0.5
twine[keyring]>=1.13
path
jaraco.develop>=7.1
jaraco.tidelift
passenv =
TWINE_PASSWORD
GITHUB_TOKEN
TIDELIFT_TOKEN
setenv =
TWINE_USERNAME = {env:TWINE_USERNAME:__token__}
commands =
python -m bootstrap
python -c "import path; path.Path('dist').rmtree_p()"
python setup.py release
python -m pep517.build .
python -m twine upload dist/*
python -m jaraco.develop.create-github-release
python -m jaraco.tidelift.publish-release-notes
[helpers]
# Custom pip behavior
pip = python {toxinidir}/tools/tox_pip.py
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment