MPPT
A Modern Python Package Template
About¶
A Modern Python Package Template.
Features¶
- Rye: Package Management
- MkDocs: Documentation
- Pre-Commit: Linters
- Pytest: Testing
- Codecov: Testing
- Thu pypi source: China pypi source
Get Started¶
Step1: Create a repository by this template¶
- Create & Clone
Step2: GitHub Configuration¶
- Needed in building documentation site: Set the github action can write the repo
- In the repository:
Setting
->Actions
->Workflow permissions
: SelectRead and write permissions
- Needed in package publishing: Set the pypi token
PYPI_API_TOKEN
- Login your pypi account: https://pypi.org/manage/account/
- In pypi account
Acount Setting
->API tokens
: SelectAdd API token
to generate the api token and COPY it! - In the GitHub repository:
Setting
->Environments
: SelectNew environments
and create an environment namedpublish
- In the
publish
environment add a secrets named withPYPI_API_TOKEN
and set the value with the token - Needed in test coverage report generation: Set the codecov token
CODECOV_TOKEN
- Login your codecov account with GitHub: https://about.codecov.io/
- In codecov account, select the repository and you'll see a page named
Let's get your repo covered
. Just COPY the token here. - In the GitHub repository:
Setting
->Secrets and variables
: Add aRepository secrets
namedCODECOV_TOKEN
and set the value with the token
Step3: Rye installation & Configuration¶
- Install Rye: https://rye-up.com/guide/installation/
- Run
rye sync --no-lock
to install all the dependencies(without lock)
Step4: Pre-Commit Configuration¶
- Fellow the
Quick start
in https://pre-commit.com/ - Because we have already installed the pre-commit by
rye
and have the.pre-commit-config.yaml
file in our repo, so what we ONLY need to do is runpre-commit install
to install the hooks - Run
rye shell
into the created python venv environment - Run
pre-commit run -a
to check all the files in the project
最后更新: November 23, 2023