构建 python 个 pypi 轮子,通常的噩梦

Building python pypi wheels, the usual nightmare

我正在尝试构建一个包并将其上传到 pypi,我通过了这一点并且上传成功,让我向您介绍我正在做的事情:

setup.py:

from setuptools import setup, find_packages

setup(
    name='project_name',
    version='1.0',
    packages=find_packages(),
    url='url',
    license='license',
    author='author',
    author_email='email_here@some_mail.com',
    description='description',
    install_requires=[
        'oauth2client',
        'pyarrow',
        'pandas',
        'requests',
        'gcloud'
    ],
)

我愿意:

% python3 setup.py sdist bdist_wheel

之后是

% python3 -m twine upload -u username -p password --repository-url https://test.pypi.org/legacy/ dist/*

两个运行都很好,没有错误/警告...

然后我得到一个 url 其中包含:

% pip install -i https://test.pypi.org/simple/ project_name==1.0

所以我创建了一个virtualenv环境并尝试安装:

% virtualenv test_env
% source test_env/bin/activate
% pip install -i https://test.pypi.org/simple/ project_name==1.0

出于某种原因,我首先得到这个:

ERROR: Could not find a version that satisfies the requirement gcloud (from project_name==1.0) (from versions: none)
ERROR: No matching distribution found for gcloud (from project_name==1.0)

然后在重试(未应用任何更改)运行 最后一个命令后我得到了其他结果,我也得到了其他结果。那么...怎么了?

simple/ project_name==1.0
Looking in indexes: https://test.pypi.org/simple/
Collecting project_name==1.0
  Downloading https://test-files.pythonhosted.org/packages/08/38/b040820ceddc63a87596a5a29ce3a5d1b309555238d7ae063835e8c8ea8a/project_name-1.0-py3-none-any.whl (9.1 kB)
Collecting pyarrow
  Downloading https://test-files.pythonhosted.org/packages/c1/82/04249512513b31d7cd9f6fa63cf0d1c64c4705da32e3c3ece9d676e235ff/pyarrow-1.0.1.tar.gz (1.3 MB)
     |████████████████████████████████| 1.3 MB 594 kB/s 
  Installing build dependencies ... error
  ERROR: Command errored out with exit status 1:
   command: /Users/username/Desktop/testenv/bin/python /Users/username/Desktop/testenv/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/rp/xxjnjsvn70g2ndh68l0g10bh0000gn/T/pip-build-env-cnc0ds0l/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://test.pypi.org/simple/ -- 'cython >= 0.29' 'numpy==1.14.5; python_version<'"'"'3.7'"'"'' 'numpy==1.16.0; python_version>='"'"'3.7'"'"'' setuptools setuptools_scm wheel
       cwd: None
  Complete output (4 lines):
  Looking in indexes: https://test.pypi.org/simple/
  Ignoring numpy: markers 'python_version < "3.7"' don't match your environment
  ERROR: Could not find a version that satisfies the requirement cython>=0.29 (from versions: 0.23.4)
  ERROR: No matching distribution found for cython>=0.29
  ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/username/Desktop/testenv/bin/python /Users/username/Desktop/testenv/lib/python3.8/site-packages/pip install --ignore-installed --no-user --prefix /private/var/folders/rp/xxjnjsvn70g2ndh68l0g10bh0000gn/T/pip-build-env-cnc0ds0l/overlay --no-warn-script-location --no-binary :none: --only-binary :none: -i https://test.pypi.org/simple/ -- 'cython >= 0.29' 'numpy==1.14.5; python_version<'"'"'3.7'"'"'' 'numpy==1.16.0; python_version>='"'"'3.7'"'"'' setuptools setuptools_scm wheel Check the logs for full command output.

注意: 这个包很好,我可以在我的 mbp 的系统解释器 (python3.8) 上安装它,但那是因为所有依赖项 numpygcloud ... 已经安装。

我认为这是因为 pip 正在寻找 https://test.pypi.org/simple/ 中不存在的包依赖项。

尝试:

pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple your-package

这将从 test.pypi 中提取您的包,但当 pip 无法在那里找到依赖项时,会返回到常规 pypi