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

标签 python pip setup.py pypi python-wheel

我正在尝试构建一个包并将其上传到 pypi ,我已经过了这一 pip 并且上传成功,让我引导您完成我正在做的事情:

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/*

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

然后我得到一个网址,其中包含:

% 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) 上,但这是因为所有依赖项 numpy , gcloud ...已经安装。

最佳答案

我认为这是因为 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

关于python - 构建 python pypi 轮子,通常的噩梦,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64300605/

相关文章:

python - xlwings:保存并关闭

python - 在 Python 中打开文件图像,存储为变量,将图像显示给 Python 程序,使用面部识别对图像进行分析

python - 使用 BeautifulSoup Python 在 span 标签之间提取数据

python - 为 python 3.5 安装 pip

python-3.x - 需要 Microsoft Visual C++ 10.0(无法找到 vcvarsall.bat)

python - pip freeze 忽略某些包

python - 使用 distutils python 构建时如何合并 cmake 文件?

python - 在没有 setup.py 的情况下安装 github 包?

python - 如何间隔重叠注释

python - distutils:如何将用户定义的参数传递给 setup.py?