Skip to content

Commit dceeeb2

Browse files
authored
Initial commit
0 parents  commit dceeeb2

File tree

12 files changed

+351
-0
lines changed

12 files changed

+351
-0
lines changed

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
2+
# help make automated releases for this project
3+
4+
name: Release
5+
6+
on:
7+
push:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build-and-publish:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
# IMPORTANT: this permission is mandatory for trusted publishing
16+
id-token: write
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
- name: Set up Python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: '3.x'
24+
- name: Install build dependencies
25+
run: python -m pip install -U setuptools wheel build
26+
- name: Build
27+
run: python -m build .
28+
- name: Publish
29+
uses: pypa/gh-action-pypi-publish@release/v1
30+
with:
31+
skip-existing: true

.github/workflows/test.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
2+
# help test this project
3+
4+
name: Test
5+
6+
on: [push, pull_request]
7+
8+
jobs:
9+
test:
10+
strategy:
11+
matrix:
12+
python: ['3.7', '3.8', '3.9', '3.10']
13+
platform: [ubuntu-latest, macos-latest, windows-latest]
14+
runs-on: ${{ matrix.platform }}
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v3
18+
- name: Set up Python ${{ matrix.python }}
19+
uses: actions/setup-python@v3
20+
with:
21+
python-version: ${{ matrix.python }}
22+
- name: Install test dependencies
23+
run: python -m pip install -U tox
24+
- name: Test
25+
run: python -m tox -e py

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# general things to ignore
2+
build/
3+
dist/
4+
*.egg-info/
5+
*.egg
6+
*.py[cod]
7+
__pycache__/
8+
*.so
9+
*~
10+
11+
# due to using tox and pytest
12+
.tox
13+
.cache

LICENSE.txt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
Copyright (c) 2016 The Python Packaging Authority (PyPA)
2+
3+
Permission is hereby granted, free of charge, to any person obtaining a copy of
4+
this software and associated documentation files (the "Software"), to deal in
5+
the Software without restriction, including without limitation the rights to
6+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7+
of the Software, and to permit persons to whom the Software is furnished to do
8+
so, subject to the following conditions:
9+
10+
The above copyright notice and this permission notice shall be included in all
11+
copies or substantial portions of the Software.
12+
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19+
SOFTWARE.

README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# A sample Python project
2+
3+
![Python Logo](https://www.python.org/static/community_logos/python-logo.png "Sample inline image")
4+
5+
A sample project that exists as an aid to the [Python Packaging User
6+
Guide][packaging guide]'s [Tutorial on Packaging and Distributing
7+
Projects][distribution tutorial].
8+
9+
This project does not aim to cover best practices for Python project
10+
development as a whole. For example, it does not provide guidance or tool
11+
recommendations for version control, documentation, or testing.
12+
13+
[The source for this project is available here][src].
14+
15+
The metadata for a Python project is defined in the `pyproject.toml` file,
16+
an example of which is included in this project. You should edit this file
17+
accordingly to adapt this sample project to your needs.
18+
19+
----
20+
21+
This is the README file for the project.
22+
23+
The file should use UTF-8 encoding and can be written using
24+
[reStructuredText][rst] or [markdown][md use] with the appropriate [key set][md
25+
use]. It will be used to generate the project webpage on PyPI and will be
26+
displayed as the project homepage on common code-hosting services, and should be
27+
written for that purpose.
28+
29+
Typical contents for this file would include an overview of the project, basic
30+
usage examples, etc. Generally, including the project changelog in here is not a
31+
good idea, although a simple “What's New” section for the most recent version
32+
may be appropriate.
33+
34+
[packaging guide]: https://packaging.python.org
35+
[distribution tutorial]: https://packaging.python.org/tutorials/packaging-projects/
36+
[src]: https://github.com/pypa/sampleproject
37+
[rst]: http://docutils.sourceforge.net/rst.html
38+
[md]: https://tools.ietf.org/html/rfc7764#section-3.5 "CommonMark variant"
39+
[md use]: https://packaging.python.org/specifications/core-metadata/#description-content-type-optional

pyproject.toml

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
[project]
2+
# This is the name of your project. The first time you publish this
3+
# package, this name will be registered for you. It will determine how
4+
# users can install this project, e.g.:
5+
#
6+
# $ pip install sampleproject
7+
#
8+
# And where it will live on PyPI: https://pypi.org/project/sampleproject/
9+
#
10+
# There are some restrictions on what makes a valid project name
11+
# specification here:
12+
# https://packaging.python.org/specifications/core-metadata/#name
13+
name = "sampleproject" # Required
14+
15+
# Versions should comply with PEP 440:
16+
# https://www.python.org/dev/peps/pep-0440/
17+
#
18+
# For a discussion on single-sourcing the version, see
19+
# https://packaging.python.org/guides/single-sourcing-package-version/
20+
version = "3.0.0" # Required
21+
22+
# This is a one-line description or tagline of what your project does. This
23+
# corresponds to the "Summary" metadata field:
24+
# https://packaging.python.org/specifications/core-metadata/#summary
25+
description = "A sample Python project" # Optional
26+
27+
# This is an optional longer description of your project that represents
28+
# the body of text which users will see when they visit PyPI.
29+
#
30+
# Often, this is the same as your README, so you can just read it in from
31+
# that file directly (as we have already done above)
32+
#
33+
# This field corresponds to the "Description" metadata field:
34+
# https://packaging.python.org/specifications/core-metadata/#description-optional
35+
readme = "README.md" # Optional
36+
37+
# Specify which Python versions you support. In contrast to the
38+
# 'Programming Language' classifiers above, 'pip install' will check this
39+
# and refuse to install the project if the version does not match. See
40+
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
41+
requires-python = ">=3.7"
42+
43+
# This is either text indicating the license for the distribution, or a file
44+
# that contains the license
45+
# https://packaging.python.org/en/latest/specifications/core-metadata/#license
46+
license = {file = "LICENSE.txt"}
47+
48+
# This field adds keywords for your project which will appear on the
49+
# project page. What does your project relate to?
50+
#
51+
# Note that this is a list of additional keywords, separated
52+
# by commas, to be used to assist searching for the distribution in a
53+
# larger catalog.
54+
keywords = ["sample", "setuptools", "development"] # Optional
55+
56+
# This should be your name or the name of the organization who originally
57+
# authored the project, and a valid email address corresponding to the name
58+
# listed.
59+
authors = [
60+
{name = "A. Random Developer", email = "[email protected]" } # Optional
61+
]
62+
63+
# This should be your name or the names of the organization who currently
64+
# maintains the project, and a valid email address corresponding to the name
65+
# listed.
66+
maintainers = [
67+
{name = "A. Great Maintainer", email = "[email protected]" } # Optional
68+
]
69+
70+
# Classifiers help users find your project by categorizing it.
71+
#
72+
# For a list of valid classifiers, see https://pypi.org/classifiers/
73+
classifiers = [ # Optional
74+
# How mature is this project? Common values are
75+
# 3 - Alpha
76+
# 4 - Beta
77+
# 5 - Production/Stable
78+
"Development Status :: 3 - Alpha",
79+
80+
# Indicate who your project is intended for
81+
"Intended Audience :: Developers",
82+
"Topic :: Software Development :: Build Tools",
83+
84+
# Pick your license as you wish
85+
"License :: OSI Approved :: MIT License",
86+
87+
# Specify the Python versions you support here. In particular, ensure
88+
# that you indicate you support Python 3. These classifiers are *not*
89+
# checked by "pip install". See instead "python_requires" below.
90+
"Programming Language :: Python :: 3",
91+
"Programming Language :: Python :: 3.7",
92+
"Programming Language :: Python :: 3.8",
93+
"Programming Language :: Python :: 3.9",
94+
"Programming Language :: Python :: 3.10",
95+
"Programming Language :: Python :: 3.11",
96+
"Programming Language :: Python :: 3 :: Only",
97+
]
98+
99+
# This field lists other packages that your project depends on to run.
100+
# Any package you put here will be installed by pip when your project is
101+
# installed, so they must be valid existing projects.
102+
#
103+
# For an analysis of this field vs pip's requirements files see:
104+
# https://packaging.python.org/discussions/install-requires-vs-requirements/
105+
dependencies = [ # Optional
106+
"peppercorn"
107+
]
108+
109+
# List additional groups of dependencies here (e.g. development
110+
# dependencies). Users will be able to install these using the "extras"
111+
# syntax, for example:
112+
#
113+
# $ pip install sampleproject[dev]
114+
#
115+
# Similar to `dependencies` above, these must be valid existing
116+
# projects.
117+
[project.optional-dependencies] # Optional
118+
dev = ["check-manifest"]
119+
test = ["coverage"]
120+
121+
# List URLs that are relevant to your project
122+
#
123+
# This field corresponds to the "Project-URL" and "Home-Page" metadata fields:
124+
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
125+
# https://packaging.python.org/specifications/core-metadata/#home-page-optional
126+
#
127+
# Examples listed include a pattern for specifying where the package tracks
128+
# issues, where the source is hosted, where to say thanks to the package
129+
# maintainers, and where to support the project financially. The key is
130+
# what's used to render the link text on PyPI.
131+
[project.urls] # Optional
132+
"Homepage" = "https://github.com/pypa/sampleproject"
133+
"Bug Reports" = "https://github.com/pypa/sampleproject/issues"
134+
"Funding" = "https://donate.pypi.org"
135+
"Say Thanks!" = "http://saythanks.io/to/example"
136+
"Source" = "https://github.com/pypa/sampleproject/"
137+
138+
# The following would provide a command line executable called `sample`
139+
# which executes the function `main` from this package when invoked.
140+
[project.scripts] # Optional
141+
sample = "sample:main"
142+
143+
# This is configuration specific to the `setuptools` build backend.
144+
# If you are using a different build backend, you will need to change this.
145+
[tool.setuptools]
146+
# If there are data files included in your packages that need to be
147+
# installed, specify them here.
148+
package-data = {"sample" = ["*.dat"]}
149+
150+
[build-system]
151+
# These are the assumed default build requirements from pip:
152+
# https://pip.pypa.io/en/stable/reference/pip/#pep-517-and-518-support
153+
requires = ["setuptools>=43.0.0", "wheel"]
154+
build-backend = "setuptools.build_meta"

src/sample/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def main():
2+
"""Entry point for the application script"""
3+
print("Call your main application code here")

src/sample/package_data.dat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
some data

src/sample/simple.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def add_one(number):
2+
return number + 1

tests/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# The inclusion of the tests module is not meant to offer best practices for
2+
# testing in general.

tests/test_simple.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# the inclusion of the tests module is not meant to offer best practices for
2+
# testing in general, but rather to support the `find_packages` example in
3+
# setup.py that excludes installing the "tests" package
4+
5+
import unittest
6+
7+
from sample.simple import add_one
8+
9+
10+
class TestSimple(unittest.TestCase):
11+
12+
def test_add_one(self):
13+
self.assertEqual(add_one(5), 6)
14+
15+
16+
if __name__ == '__main__':
17+
unittest.main()

tox.ini

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# this file is *not* meant to cover or endorse the use of tox or pytest or
2+
# testing in general,
3+
#
4+
# It's meant to show the use of:
5+
#
6+
# - check-manifest
7+
# confirm items checked into vcs are in your sdist
8+
# - readme_renderer (when using a ReStructuredText README)
9+
# confirms your long_description will render correctly on PyPI.
10+
#
11+
# and also to help confirm pull requests to this project.
12+
13+
[tox]
14+
envlist = py{37,38,39,310}
15+
16+
# Define the minimal tox version required to run;
17+
# if the host tox is less than this the tool with create an environment and
18+
# provision it with a tox that satisfies it under provision_tox_env.
19+
# At least this version is needed for PEP 517/518 support.
20+
minversion = 3.3.0
21+
22+
# Activate isolated build environment. tox will use a virtual environment
23+
# to build a source distribution from the source tree. For build tools and
24+
# arguments use the pyproject.toml file as specified in PEP-517 and PEP-518.
25+
isolated_build = true
26+
27+
[testenv]
28+
deps =
29+
check-manifest >= 0.42
30+
# If your project uses README.rst, uncomment the following:
31+
# readme_renderer
32+
flake8
33+
pytest
34+
build
35+
twine
36+
commands =
37+
check-manifest --ignore 'tox.ini,tests/**'
38+
python -m build
39+
python -m twine check dist/*
40+
flake8 .
41+
py.test tests {posargs}
42+
43+
[flake8]
44+
exclude = .tox,*.egg,build,data
45+
select = E,W,F

0 commit comments

Comments
 (0)