Giter VIP home page Giter VIP logo

34j / pypackage-template-fork Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 767 KB

Project template for a Python Package using Copier. [autoflake, sphinx-autodoc, CC0 support, "and conrtibutors", repo settings, Python 3.8+, venv creation, more Windows friendly] `copier copy --trust "gh:34j/pypackage-template-fork" <name>`

Home Page: https://github.com/browniebroke/pypackage-template

License: MIT License

Jinja 45.23% JavaScript 1.74% Makefile 4.52% Batchfile 5.45% Python 37.37% Shell 5.70%
cookiecutter cookiecutter-template copier github package package-template python copier-template poetry poetry-python pypi

pypackage-template-fork's Introduction

Python Package Template

CI Status

Project template for a Python Package using Copier.

Features

Quickstart

copier copy --trust "gh:34j/pypackage-template-fork" <path>

Branches/main/Branch protection rules

  • Allow force pushes

Actions/General/Workflow permissions

  • Read and write permissions

Secrets and variables/Actions/Repository secrets

go to Applications and set up Renovate

go to codecov.io and copy CODECOV_TOKEN and add it

go to Read the Docs and add the project

set up pre-commit-ci

Update

copier --force update

Usage

Generate a new project with:

copier copy --trust "gh:34j/pypackage-template-fork" <name>

This will prompt you for a few questions and create new directory with the name you used as project slug.

Note: the --trust option is required because this template may execute some tasks after generating the project, like initialising the git repo, installing dependencies and so forth. These are all listed in the copier.yml of this repo, under the _tasks key. They are all optional and safe to run. You can take my word for it, or better, check the code yourself!

Start developing

The project uses Poetry for dependencies management and packaging. Make sure you have it installed in your development machine. To install the development dependencies in a virtual environment, type:

poetry install

This will also generate a poetry.lock file, you should track this file in version control. To execute the test suite, call pytest inside Poetry's virtual environment via poetry run:

poetry run pytest

Check out the Poetry documentation for more information on the available commands.

GitHub Actions

When you first push to GitHub, it'll start a ci GitHub workflow that you can see in the "Actions" tab of your repository. This workflow runs a couple of jobs:

  • The test job will run your test suite with Pytest against all Python version from 3.8 to 3.11
  • A few things will run in the lint job:
    • black in check mode
    • isort in check mode
    • flake8
    • pyupgrade for Python 3.8+

A labels workflow will also run and synchronise the GitHub labels based on the .github/labels.toml file.

Secrets

The workflows need a few secrets to be setup in your GitHub repository:

  • PYPI_TOKEN to publish releases to PyPI. This one should be created as release environment secret.
  • GH_PAT a personal access token (PAT) with the repo scope for opening pull requests and updating the repository topics. This is used by the hacktoberfest workflow.
  • CODECOV_TOKEN to upload coverage data to codecov.io in the Test workflow (optional for public repos).

If you have the GitHub CLI installed and chose to set up GitHub, they will be created with a dummy value.

Automated release

By following the conventional commits specification, we're able to completely automate versioning and releasing to PyPI. This is handled by the semantic-release.yml workflow. It is triggered manually by default, but can be configured to run on every push to your main branch.

Here is an overview of its features:

  • Check the commit log since the last release, and determine the next version to be released.
  • If no significant change detected, stop here (e.g. just dependencies update).
  • Otherwise, bump the version in code locations specified in setup.cfg.
  • Update the CHANGELOG.md file.
  • Commit changes.
  • Create a git tag.
  • Push to GitHub.
  • Create a release in GitHub with the changes as release notes.
  • Build the source and binary distribution (wheel).
  • Upload the sources to PyPI and attach them to the Github release.

For more details, check out the conventional commits website and Python semantic release Github action.

Pre-commit

The project comes with the config for pre-commit. If you're not familiar with it, follow their documentation on how to install it and set it up.

Documentation

The project assumes that the documentation will be hosted on Read the Docs and written in Markdown with the MyST parser for Sphinx.

To enable it, you might need to go into your dashboard and import the project from Github. Everything else should work out of the box.

Dependencies update

The project dependencies are kept up to date with Renovate which requires the Github app to be installed.

The main advantage of Renovate over Dependabot is the auto-merge option, which is configured to automatically merge minor/patch updates with all the CI checks passing. It supports a variety of package managers, including Poetry, GitHub actions and pre-commit hooks which are used by default.

All contributors

This is a specification that help you highlight every open source contribution in your README. This is easy to maintain as it comes with a GitHub bot to do the updates for you, so more manual updates on the contributors file.

If you never used it before, you will have to install the Github app and give it access to your repo.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Bruno Alla
Bruno Alla

๐Ÿ’ป ๐Ÿค” ๐Ÿ“–
Jeff Tsay
Jeff Tsay

๐Ÿ’ป
34j
34j

๐Ÿ’ป
Stefan Rado
Stefan Rado

๐Ÿ“–

This project follows the all-contributors specification. Contributions of any kind welcome!

pypackage-template-fork's People

Contributors

34j avatar allcontributors[bot] avatar browniebroke avatar dependabot[bot] avatar github-actions[bot] avatar jtsay362 avatar kroimon avatar pre-commit-ci[bot] avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar

Watchers

 avatar

pypackage-template-fork's Issues

Poetry install not using venv

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

Additional context
Add any other context about the problem here.

Autoflake not configured

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

Additional context
Add any other context about the problem here.

Add nb-clean

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Additional context
Add any other context or screenshots about the feature request here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.