Python package install using pip or easy_install from repos

后端 未结 4 853
深忆病人
深忆病人 2020-12-23 08:46

The simplest way to deal with python package installations, so far, to me, has been to check out the source from the source control system and then add a symbolic link in th

相关标签:
4条回答
  • 2020-12-23 09:07

    If you download or check out the source distribution of a package — the one that has its "setup.py" inside of it — then if the package is based on the "setuptools" (which also power easy_install), you can move into that directory and say:

    $ python setup.py develop
    

    and it will create the right symlinks in dist-packages so that the .py files in the source distribution are the ones that get imported, rather than copies installed separately (which is what "setup.py install" would do — create separate copies that don't change immediately when you edit the source code to try a change).

    As the other response indicates, you should try reading the "setuptools" documentation to learn more. "setup.py develop" is a really useful feature! Try using it in combination with a virtualenv, and you can "setup.py develop" painlessly and without messing up your system-wide Python with packages you are only developing on temporarily:

    http://pypi.python.org/pypi/virtualenv
    
    0 讨论(0)
  • 2020-12-23 09:07

    easy_install accepts a URL for the source tree too. Works at least when the sources are in Subversion.

    0 讨论(0)
  • 2020-12-23 09:13

    easy_install has support for downloading specific versions. For example:

    easy_install python-dateutil==1.4.0
    

    Will install v1.4, while the latest version 1.4.1 would be picked if no version was specified.

    There is also support for svn checkouts, but using that doesn't give you much benefits from your manual version. See the manual for more information above.

    Being able to switch to specific branches is rarely useful unless you are developing the packages in question, and then it's typically not a good idea to install them in site-packages anyway.

    0 讨论(0)
  • 2020-12-23 09:15

    Using pip this is quite easy. For instance:

    pip install -e hg+http://bitbucket.org/andrewgodwin/south/#egg=South
    

    Pip will automatically clone the source repo and run "setup.py develop" for you to install it into your environment (which hopefully is a virtualenv). Git, Subversion, Bazaar and Mercurial are all supported.

    You can also then run "pip freeze" and it will output a list of your currently-installed packages with their exact versions (including, for develop-installs, the exact revision from the VCS). You can put this straight into a requirements file and later run

    pip install -r requirements.txt
    

    to install that same set of packages at the exact same versions.

    0 讨论(0)
提交回复
热议问题