How do I create a pip installable project?

前端 未结 4 1416
天涯浪人
天涯浪人 2021-02-01 17:36

How do I create a pip installable project? How do you register with pip?

What meta data config should all projects have in order to allow integration and easy import.

4条回答
  •  清酒与你
    2021-02-01 18:23

    You need to

    1. Write a setup.py file
    2. Run python setup.py sdist tar gzipped file.
    3. Run register or submit the project using the web form.

    You can register using:

    >> python setup.py register
    

    An exmaple setup.py file is:

    #!/usr/bin/env python
    
    from distutils.core import setup
    
     setup(name='Distutils',
      version='1.0',
      description='Python Distribution Utilities',
      author='Greg Ward',
      author_email='gward@python.net',
      url='http://www.python.org/sigs/distutils-sig/',
      packages=['distutils', 'distutils.command'],
     )
    

    Users will then just have to upack the taz file and run install..

    >> python setup.py install
    

提交回复
热议问题