Skip to content

Instantly share code, notes, and snippets.

@littlepea
Last active December 15, 2015 08:58
Show Gist options
  • Save littlepea/5234423 to your computer and use it in GitHub Desktop.
Save littlepea/5234423 to your computer and use it in GitHub Desktop.
PyPI packaging instructions
  1. Fork the repo and clone the fork into PipDiff:

    git clone git@github.com:littlepea/pipdiff.git PipDiff
    
  2. Test that the utility is working:

    cd pipdiff/
    ./pipdiff.py
    
    Django==1.4.5                            PyPI:Django==1.5
    Pillow==2.0.0
    South==0.7.6
    Unidecode==0.04.12
    amqp==1.0.8                              PyPI:amqp==1.0.10
    ...
    
  3. Setup a proper directory structure for the package:

    PipDiff/
        pipdiff/
            __init__.py
            pipdiff.py
        README.md
    
  4. In pipdiff.py wrap the code into main() function and at the end add:

    if __name__ == '__main__':
        main()
    
  5. Copy LICENSE, MANIFEST.in, .gitignore, setup.py, bootstrap.py, buildout.cfg from https://github.com/srid/modern-package-template into PipDiff

  6. In buildout.cfg set:

    eggs = pipdiff
    
  7. In setup.py set:

    name='pipdiff',
    description="View a summary list of package release differences between your local environment and PyPI.",
    author='Evgeny Demchenko',
    author_email='little_pea@list.ru',
    url='https://github.com/ogt/pipdiff',
    license='BSD',
    entry_points={
        'console_scripts': ['pipdiff.pipdiff:main']
    }
    

entry_points are to make sure pipdiff will be in the bin/ available for execution after installation.

  1. Test that it's installable by pip:

    $ pip install -e PipDiff/
    Obtaining file:///home/slam/workspace/PipDiff
      Running setup.py egg_info for package from file:///home/slam/workspace/PipDiff
    
    Installing collected packages: pipdiff
      Running setup.py develop for pipdiff
    
        Creating /home/slam/.virtualenvs/cms/lib/python2.7/site-packages/pipdiff.egg-link (link to .)
        pipdiff 0.1 is already the active version in easy-install.pth
        Installing pipdiff script to /home/slam/.virtualenvs/cms/bin
    
        Installed /home/slam/workspace/PipDiff
    Successfully installed pipdiff
    Cleaning up...
    
  2. Test that it's executable:

    $ pipdiff
    Django==1.4.5                            PyPI:Django==1.5
    Pillow==2.0.0
    South==0.7.6
    Unidecode==0.04.12
    amqp==1.0.8                              PyPI:amqp==1.0.10
    ...
    

10. Register on PyPI (you need to have an account):

python setup.py register

11. Upload the code to PyPI:

python setup.py sdist upload

12. Remove local version and test the PyPI installation:

pip uninstall pipdiff

pip install pipdiff
  1. Success!

More info here: http://guide.python-distribute.org/quickstart.html

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