Tutorial¶
Install cruft
First, you need to create a virtualenv for the package project. Use your favorite method, or create a virtualenv for your new package like this:
python3 -m venv .venv
Then install cruft:
$ . .venv/bin/activate $ python -m pip install cruft
Generate Your Package
Now it’s time to generate your Python package.
Use cruft, pointing it at the cookiecutter-namespace-template repo:
$ cruft create https://github.com/veit/cookiecutter-namespace-template.git
You’ll be asked to enter a bunch of values to set the package up. If you don’t know what to enter, stick with the defaults.
Create a Git Repo
Go to your Git account and create a new repo named
my.package
, wheremy.package
matches the[namespace.package]
from your answers to running cookiecutter.Note
If your venv folder is within your project folder, be sure to add the venv folder name to your
.gitignore
file.You will find one folder named after the
[namespace.package]
. Move into his folder, and then setup git to use your Git repo and upload the code:$ cd my.package $ git init . $ git add . $ git commit -m "Initial commit" $ git remote add origin git@example.org:MYUSERNAME/MY.PYCKAGE.git $ git push -u origin main
Where
MYUSERNAME
andMY.PACKAGE
are adjusted for your username and package name.You’ll need a ssh key to push the repo. You can generate a key or add an existing one.
Install dev requirements
You should still be in the folder containing the
pyproject.toml
file.Install the new project’s local development requirements:
$ python -m pip install -e ".[dev]"
Release on PyPI
Here’s a release checklist you can use.