-
Notifications
You must be signed in to change notification settings - Fork 41
Description
Releasing a Python package to PyPI (Python Package Index) involves several steps. Here's a step-by-step guide to help you publish your Python package:
1. Create Your Python Package:
First, make sure your Python package is properly structured. It should contain the necessary files like setup.py (for package metadata), your Python code, and any other required files.
2. Prepare Your Package:
- Ensure your package follows the Python packaging standards.
- Create a
setup.pyfile in your package directory. Here's an examplesetup.pyfile:
from setuptools import setup
setup(
name='your-package-name',
version='1.0.0',
packages=['your_package'],
url='https://github.com/yourusername/your-package',
author='Your Name',
author_email='your@email.com',
description='Description of your package',
install_requires=[],
)- Create a
DESCRIPTION.rstfile in your package directory. Here's an exampleDESCRIPTION.rstfile:
Quick installation::
pip install iching
Quick Start::
from iching import iching
iching.predict(19850927, 20180119)
See the details: https://github.com/chengjun/iching/blob/master/DESCRIPTION.rst
3. Create an Account on PyPI:
If you haven't already, create an account on PyPI.
4. Install Required Tools:
Make sure you have the necessary tools installed:
pip install setuptools wheel twine5. Build Your Package:
Navigate to your package directory and run the following commands to build your package:
python setup.py sdist bdist_wheelFor example:
(base) MacBook-Pro-4:iching datalab$ python setup.py sdist bdist_wheel
This will create distribution packages in the dist directory.
6. Upload Your Package:
Use twine to upload your package to PyPI. Run the following command:
twine upload dist/*(base) MacBook-Pro-4:iching datalab$ twine upload --verbose --repository-url https://upload.pypi.org/legacy/ --username chengjun --password <your_password> dist/*
Please replace <your_password> with your PyPI password.
This command will upload all files in the dist directory to PyPI.