Debian Codegraph @

testing/web-platform/tests/tools/third_party/zipp/skeleton.md

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