my-package-name
├── my_module_name
│ └── __init__.py
├── LICENSE.txt
├── README.rst
├── requirements.txt
└── pyproject.toml
-
Create a Python package name which is ideally all lower case with no dashes but may contain dashes (but not underscores)
- Example :
my-package-name
- Set parent directory to package name
- Example :
-
Create a Python module name which is ideally all lower case with no dashes or underscores but may contain underscores (but not dashes)
- Example :
my_module_name
- Set child directory to module name :
my-package-name/my_module_name
- Example :
-
Copy pyproject.toml from https://github.com/pypa/sampleproject
-
Create a
README.md
-
Choose a
license
( http://choosealicense.com/ )- Get the "license" identifier value from the "Optional" section or the URL or SPDX ( https://spdx.org/licenses/ )
- Copy paste the license text into LICENSE.txt
-
Update
pyproject.toml
valuesname
:my-package-name
version
description
keywords
authors
maintainers
- Set
classifiers
( https://pypi.python.org/pypi?%3Aaction=list_classifiers ) - Set
dependencies
- Remove
project.optional-dependencies
unless you need them - Set
project.urls
- Remove
project.scripts
unless your project surfaces any command line scripts - Remove
tool.setuptools
as we're usinghatch
- Update
build-system
to usehatch
-
[build-system] requires = ["hatchling"] build-backend = "hatchling.build"
-
- Create
requirements.txt
: ?- requirements.txt is for pinning versions of an environment. dependencies is for abstract requirements](https://packaging.python.org/requirements/)
-
No need to create MANIFEST.in as it's only required in Python 2.6
-
Test installation
virtualenv /tmp/testinstall . /tmp/testinstall/bin/activate pip install /path/to/mypackage
-
Create github repo with package name and commit
-
Ensure you have
hatch
installedpython3 -m pip install --user --upgrade hatch
-
Build sign and upload to pypitest ( https://hynek.me/articles/sharing-your-labor-of-love-pypi-quick-and-dirty/ )
hatch build hatch publish --repo https://test.pypi.org/legacy/
-
Verify everything looks good at https://testpypi.python.org/pypi/mypackagename/
-
Test installation in a virtualenv
virtualenv /tmp/testinstall . /tmp/testinstall/bin/activate pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple mypackagename
-
Sign and upload to pypi
hatch publish --repo https://upload.pypi.org/legacy/
-
Verify everything looks good at https://pypi.python.org/pypi/mypackagename
-
Delete build artifcats
rm -rf dist /tmp/testinstall
Explore using cookiecutter to automate all this