| Start |
|---|
| Introduction Every package requires a Consider the following directory structure for a simple package: The The following virtualenv (opens new window) is great to test package installs without modifying your other Python environments: |
| Uploading to PyPI Once your Setup a .pypirc FileThis file stores logins and passwords to authenticate your accounts. It is typically stored in your home directory. It is safer (opens new window) to use Register and Upload to testpypi (optional)Note: PyPI does not allow overwriting uploaded packages (opens new window), so it is prudent to first test your deployment on a dedicated test server, e.g. testpypi. This option will be discussed. Consider a versioning scheme (opens new window) for your package prior to uploading such as calendar versioning (opens new window) or semantic versioning (opens new window). Either log in, or create a new account at testpypi (opens new window). Registration is only required the first time, although registering more than once is not harmful. While in the root directory of your package: Your package should now be accessible through your account. TestingMake a test virtual environment. Try to If successful, your package is least importable. You might consider testing your API as well before your final upload to PyPI. If you package failed during testing, do not worry. You can still fix it, re-upload to testpypi and test again. Register and Upload to PyPIMake sure Either log in, or create a new account at PyPI (opens new window). That's it! Your package is now live (opens new window). If you discover a bug, simply upload a new version of your package. DocumentationDon't forget to include at least some kind of documentation for your package. PyPi takes as the default formatting language reStructuredText (opens new window). ReadmeIf your package doesn't have a big documentation, include what can help other users in Create Note that if you try to put Markdown (opens new window) file into your package, PyPi will read it as a pure text file without any formatting. LicensingIt's often more than welcome to put a In more readable way some licenses are explained at TL;DR (opens new window). |
| Making package executable If your package isn't only a library, but has a piece of code that can be used either as a showcase or a standalone application when your package is installed, put that piece of code into Put the If there's no python: No module named `package_name.__main__;` 'package_name' is a package and cannot be directly executed. RemarksThe pypa sample project (opens new window) contains a complete, easily modifiable template |
Read Article
https://develop.horje.com/learn/1434/reference