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

Posting your project to PyPI #5

Open
luizirber opened this issue May 28, 2016 · 0 comments
Open

Posting your project to PyPI #5

luizirber opened this issue May 28, 2016 · 0 comments

Comments

@luizirber
Copy link
Member

luizirber commented May 28, 2016

Whenever you pip install a package, it's being pulled from PyPI, the central Python package database. If you want your projects to be pip installable, you'll need to put them there. This example will use the Test PyPI server, but can be trivially modified to use the main PyPI repo.

  • Register for an account on Test PyPI: https://testpypi.python.org/pypi

  • save credentials and configurations to ~/.pypirc (if you're on Windows, %userprofile%/.pypirc)

    [distutils]
    index-servers=
    pypi
    pypitest
    
    [pypitest]
    repository = https://testpypi.python.org/pypi
    username = <your user name goes here>
    password = <your password goes here>
    
    [pypi]
    repository = https://pypi.python.org/pypi
    username = <your user name goes here>
    password = <your password goes here>
  • Create source package: python setup.py sdist

    • This bundles up all your files and preps them for PyPI.
    • This creates a new directory called dist/ in your project directory.
  • The default way of interacting with PyPI using setuptools is insecure. Instead, we'll use twine: pip install twine

  • Now use twine to register your package with PyPI. Run this from your project directory: twine register -r pypitest dist/<package> -c ~/.pypirc

    • <package> is the .tar.gz file in the dist directory which was created earlier. It should correspond to the name field from your setup.py, not the project name on github.
    • (if you're on Windows, twine register -r pypitest dist/<package> -c %userprofile%/.pypirc)
  • And upload it! twine upload dist/<package>

Further reading is provided here: https://packaging.python.org/en/latest/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant