Skip to content

CangyuanLi/pyproject

Repository files navigation

pyproject:

PyPI version PyPI - Downloads License: MIT pre-commit Checked with mypy Code style: black Imports: isort Tests Coverage

What is it?

pyproject is a command line utility to setup and distribute Python packages.

Usage:

Dependencies

  • platformdirs - Install configuration files in the correct location
  • rich - Beautiful terminal output

Installing

The easiest way is to install pyproject is from PyPI using pip:

pip install pyproject-generator

Afterwards, a pyproject command will be exposed on your system.

Initializing a Project

Simply run

pyproject init {project_name}

to create your project folder. It will automatically setup a package structure, virtual environment, and install packages.

The final project structure looks like

├── .git
├── .github
│   └── workflows
│       └── tests.yml
├── .gitignore
├── .pre-commit-config.yaml
├── LICENSE
├── README.md
├── benchmarks
│   └── benchmark.py
├── pyproject.toml
├── requirements_dev.txt
├── setup.cfg
├── src
│   └── myproject
│       ├── __init__.py
│       ├── __version__.py
│       └── py.typed
├── tests
│   └── test_myproject.py
└── tox.ini

Configuring pyproject-generator

pyproject also allows you to configure your author name, email, Github URL, PyPI username and password, and a list of default dependencies that you want to install. Please note that your credentials are simply stored locally as plaintext. If you do not wish to store them, you can simply pass them in manually via the --pypi_username and --pypi_password flags, or run without any flags and type them in as required. To configure, run

pyproject config --author="" --email="" --github_url="" --pypi_username="" --pypi_password=""

You may set dependencies one of three ways. In all cases, pass in a comma-delimited string (for multiple dependencies) or a string (for one dependency). You can set the dependencies, which overrides the default settings.

pyproject config --set_dependencies="white,ruff,mypy"

You may add dependencies:

pyproject config --add_dependencies="django"

And you may remove dependencies:

pyproject config --remove_dependencies="pre-commit"

Note that these flags also work with the init action. config merely does the work of saving them locally to be re-used later.

Uploading a Project

pyproject also supplies an upload function. Run

pyproject upload

to build and upload your package to PyPI.

Releases

No releases published

Packages

No packages published

Languages