A lightweight python package, alternative of pyscafford

lightsong / 2024-09-21 / 原文

python_package

https://github.com/fanqingsong/python_package

Description

A production ready python library template

  • Metadata and dependency information is stored in the pyproject.toml for compatibility with both pip and poetry.
  • Flake8, pylint, and isort configurations are defined to be compatible with the black autoformatter.
  • Pylint settings are based on the Google Python Style Guide and adapted for black compatibility.
  • Linting tools run automatically before each commit using pre-commit, black, and isort.
  • Test coverage reports are generated during every commit and pull request using coverage and pytest-cov. All reports are automatically uploaded and archived on codecov.io.
  • Unit tests are written using pytest and static type checking is provided by mypy.
  • Package releases to PyPI with dynamic versioning provided by bump2version begin automatically whenever a new tag is created in github.
  • Documentation is built using mkdocs and mkdocstrings. Docs are automatically deployed to github pages during every release.
  • Release notes are automatically generated during every release using github actions.

Full Documentation

Installation

To install the package using pip:

pip install pytemplates_pypackage
 

To add the package as a dependency using poetry:

poetry add pytemplates_pypackage
 

Usage

From a .py file:

import pytemplates_pypackage
print(pytemplates_pypackage.__version__)
pytemplates_pypackage.greet(user="Jacob")

from pytemplates_pypackage import wish_farewell
wish_farewell(user="Jacob")
 

Developer Setup

To begin local development, clone the PyTemplates/typer_cli repository and use one of the following methods to build it. Commands should be executed from inside of the project home folder.

Using poetry

poetry install
 

Install optional dependencies using the --extras flag:

poetry install --extras=environment
 

Using pip

pip install .
 

Install optional dependencies using square brackets:

pip install .[environment]