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

Comments

Projects
None yet
1 participant
@cmaumet
Owner

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 -r pypitest dist/*
pip install -i https://testpypi.python.org/simple <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

Edited on 06/07/2018: replacing '/pypi' by '/simple' when installing from pypi test.

@cmaumet cmaumet changed the title from Test blog to Make a Python package available via Anaconda Nov 26, 2016

@cmaumet cmaumet changed the title from Make a Python package available via Anaconda to Make your python package installable via pip Nov 26, 2016

@cmaumet cmaumet changed the title from Make your python package installable via pip to Make your python package available with pip Nov 26, 2016

@cmaumet cmaumet changed the title from Make your python package available with pip to `pip install your_package` Nov 27, 2016

@cmaumet cmaumet changed the title from `pip install your_package` to pip install your_package Nov 27, 2016

@cmaumet cmaumet changed the title from pip install your_package to Cheatsheet: how to make a pip package Nov 27, 2016

@cmaumet cmaumet changed the title from Cheatsheet: how to make a pip package to [cheatsheet] How to make a pip package Nov 27, 2016

@cmaumet cmaumet changed the title from [cheatsheet] How to make a pip package to How to make a pip package? Nov 27, 2016

@cmaumet cmaumet closed this Nov 27, 2016

@cmaumet cmaumet changed the title from How to make a pip package? to How to create & publish a pip package? Nov 27, 2016

@cmaumet cmaumet changed the title from How to create & publish a pip package? to How to create a pip package? Nov 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment