How to create a python 2.x package - simple case

前端 未结 2 1275
萌比男神i
萌比男神i 2020-12-12 17:01

Please show the simple and up to date standard way to create a python package for python 2.x

I\'d prefer to use pip for installing the package later.

The pac

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-12 17:16

    The following is copied from the Distutils Tutorial.

    File layout:

    top
    |-- package
    |   |-- __init__.py
    |   |-- module.py
    |   `-- things
    |       |-- cross.png
    |       |-- fplogo.png
    |       `-- tick.png
    |-- runner
    |-- MANIFEST.in
    |-- README
    `-- setup.py
    

    To make the installation tarball, you simply run:

    python setup.py sdist
    

    To install the package, use pip or easy_install:

    pip install my_package-1.2.3.tar.bz2
    

    or

    easy_install my_package-1.2.3.tar.bz2
    

    Also, you can upload it to PyPI, first register it:

    python setup.py register
    

    then upload the source tarball

    python setup.py sdist upload
    

    You can upload binary eggs as well (though not necessary):

    python setup.py bdist_egg upload
    

    Then folks can install it like this:

    pip install my_package==1.2.3
    

    or,

    easy_install my_package==1.2.3
    

提交回复
热议问题