Initial commit
This commit is contained in:
commit
109fdc68cc
31
.github/workflows/release.yml
vendored
Normal file
31
.github/workflows/release.yml
vendored
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
|
||||||
|
# help make automated releases for this project
|
||||||
|
|
||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-publish:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
# IMPORTANT: this permission is mandatory for trusted publishing
|
||||||
|
id-token: write
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: '3.x'
|
||||||
|
- name: Install build dependencies
|
||||||
|
run: python -m pip install -U setuptools wheel build
|
||||||
|
- name: Build
|
||||||
|
run: python -m build .
|
||||||
|
- name: Publish
|
||||||
|
uses: pypa/gh-action-pypi-publish@release/v1
|
||||||
|
with:
|
||||||
|
skip-existing: true
|
||||||
27
.github/workflows/test.yml
vendored
Normal file
27
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# this file is *not* meant to cover or endorse the use of GitHub Actions, but rather to
|
||||||
|
# help test this project
|
||||||
|
|
||||||
|
name: Test
|
||||||
|
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
python: ['3.9', '3.10', '3.11', '3.12', '3.13']
|
||||||
|
platform: [ubuntu-latest, macos-latest, windows-latest]
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Set up Python ${{ matrix.python }}
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python }}
|
||||||
|
- name: Install test dependencies
|
||||||
|
run: python -m pip install --upgrade nox
|
||||||
|
- name: Test
|
||||||
|
run: python -m nox -s tests-${{ matrix.python }}
|
||||||
|
- name: Lint
|
||||||
|
run: python -m nox -s lint
|
||||||
14
.gitignore
vendored
Normal file
14
.gitignore
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# general things to ignore
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
*.egg-info/
|
||||||
|
*.egg
|
||||||
|
*.py[cod]
|
||||||
|
__pycache__/
|
||||||
|
*.so
|
||||||
|
*~
|
||||||
|
venv/
|
||||||
|
|
||||||
|
# due to using nox and pytest
|
||||||
|
.nox
|
||||||
|
.cache
|
||||||
19
LICENSE.txt
Normal file
19
LICENSE.txt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
Copyright (c) 2016 The Python Packaging Authority (PyPA)
|
||||||
|
|
||||||
|
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 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.
|
||||||
39
README.md
Normal file
39
README.md
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
# A sample Python project
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|
A sample project that exists as an aid to the [Python Packaging User
|
||||||
|
Guide][packaging guide]'s [Tutorial on Packaging and Distributing
|
||||||
|
Projects][distribution tutorial].
|
||||||
|
|
||||||
|
This project does not aim to cover best practices for Python project
|
||||||
|
development as a whole. For example, it does not provide guidance or tool
|
||||||
|
recommendations for version control, documentation, or testing.
|
||||||
|
|
||||||
|
[The source for this project is available here][src].
|
||||||
|
|
||||||
|
The metadata for a Python project is defined in the `pyproject.toml` file,
|
||||||
|
an example of which is included in this project. You should edit this file
|
||||||
|
accordingly to adapt this sample project to your needs.
|
||||||
|
|
||||||
|
----
|
||||||
|
|
||||||
|
This is the README file for the project.
|
||||||
|
|
||||||
|
The file should use UTF-8 encoding and can be written using
|
||||||
|
[reStructuredText][rst] or [markdown][md use] with the appropriate [key set][md
|
||||||
|
use]. It will be used to generate the project webpage on PyPI and will be
|
||||||
|
displayed as the project homepage on common code-hosting services, and should be
|
||||||
|
written for that purpose.
|
||||||
|
|
||||||
|
Typical contents for this file would include an overview of the project, basic
|
||||||
|
usage examples, etc. Generally, including the project changelog in here is not a
|
||||||
|
good idea, although a simple “What's New” section for the most recent version
|
||||||
|
may be appropriate.
|
||||||
|
|
||||||
|
[packaging guide]: https://packaging.python.org
|
||||||
|
[distribution tutorial]: https://packaging.python.org/tutorials/packaging-projects/
|
||||||
|
[src]: https://github.com/pypa/sampleproject
|
||||||
|
[rst]: http://docutils.sourceforge.net/rst.html
|
||||||
|
[md]: https://tools.ietf.org/html/rfc7764#section-3.5 "CommonMark variant"
|
||||||
|
[md use]: https://packaging.python.org/specifications/core-metadata/#description-content-type-optional
|
||||||
53
noxfile.py
Normal file
53
noxfile.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# this file is *not* meant to cover or endorse the use of nox or pytest or
|
||||||
|
# testing in general,
|
||||||
|
#
|
||||||
|
# It's meant to show the use of:
|
||||||
|
#
|
||||||
|
# - check-manifest
|
||||||
|
# confirm items checked into vcs are in your sdist
|
||||||
|
# - readme_renderer (when using a reStructuredText README)
|
||||||
|
# confirms your long_description will render correctly on PyPI.
|
||||||
|
#
|
||||||
|
# and also to help confirm pull requests to this project.
|
||||||
|
|
||||||
|
import os
|
||||||
|
|
||||||
|
import nox
|
||||||
|
|
||||||
|
nox.options.sessions = ["lint"]
|
||||||
|
|
||||||
|
# Define the minimal nox version required to run
|
||||||
|
nox.options.needs_version = ">= 2024.3.2"
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session
|
||||||
|
def lint(session):
|
||||||
|
session.install("flake8")
|
||||||
|
session.run(
|
||||||
|
"flake8", "--exclude", ".nox,*.egg,build,data",
|
||||||
|
"--select", "E,W,F", "."
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session
|
||||||
|
def build_and_check_dists(session):
|
||||||
|
session.install("build", "check-manifest >= 0.42", "twine")
|
||||||
|
# If your project uses README.rst, uncomment the following:
|
||||||
|
# session.install("readme_renderer")
|
||||||
|
|
||||||
|
session.run("check-manifest", "--ignore", "noxfile.py,tests/**")
|
||||||
|
session.run("python", "-m", "build")
|
||||||
|
session.run("python", "-m", "twine", "check", "dist/*")
|
||||||
|
|
||||||
|
|
||||||
|
@nox.session(python=["3.9", "3.10", "3.11", "3.12", "3.13"])
|
||||||
|
def tests(session):
|
||||||
|
session.install("pytest")
|
||||||
|
build_and_check_dists(session)
|
||||||
|
|
||||||
|
generated_files = os.listdir("dist/")
|
||||||
|
generated_sdist = os.path.join("dist/", generated_files[1])
|
||||||
|
|
||||||
|
session.install(generated_sdist)
|
||||||
|
|
||||||
|
session.run("py.test", "tests/", *session.posargs)
|
||||||
162
pyproject.toml
Normal file
162
pyproject.toml
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
# Guide (user-friendly):
|
||||||
|
# https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
|
||||||
|
|
||||||
|
# Specification (technical, formal):
|
||||||
|
# https://packaging.python.org/en/latest/specifications/pyproject-toml/
|
||||||
|
|
||||||
|
|
||||||
|
# Choosing a build backend:
|
||||||
|
# https://packaging.python.org/en/latest/tutorials/packaging-projects/#choosing-a-build-backend
|
||||||
|
[build-system]
|
||||||
|
# A list of packages that are needed to build your package:
|
||||||
|
requires = ["setuptools"] # REQUIRED if [build-system] table is used
|
||||||
|
# The name of the Python object that frontends will use to perform the build:
|
||||||
|
build-backend = "setuptools.build_meta" # If not defined, then legacy behavior can happen.
|
||||||
|
|
||||||
|
|
||||||
|
[project]
|
||||||
|
# This is the name of your project. The first time you publish this
|
||||||
|
# package, this name will be registered for you. It will determine how
|
||||||
|
# users can install this project, e.g.:
|
||||||
|
#
|
||||||
|
# $ pip install sampleproject
|
||||||
|
#
|
||||||
|
# And where it will live on PyPI: https://pypi.org/project/sampleproject/
|
||||||
|
#
|
||||||
|
# There are some restrictions on what makes a valid project name
|
||||||
|
# specification here:
|
||||||
|
# https://packaging.python.org/specifications/core-metadata/#name
|
||||||
|
name = "sampleproject" # REQUIRED, is the only field that cannot be marked as dynamic.
|
||||||
|
|
||||||
|
# Versions should comply with PEP 440:
|
||||||
|
# https://www.python.org/dev/peps/pep-0440/
|
||||||
|
#
|
||||||
|
# For a discussion on single-sourcing the version, see
|
||||||
|
# https://packaging.python.org/guides/single-sourcing-package-version/
|
||||||
|
version = "4.0.0" # REQUIRED, although can be dynamic
|
||||||
|
|
||||||
|
# This is a one-line description or tagline of what your project does. This
|
||||||
|
# corresponds to the "Summary" metadata field:
|
||||||
|
# https://packaging.python.org/specifications/core-metadata/#summary
|
||||||
|
description = "A sample Python project"
|
||||||
|
|
||||||
|
# This is an optional longer description of your project that represents
|
||||||
|
# the body of text which users will see when they visit PyPI.
|
||||||
|
#
|
||||||
|
# Often, this is the same as your README, so you can just read it in from
|
||||||
|
# that file directly.
|
||||||
|
#
|
||||||
|
# This field corresponds to the "Description" metadata field:
|
||||||
|
# https://packaging.python.org/specifications/core-metadata/#description-optional
|
||||||
|
readme = "README.md"
|
||||||
|
|
||||||
|
# Specify which Python versions you support. In contrast to the
|
||||||
|
# 'Programming Language' classifiers in this file, 'pip install' will check this
|
||||||
|
# and refuse to install the project if the version does not match. See
|
||||||
|
# https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
|
||||||
|
requires-python = ">=3.9"
|
||||||
|
|
||||||
|
# This is either text indicating the license for the distribution, or a file
|
||||||
|
# that contains the license.
|
||||||
|
# https://packaging.python.org/en/latest/specifications/core-metadata/#license
|
||||||
|
license = { file = "LICENSE.txt" }
|
||||||
|
|
||||||
|
# This field adds keywords for your project which will appear on the
|
||||||
|
# project page. What does your project relate to?
|
||||||
|
#
|
||||||
|
# Note that this is a list of additional keywords, separated
|
||||||
|
# by commas, to be used to assist searching for the distribution in a
|
||||||
|
# larger catalog.
|
||||||
|
keywords = ["sample", "setuptools", "development"]
|
||||||
|
|
||||||
|
# This should be your name or the name of the organization who originally
|
||||||
|
# authored the project, and a valid email address corresponding to the name
|
||||||
|
# listed.
|
||||||
|
authors = [{ name = "A. Random Developer", email = "author@example.com" }]
|
||||||
|
|
||||||
|
# This should be your name or the names of the organization who currently
|
||||||
|
# maintains the project, and a valid email address corresponding to the name
|
||||||
|
# listed.
|
||||||
|
maintainers = [
|
||||||
|
{ name = "A. Great Maintainer", email = "maintainer@example.com" },
|
||||||
|
]
|
||||||
|
|
||||||
|
# Classifiers help users find your project by categorizing it.
|
||||||
|
#
|
||||||
|
# For a list of valid classifiers, see https://pypi.org/classifiers/
|
||||||
|
classifiers = [
|
||||||
|
# How mature is this project? Common values are
|
||||||
|
# 3 - Alpha
|
||||||
|
# 4 - Beta
|
||||||
|
# 5 - Production/Stable
|
||||||
|
"Development Status :: 3 - Alpha",
|
||||||
|
|
||||||
|
# Indicate who your project is intended for
|
||||||
|
"Intended Audience :: Developers",
|
||||||
|
"Topic :: Software Development :: Build Tools",
|
||||||
|
|
||||||
|
# Pick your license as you wish
|
||||||
|
"License :: OSI Approved :: MIT License",
|
||||||
|
|
||||||
|
# Specify the Python versions you support here. In particular, ensure
|
||||||
|
# that you indicate you support Python 3. These classifiers are *not*
|
||||||
|
# checked by "pip install". See instead "requires-python" key in this file.
|
||||||
|
"Programming Language :: Python :: 3",
|
||||||
|
"Programming Language :: Python :: 3.9",
|
||||||
|
"Programming Language :: Python :: 3.10",
|
||||||
|
"Programming Language :: Python :: 3.11",
|
||||||
|
"Programming Language :: Python :: 3.12",
|
||||||
|
"Programming Language :: Python :: 3.13",
|
||||||
|
"Programming Language :: Python :: 3 :: Only",
|
||||||
|
]
|
||||||
|
|
||||||
|
# This field lists other packages that your project depends on to run.
|
||||||
|
# Any package you put here will be installed by pip when your project is
|
||||||
|
# installed, so they must be valid existing projects.
|
||||||
|
#
|
||||||
|
# For an analysis of this field vs pip's requirements files see:
|
||||||
|
# https://packaging.python.org/discussions/install-requires-vs-requirements/
|
||||||
|
dependencies = ["peppercorn"]
|
||||||
|
|
||||||
|
# List additional groups of dependencies here (e.g. development
|
||||||
|
# dependencies). Users will be able to install these using the "extras"
|
||||||
|
# syntax, for example:
|
||||||
|
#
|
||||||
|
# $ pip install sampleproject[dev]
|
||||||
|
#
|
||||||
|
# Optional dependencies the project provides. These are commonly
|
||||||
|
# referred to as "extras". For a more extensive definition see:
|
||||||
|
# https://packaging.python.org/en/latest/specifications/dependency-specifiers/#extras
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = ["check-manifest"]
|
||||||
|
test = ["coverage"]
|
||||||
|
|
||||||
|
# List URLs that are relevant to your project
|
||||||
|
#
|
||||||
|
# This field corresponds to the "Project-URL" and "Home-Page" metadata fields:
|
||||||
|
# https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
|
||||||
|
# https://packaging.python.org/specifications/core-metadata/#home-page-optional
|
||||||
|
#
|
||||||
|
# Examples listed include a pattern for specifying where the package tracks
|
||||||
|
# issues, where the source is hosted, where to say thanks to the package
|
||||||
|
# maintainers, and where to support the project financially. The key is
|
||||||
|
# what's used to render the link text on PyPI.
|
||||||
|
[project.urls]
|
||||||
|
"Homepage" = "https://github.com/pypa/sampleproject"
|
||||||
|
"Bug Reports" = "https://github.com/pypa/sampleproject/issues"
|
||||||
|
"Funding" = "https://donate.pypi.org"
|
||||||
|
"Say Thanks!" = "http://saythanks.io/to/example"
|
||||||
|
"Source" = "https://github.com/pypa/sampleproject/"
|
||||||
|
|
||||||
|
# The following would provide a command line executable called `sample`
|
||||||
|
# which executes the function `main` from this package when invoked.
|
||||||
|
[project.scripts]
|
||||||
|
sample = "sample:main"
|
||||||
|
|
||||||
|
|
||||||
|
# This is configuration specific to the `setuptools` build backend.
|
||||||
|
# If you are using a different build backend, you will need to change this.
|
||||||
|
[tool.setuptools]
|
||||||
|
# If there are data files included in your packages that need to be
|
||||||
|
# installed, specify them here.
|
||||||
|
package-data = { "sample" = ["*.dat"] }
|
||||||
3
src/sample/__init__.py
Normal file
3
src/sample/__init__.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
def main():
|
||||||
|
"""Entry point for the application script"""
|
||||||
|
print("Call your main application code here")
|
||||||
1
src/sample/package_data.dat
Normal file
1
src/sample/package_data.dat
Normal file
@ -0,0 +1 @@
|
|||||||
|
some data
|
||||||
2
src/sample/simple.py
Normal file
2
src/sample/simple.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
def add_one(number):
|
||||||
|
return number + 1
|
||||||
2
tests/__init__.py
Normal file
2
tests/__init__.py
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# The inclusion of the tests module is not meant to offer best practices for
|
||||||
|
# testing in general.
|
||||||
17
tests/test_simple.py
Normal file
17
tests/test_simple.py
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# the inclusion of the tests module is not meant to offer best practices for
|
||||||
|
# testing in general, but rather to support the `find_packages` example in
|
||||||
|
# setup.py that excludes installing the "tests" package
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
from sample.simple import add_one
|
||||||
|
|
||||||
|
|
||||||
|
class TestSimple(unittest.TestCase):
|
||||||
|
|
||||||
|
def test_add_one(self):
|
||||||
|
self.assertEqual(add_one(5), 6)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
unittest.main()
|
||||||
Loading…
Reference in New Issue
Block a user