Skip to content

Commit 3684c4d

Browse files
committed
2 parents 1bab564 + 4310c97 commit 3684c4d

9 files changed

Lines changed: 219 additions & 111 deletions

File tree

.travis.yml

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@ jobs:
1313
- stage: deploy
1414
if: tag IS present
1515
python: *latest_py3
16-
install: skip
17-
script: skip
18-
deploy:
19-
provider: pypi
20-
on:
21-
tags: true
22-
all_branches: true
23-
user: jaraco
24-
password:
25-
secure: fggUs33qP6DB+j/q7KGScfohgGq7OwsW5BMW6ZZvSlq+9pnNDZxSVrfCw0wb9vdq/Hb9nH4Of+wDoyh+Ul6GN28GRX7qj1HTjbc65nhRp9aA1Ib9Y3KJwGR8k5gPJZmx/zKP0r7COSXsOdXDkVSJ/UjCfuKhcsSHpi0lAYG6BSA=
26-
distributions: dists
27-
skip_cleanup: true
16+
before_script: skip
17+
env:
18+
- TWINE_USERNAME=jaraco
19+
# TWINE_PASSWORD
20+
- secure: Zd2236tCf+i7SYq50DAutS8EnQDWDFLRGnBjOi6CAJ1nblca07Ca2kpo3i2xvpktu1yrb0rFY9vnz9rMdwRavCz6deNcAxpM86m2sXepuz+fs4CIrDG5OepBy2LW/hHEafUObsoWeC4Ku8yXte7IUnmXBsplpTpjAybztNJ+C54=
21+
- TOX_TESTENV_PASSENV="TWINE_USERNAME TWINE_PASSWORD"
22+
script: tox -e release
2823

2924
cache: pip
3025

CHANGES.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ name, ``path.Path`` as introduced in 6.2.
234234
7.6
235235
---
236236

237-
- Pull Request #100: Add ``merge_tree`` method for merging
237+
- #100: Add ``merge_tree`` method for merging
238238
two existing directory trees.
239239
- Uses `setuptools_scm <https://github.org/pypa/setuptools_scm>`_
240240
for version management.

docs/conf.py

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,34 @@
22
# -*- coding: utf-8 -*-
33

44
extensions = [
5-
'sphinx.ext.autodoc',
6-
'jaraco.packaging.sphinx',
7-
'rst.linker',
8-
'sphinx.ext.intersphinx',
5+
"sphinx.ext.autodoc",
6+
"jaraco.packaging.sphinx",
7+
"rst.linker",
8+
"sphinx.ext.intersphinx",
99
]
1010

11-
pygments_style = 'sphinx'
12-
html_theme = 'alabaster'
13-
html_static_path = []
14-
htmlhelp_basename = 'pathpydoc'
15-
templates_path = ['_templates']
16-
exclude_patterns = ['_build']
17-
source_suffix = '.rst'
18-
master_doc = 'index'
11+
pygments_style = "sphinx"
12+
html_theme = "alabaster"
13+
master_doc = "index"
1914

2015
intersphinx_mapping = {'python': ('http://docs.python.org/', None)}
2116

2217
link_files = {
23-
'../CHANGES.rst': dict(
24-
using=dict(
25-
GH='https://github.com',
26-
),
18+
"../CHANGES.rst": dict(
19+
using=dict(GH="https://github.com"),
2720
replace=[
2821
dict(
29-
pattern=r'(Issue #|\B#)(?P<issue>\d+)',
30-
url='{package_url}/issues/{issue}',
22+
pattern=r"(Issue #|\B#)(?P<issue>\d+)",
23+
url="{package_url}/issues/{issue}",
3124
),
3225
dict(
33-
pattern=r"Pull Request ?#(?P<pull_request>\d+)",
34-
url='{package_url}/pull/{pull_request}',
26+
pattern=r"^(?m)((?P<scm_version>v?\d+(\.\d+){1,2}))\n[-=]+\n",
27+
with_scm="{text}\n{rev[timestamp]:%d %b %Y}\n",
3528
),
3629
dict(
37-
pattern=r'^(?m)((?P<scm_version>v?\d+(\.\d+){1,2}))\n[-=]+\n',
38-
with_scm='{text}\n{rev[timestamp]:%d %b %Y}\n',
39-
),
40-
dict(
41-
pattern=r'PEP[- ](?P<pep_number>\d+)',
42-
url='https://www.python.org/dev/peps/pep-{pep_number:0>4}/',
30+
pattern=r"PEP[- ](?P<pep_number>\d+)",
31+
url="https://www.python.org/dev/peps/pep-{pep_number:0>4}/",
4332
),
4433
],
45-
),
34+
)
4635
}

pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
[build-system]
2-
requires = ["setuptools>=30.3", "wheel", "setuptools_scm>=1.15"]
2+
requires = ["setuptools>=34.4", "wheel", "setuptools_scm>=1.15"]
3+
build-backend = "setuptools.build_meta"

pytest.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@ addopts=--doctest-modules --flake8
44
doctest_optionflags=ALLOW_UNICODE ELLIPSIS
55
filterwarnings=
66
ignore:Possible nested set::pycodestyle:113
7+
ignore:Using or importing the ABCs::flake8:410
8+
# workaround for https://sourceforge.net/p/docutils/bugs/348/
9+
ignore:'U' mode is deprecated::docutils.io
10+
# workaround for https://gitlab.com/pycqa/flake8/issues/275
11+
ignore:You passed a bytestring as `filenames`.::flake8

setup.cfg

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,54 @@
1-
[aliases]
2-
dists = clean --all sdist bdist_wheel
3-
41
[bdist_wheel]
52
universal = 1
63

74
[metadata]
85
license_file = LICENSE
6+
name = path.py
7+
author = Jason Orendorff
8+
author_email[email protected]
9+
maintainer = Jason R. Coombs
10+
maintainer_email = [email protected]
11+
description = A module wrapper for os.path
912
long_description = file:README.rst
13+
url = https://github.com/jaraco/path.py
14+
classifiers =
15+
Development Status :: 5 - Production/Stable
16+
Intended Audience :: Developers
17+
License :: OSI Approved :: MIT License
18+
Programming Language :: Python :: 2.7
19+
Programming Language :: Python :: 3
20+
Operating System :: OS Independent
21+
Topic :: Software Development :: Libraries :: Python Modules
22+
23+
[options]
24+
pymodules =
25+
path
26+
python_requires = >=2.7,!=3.1,!=3.2,!=3.3
27+
install_requires =
28+
importlib_metadata>=0.5
29+
backports.os; python_version=="2.7" and sys_platform=="linux2"
30+
setup_requires = setuptools_scm >= 1.15.0
31+
32+
[options.extras_require]
33+
testing =
34+
# upstream
35+
pytest >= 3.5, !=3.7.3
36+
pytest-checkdocs
37+
pytest-flake8
38+
39+
# local
40+
appdirs
41+
packaging
42+
43+
# required for checkdocs on README.rst
44+
pygments
45+
46+
docs =
47+
# upstream
48+
sphinx
49+
jaraco.packaging >= 3.2
50+
rst.linker >= 1.9
51+
52+
# local
53+
54+
[options.entry_points]

setup.py

Lines changed: 2 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,6 @@
11
#!/usr/bin/env python
22

3-
# Project skeleton maintained at https://github.com/jaraco/skeleton
4-
53
import setuptools
64

7-
name = 'path.py'
8-
description = 'A module wrapper for os.path'
9-
nspkg_technique = 'native'
10-
"""
11-
Does this package use "native" namespace packages or
12-
pkg_resources "managed" namespace packages?
13-
"""
14-
15-
params = dict(
16-
name=name,
17-
use_scm_version=True,
18-
author="Jason Orendorff",
19-
author_email="[email protected]",
20-
maintainer="Jason R. Coombs",
21-
maintainer_email="[email protected]",
22-
description=description or name,
23-
url="https://github.com/jaraco/" + name,
24-
py_modules=['path', 'test_path'],
25-
python_requires='>=2.7,!=3.1,!=3.2,!=3.3',
26-
install_requires=[
27-
'importlib_metadata>=0.5',
28-
'backports.os; python_version=="2.7" and sys_platform=="linux2"',
29-
],
30-
extras_require={
31-
'testing': [
32-
# upstream
33-
'pytest>=3.5,!=3.7.3',
34-
'pytest-sugar>=0.9.1',
35-
'collective.checkdocs',
36-
'pytest-flake8',
37-
38-
# local
39-
'appdirs',
40-
'packaging',
41-
42-
# required for checkdocs on README.rst
43-
'pygments',
44-
],
45-
'docs': [
46-
# upstream
47-
'sphinx',
48-
'jaraco.packaging>=3.2',
49-
'rst.linker>=1.9',
50-
51-
# local
52-
],
53-
},
54-
setup_requires=[
55-
'setuptools_scm>=1.15.0',
56-
],
57-
classifiers=[
58-
"Development Status :: 5 - Production/Stable",
59-
"Intended Audience :: Developers",
60-
"License :: OSI Approved :: MIT License",
61-
"Operating System :: OS Independent",
62-
"Programming Language :: Python :: 2.7",
63-
"Programming Language :: Python :: 3",
64-
"Topic :: Software Development :: Libraries :: Python Modules",
65-
],
66-
entry_points={
67-
},
68-
)
69-
if __name__ == '__main__':
70-
setuptools.setup(**params)
5+
if __name__ == "__main__":
6+
setuptools.setup(use_scm_version=True)

skeleton.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Overview
2+
3+
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.
4+
5+
## An SCM Managed Approach
6+
7+
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.
8+
9+
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.
10+
11+
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.
12+
13+
# Usage
14+
15+
## new projects
16+
17+
To use skeleton for a new project, simply pull the skeleton into a new project:
18+
19+
```
20+
$ git init my-new-project
21+
$ cd my-new-project
22+
$ git pull gh://jaraco/skeleton
23+
```
24+
25+
Now customize the project to suit your individual project needs.
26+
27+
## existing projects
28+
29+
If you have an existing project, you can still incorporate the skeleton by merging it into the codebase.
30+
31+
```
32+
$ git merge skeleton --allow-unrelated-histories
33+
```
34+
35+
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.
36+
37+
## Updating
38+
39+
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.
40+
41+
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.
42+
43+
# Features
44+
45+
The features/techniques employed by the skeleton include:
46+
47+
- PEP 517/518 based build relying on setuptools as the build tool
48+
- setuptools declarative configuration using setup.cfg
49+
- tox for running tests
50+
- A README.rst as reStructuredText with some popular badges, but with readthedocs and appveyor badges commented out
51+
- A CHANGES.rst file intended for publishing release notes about the project.
52+
53+
## Packaging Conventions
54+
55+
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).
56+
57+
The setup.cfg file implements the following features:
58+
59+
- Assumes universal wheel for release
60+
- Advertises the project's LICENSE file (MIT by default)
61+
- Reads the README.rst file into the long description
62+
- Some common Trove classifiers
63+
- Includes all packages discovered in the repo
64+
- Data files in the package are also included (not just Python files)
65+
- Declares the required Python versions
66+
- Declares install requirements (empty by default)
67+
- Declares setup requirements for legacy environments
68+
- Supplies two 'extras':
69+
- testing: requirements for running tests
70+
- docs: requirements for building docs
71+
- 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
72+
- Placeholder for defining entry points
73+
74+
Additionally, the setup.py file declares `use_scm_version` which relies on [setuptools_scm](https://pypi.org/project/setuptools_scm) to do two things:
75+
76+
- derive the project version from SCM tags
77+
- ensure that all files committed to the repo are automatically included in releases
78+
79+
## Running Tests
80+
81+
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).
82+
83+
Other environments (invoked with `tox -e {name}`) supplied include:
84+
85+
- a `build-docs` environment to build the documentation
86+
- a `release` environment to publish the package to PyPI
87+
88+
A pytest.ini is included to define common options around running tests. In particular:
89+
90+
- rely on default test discovery in the current directory
91+
- avoid recursing into common directories not containing tests
92+
- run doctests on modules and invoke flake8 tests
93+
- 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.
94+
- filters out known warnings caused by libraries/functionality included by the skeleton
95+
96+
Relies a .flake8 file to correct some default behaviors:
97+
98+
- allow tabs for indentation (legacy for jaraco projects)
99+
- disable mutually incompatible rules W503 and W504.
100+
101+
## Continuous Integration
102+
103+
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. In addition to running tests, an additional deploy stage is configured to automatically release tagged commits. The username and password for PyPI must be configured for each project using the `travis` command and only after the travis project is created. As releases are cut with [twine](https://pypi.org/project/twine), the two values are supplied through the `TWINE_USERNAME` and `TWINE_PASSWORD`. To configure the latter as a secret, run the following command:
104+
105+
```
106+
echo "TWINE_PASSWORD={password}" | travis encrypt
107+
```
108+
109+
Or disable it in the CI definition and configure it through the web UI.
110+
111+
Features include:
112+
- test against Python 2 and 3
113+
- run on Ubuntu Xenial
114+
- correct for broken IPv6
115+
116+
Also provided is a minimal template for running under Appveyor (Windows).
117+
118+
## Building Documentation
119+
120+
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 build-docs`. Both techniques rely on the dependencies declared in `setup.cfg/options.extras_require.docs`.
121+
122+
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.
123+
124+
## Cutting releases
125+
126+
By default, tagged commits are released through the continuous integration deploy stage.

tox.ini

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ deps =
77
setuptools>=31.0.1
88
commands =
99
pytest {posargs}
10-
python setup.py checkdocs
1110
usedevelop = True
1211
extras = testing
1312

@@ -18,3 +17,15 @@ extras =
1817
changedir = docs
1918
commands =
2019
python -m sphinx . {toxinidir}/build/html
20+
21+
[testenv:release]
22+
skip_install = True
23+
deps =
24+
pep517>=0.5
25+
# workaround for https://github.com/pypa/twine/issues/423
26+
git+https://github.com/pypa/twine
27+
path.py
28+
commands =
29+
python -c "import path; path.Path('dist').rmtree_p()"
30+
python -m pep517.build .
31+
python -m twine upload dist/*

0 commit comments

Comments
 (0)