Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a pip package? #1

Closed
cmaumet opened this issue Nov 26, 2016 · 0 comments
Closed

How to create a pip package? #1

cmaumet opened this issue Nov 26, 2016 · 0 comments

Comments

@cmaumet
Copy link
Owner

@cmaumet cmaumet commented Nov 26, 2016

In this first post you will find quick references to the commands needed to share your package through Pypi.

Pypi, available at https://pypi.python.org, is the official repository for Python packages. Packages available on Pypi can be installed very easily using pip install <package_name>.

Registering your package and first upload

To make your Python package available on Pypi, you will need to:

  1. Create configuration files (including setup.py, setup.cfg) for your project, cf.
    https://packaging.python.org/distributing/#configuring-your-project for a full list.
  2. Build your package
cd <PATH_TO_PACKAGE>
python setup.py sdist
python setup.py bdist_wheel
  1. Register your project and upload to Pypi test server
python setup.py register -r https://testpypi.python.org/pypi
twine upload -r pypitest dist/*
  1. Check that the install works fine from Pypi test server
pip install -i https://testpypi.python.org/pypi <PACKAGE_NAME>
  1. Upload your package to Pypi!
twine upload -r pypi dist/*

Releasing a new version

To make a new version of your package available:

  1. Delete any previous built
cd <PATH_TO_PACKAGE>
rm -rf dist
rm -rf build
rm -rf *.egg-info
  1. Rebuild your package
python setup.py sdist
python setup.py bdist_wheel
  1. Send to Pypi test server and check the installation
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
pip install --index-url https://test.pypi.org/simple/ <PACKAGE_NAME>

Check that the version is the latest one:

pip freeze | grep <PACKAGE_NAME>
  1. Upload to Pypi!
twine upload -r pypi dist/*

For more information, the official documentation (with examples) is available at: https://packaging.python.org/distributing

Edit on July 6, 2018: replacing '/pypi' by '/simple' when installing from pypi test.
Edit on June 2, 2019: updated twine and pip install commands to upload and install from pypi test according to TestPypi documentation. Add info about checking version.

@cmaumet cmaumet changed the title Test blog Make a Python package available via Anaconda Nov 26, 2016
@cmaumet cmaumet changed the title Make a Python package available via Anaconda Make your python package installable via pip Nov 26, 2016
@cmaumet cmaumet changed the title Make your python package installable via pip Make your python package available with pip Nov 26, 2016
@cmaumet cmaumet changed the title Make your python package available with pip `pip install your_package` Nov 27, 2016
@cmaumet cmaumet changed the title `pip install your_package` pip install your_package Nov 27, 2016
@cmaumet cmaumet changed the title pip install your_package Cheatsheet: how to make a pip package Nov 27, 2016
@cmaumet cmaumet changed the title Cheatsheet: how to make a pip package [cheatsheet] How to make a pip package Nov 27, 2016
@cmaumet cmaumet changed the title [cheatsheet] How to make a pip package How to make a pip package? Nov 27, 2016
@cmaumet cmaumet closed this Nov 27, 2016
@cmaumet cmaumet changed the title How to make a pip package? How to create & publish a pip package? Nov 27, 2016
@cmaumet cmaumet changed the title How to create & publish a pip package? How to create a pip package? Nov 27, 2016
Repository owner deleted a comment from markolofsen Dec 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.