Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Apr 25, 2020
2 parents 0215149 + bb96dc3 commit 94fcc97
Show file tree
Hide file tree
Showing 11 changed files with 162 additions and 43 deletions.
7 changes: 6 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
repos:
- repo: https://github.com/psf/black
rev: 19.3b0
rev: 19.10b0
hooks:
- id: black

- repo: https://github.com/asottile/blacken-docs
rev: v1.4.0
hooks:
- id: blacken-docs
13 changes: 2 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
dist: xenial
dist: bionic
language: python

python:
- 3.6
- &latest_py3 3.8

jobs:
fast_finish: true
include:
- stage: deploy
if: tag IS present
python: *latest_py3
before_script: skip
script: tox -e release

cache: pip

install:
- pip install tox tox-venv

before_script:
# Disable IPv6. Ref travis-ci/travis-ci#8361
# Enable IPv6. Ref travis-ci/travis-ci#8361
- if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
sudo sh -c 'echo 0 > /proc/sys/net/ipv6/conf/all/disable_ipv6';
fi
Expand Down
18 changes: 15 additions & 3 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
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.
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.
8 changes: 7 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
.. image:: https://img.shields.io/pypi/v/jaraco.itertools.svg
:target: https://pypi.org/project/jaraco.itertools
:target: `PyPI link`_

.. image:: https://img.shields.io/pypi/pyversions/jaraco.itertools.svg
:target: `PyPI link`_

.. _PyPI link: https://pypi.org/project/jaraco.itertools

.. image:: https://dev.azure.com/jaraco/jaraco.itertools/_apis/build/status/jaraco.jaraco.itertools?branchName=master
:target: https://dev.azure.com/jaraco/jaraco.itertools/_build/latest?definitionId=1&branchName=master

.. image:: https://img.shields.io/travis/jaraco/jaraco.itertools/master.svg
:target: https://travis-ci.org/jaraco/jaraco.itertools
Expand Down
80 changes: 80 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# 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)
displayName: 'publish to PyPI'
condition: contains(variables['Build.SourceBranch'], 'tags')
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[build-system]
requires = ["setuptools>=34.4", "wheel", "setuptools_scm>=1.15"]
requires = ["setuptools>=42", "wheel", "setuptools_scm[toml]>=3.4.1"]
build-backend = "setuptools.build_meta"

[tool.black]
skip-string-normalization = true

[tool.setuptools_scm]
2 changes: 2 additions & 0 deletions pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ norecursedirs=dist build .tox .eggs
addopts=--doctest-modules --flake8 --black --cov
doctest_optionflags=ALLOW_UNICODE ELLIPSIS ALLOW_BYTES
filterwarnings=
# https://github.com/pytest-dev/pytest/issues/6928
ignore:direct construction of .*Item has been deprecated:DeprecationWarning
8 changes: 3 additions & 5 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[bdist_wheel]
universal = 1

[metadata]
license_file = LICENSE
name = jaraco.itertools
Expand All @@ -14,6 +11,7 @@ classifiers =
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Programming Language :: Python :: 3
Programming Language :: Python :: 3 :: Only

[options]
packages = find:
Expand All @@ -22,15 +20,15 @@ python_requires = >=3.6
install_requires =
more_itertools>=4.0.0
inflect
setup_requires = setuptools_scm >= 1.15.0
setup_requires = setuptools_scm[toml] >= 3.4.1

[options.extras_require]
testing =
# upstream
pytest >= 3.5, !=3.7.3
pytest-checkdocs >= 1.2.3
pytest-flake8
pytest-black-multipy
pytest-black >= 0.3.7
pytest-cov

# local
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
import setuptools

if __name__ == "__main__":
setuptools.setup(use_scm_version=True)
setuptools.setup()
62 changes: 43 additions & 19 deletions skeleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

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
## 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.
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.

Expand Down Expand Up @@ -38,24 +38,24 @@ The `--allow-unrelated-histories` is necessary because the history from the skel

## 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.
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.

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
- 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 readthedocs and appveyor badges commented out
- 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)
- Use of [Black](https://black.readthedocs.io/en/stable/) for code formatting (disabled on unsupported Python 3.5 and earlier)

## 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).
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:

Expand Down Expand Up @@ -92,39 +92,63 @@ A pytest.ini is included to define common options around running tests. In parti

- 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.
- 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 a .flake8 file to correct some default behaviors:
Relies on a .flake8 file to correct some default behaviors:

- disable mutually incompatible rules W503 and W504
- support for black format
- support for Black format

## Continuous Integration

The project is pre-configured to run tests in [Travis-CI](https://travis-ci.org) (.travis.yml). Any new project must be enabled either through their web site or with the `travis enable` command.
The project is pre-configured to run tests through multiple CI providers.

### Azure Pipelines

[Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) are the preferred provider as they provide free, fast, multi-platform services. See azure-pipelines.yml for more details.

Features include:

- test against multiple Python versions
- run on Ubuntu Bionic

### Travis CI

[Travis CI](https://travis-ci.org) is configured through .travis.yml. Any new project must be enabled either through their web site or with the `travis enable` command.

Features include:
- test against Python 2 and 3
- run on Ubuntu Xenial
- test against Python 3
- run on Ubuntu Bionic
- correct for broken IPv6

Also provided is a minimal template for running under Appveyor (Windows).
### AppVeyor

A minimal template for running under AppVeyor (Windows) is provided.

### Continuous Deployments

In addition to running tests, an additional deploy 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 Travis as the TWINE_PASSWORD environment variable. After the Travis project is created, configure the token through the web UI or with a command like the following (bash syntax):
In addition to running tests, an additional deploy 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 Azure as the `Azure secrets` variable group. This variable group needs to be created only once per organization. For example:

```
TWINE_PASSWORD={token} travis env copy TWINE_PASSWORD
# create a resource group if none exists
az group create --name main --location eastus2
# create the vault (try different names until something works)
az keyvault create --name secrets007 --resource-group main
# create the secret
az keyvault secret set --vault-name secrets007 --name PyPI-token --value $token
```

Then, in the web UI for the project's Pipelines Library, create the `Azure secrets` variable group referencing the key vault name.

For more details, see [this blog entry](https://blog.jaraco.com/configuring-azure-pipelines-with-secets/).

## 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.
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

Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ requires =

[testenv]
deps =
setuptools>=31.0.1
pip_version = pip
commands =
pytest {posargs}
Expand Down

0 comments on commit 94fcc97

Please sign in to comment.