我创建了本地pypi服务器http://localhost:8080/simple。我上载了我项目所需的软件包flask-mongoengine,但是当tox尝试对pip install进行软件包依赖的nose时,它将尝试从pypi.python.org下载

Collecting flask-mongoengine==0.9.2 (from -r requirements.txt (line 14))
  Downloading https://localhost:8080/packages/flask-mongoengine-0.9.2.tar.gz (112kB)
    100% |████████████████████████████████| 112kB 26.8MB/s
    Complete output from command python setup.py egg_info:
    Download error on https://pypi.python.org/simple/nose/: [Errno 101] Network is unreachable -- Some packages may not be found!
    Couldn't find index page for 'nose' (maybe misspelled?)
    Download error on https://pypi.python.org/simple/: [Errno 101] Network is unreachable -- Some packages may not be found!
    No local packages or working download links found for nose
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-n57wg0y0/flask-mongoengine/setup.py", line 74, in <module>
        'Topic :: Software Development :: Libraries :: Python Modules'
      File "/var/lib/jenkins/.pyenv/versions/3.5.2/lib/python3.5/distutils/core.py", line 108, in setup
        _setup_distribution = dist = klass(attrs)
      File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/setuptools/dist.py", line 315, in __init__
        self.fetch_build_eggs(attrs['setup_requires'])
      File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/setuptools/dist.py", line 361, in fetch_build_eggs
        replace_conflicting=True,
      File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/pkg_resources/__init__.py", line 850, in resolve
        dist = best[req.key] = env.best_match(req, ws, installer)
      File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1122, in best_match
        return self.obtain(req, installer)
      File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/pkg_resources/__init__.py", line 1134, in obtain
        return installer(requirement)
      File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/setuptools/dist.py", line 429, in fetch_build_egg
        return cmd.easy_install(req)
      File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/setuptools/command/easy_install.py", line 659, in easy_install
        raise DistutilsError(msg)
    distutils.errors.DistutilsError: Could not find suitable distribution for Requirement.parse('nose')


我的pypi服务器具有nose软件包,但是有些方法不能将其重定向到该软件包。

试过第一个答案,它给出了错误

Traceback (most recent call last):
  File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/pip/req/req_install.py", line 82, in __init__
    req = Requirement(req)
  File "/var/lib/jenkins/workspace/myproject/.tox/py35/lib/python3.5/site-packages/pip/_vendor/packaging/requirements.py", line 96, in __init__
    requirement_string[e.loc:e.loc + 8]))
pip._vendor.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'[global]'"

ERROR: InvocationError: '/var/lib/jenkins/workspace/myproject/.tox/py35/bin/pip install -i http://localhost:8080 --trusted-host localhost:8080 -r requirements.txt'

最佳答案

指定默认指向本地主机?在$HOME/.pypirc中:

[distutils]
index-servers =
    localpypi

[localpypi]
repository: http://localhost:8080/simple
username:<your_localpypi_username>
password:<your_localpypi_passwd>


requirements.txt中,这样的内容可能会代替.pypirc而起作用,或者可能需要添加到以下内容中:

# requirements.txt
--index-url http://localhost:8080/simple
--trusted-host localhost:8080
flask-mongoengine


对于$HOME/.config/pip/pip.conf

[global]
timeout = 1
index-url = http://localhost:8080/simple
trusted-host = localhost:8080


嗯,也许也是这样:


https://pypi.python.org/pypi/pypiserver#uploading-packages-remotely


也可能:

python setup.py dist upload -r http://localhost:8080/simple


如果从pypi需要任何依赖项,则:


PyPI local cache for Jenkins/local builds
how to create local own pypi repository index without mirror?


我对--index-url--extra-index-url可以设置的所有位置感到困惑,但是我的想法是设置pypi和pip的index-url?

关于python - 本地pypi包取决于python pypi服务器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48431288/

10-13 04:10