setuptools, easy_install, and a custom pypi server

落花浮王杯 提交于 2020-02-27 05:27:05

问题


I've got a custom pypi server running and am wondering how to point all references to https://pypi.python.org/ from there to my custom server?

I want to be able to cover cases of a user calling pip / easy_install of a package (so they don't have to remember to do -i or -f) as well as someone doing python setup.py install using setuptools with install_requires in the setup.py.

Is there some global config or setting I can do to get all these different methods to look at my local server? I imagine doing some network-proxy-type magic to route http://pypi.python.org/ to my custom server would be one way to go but unfortunately that's not an option.

Thanks!


回答1:


The following configuration will disable the pypi repository index and make your index the only index used by pip and easy_install. The setuptools install command is basically a shortcut to run the easy_install command on the current project. So, that would work too.

# Add the following to ~/.pydistutils.cfg for easy_install
[easy_install]
index_url = http://localhost:8000/


# Add the following to ~/.pip/pip.conf for pip
[global]
index-url = http://localhost:8000/

Look at easy_install's and pip's documentation for more information.

You could provide your users with a simple python script that creates these config files for them.




回答2:


You need to change 2 files:

For distutils

  • Configuration file: doc

    • ~/.pydistutils.cfg for linux,
    • $HOME/pydistutils.cfg for Windows
  • Content:

    [easy_install]
    index_url = YOUR_URL
    

This concerns commands like python setup.py install.

For pip

  • Configuration file: doc

    • ~/.pip/pip.conf for linux,
    • $HOME/pip/pip.conf for Windows
  • Content:

    [global]
    index-url = YOUR_URL
    

This concerns pip install mypackage commands.



来源:https://stackoverflow.com/questions/15014180/setuptools-easy-install-and-a-custom-pypi-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!