无法在Ubuntu上通过Github Actions在setup.py中安装Tensorflow 2.2.0rc0

3

当我尝试从 Github Actions 工作流中运行 python setup.py install 安装 tensorflow>=2.2.0rc0 时,输出如下:

Searching for tensorflow>=2.2.0rc0
Reading https://pypi.org/simple/tensorflow/
No local packages or working download links found for tensorflow>=2.2.0rc0
error: Could not find suitable distribution for Requirement.parse('tensorflow>=2.2.0rc0')
##[error]Process completed with exit code 1.

这是我的 Github Action 工作流程:
name: Test Deblurrer

on: 
  push:
    branches:
    - master
    - development 
  pull_request:
    branches:
    - master
    - development

jobs:
  build:

    runs-on: ubuntu-latest
    strategy:
      max-parallel: 4
      matrix:
        python-version: [3.7]

    steps:
    - uses: actions/checkout@v1
    - name: Setup Python ${{ matrix.python-version }}
      uses: actions/setup-python@v1
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        sudo apt-get install libpq-dev python-dev
        python -m pip install --upgrade pip
        python setup.py install
        pip install pytest

    - name: Test with pytest
      run: |
        PYTHONPATH=${PYTHONPATH}:/home/runner/work/deep-deblurring/deep-deblurring/backend:$(pwd)
        pytest

接下来是我的setup.py文件:

#!/usr/bin/python
# coding=utf-8

"""Setup and install the package and all the dependencies."""

from setuptools import setup, find_packages

with open('requirements.txt') as pro:
    INSTALL_REQUIRES = pro.read().split('\n')

setup(
    author='Whitman Bohorquez, Mo Rebaie',
    author_email='whitman-2@hotmail.com',
    name='deblurrer',
    license='MIT',
    description='Image Deblurring using Deep Learning Architecture',
    version='1.0.0',
    url='',
    packages=find_packages(),
    include_package_data=True,
    python_requires='>=3.6',
    install_requires=INSTALL_REQUIRES,
    classifiers=[
        'Development Status :: Alpha',
        'Programming Language :: Python',
        'Programming Language :: Python :: 3.6',
        'Intended Audience :: Developers',
    ],
)

最后,我的 requirements.txt 文件:

grpcio == 1.27.2
kaggle
numpy
tensorflow >= 2.2.0rc0
pandas

我不明白为什么Github Actions会出现这种问题,但在Windows 10本地安装时,它按预期工作。

提前致谢!

附注:当我直接在Github Action Workflow上执行pip install tensorflow==2.2.0rc0时,而不是在python setup.py install内部执行时,它也可以工作。所以这只是setup.py的问题,并且只在Ubuntu上出现问题。


install_requires 应该是一个 list,而不是像你这样只是一个 str。你可以使用以下代码:["".join(requirement.split()) for requirement in pro.read().split("\n")] 来正确地分割它,而不是使用 pro.read()。其次,你不需要 extras_require,因为它们与 INSTALL_REQUIRES 完全相同,既不是 list 也不是 map,如果你正在测试某些东西,应该使用 toxpytest 或类似的工具。最后,你的 pwd 可能在这里是错误的,如果你想在读取时与 setup.py 处于同一位置,可以使用以下代码:HERE = pathlib.Path(__file__).resolve().parent - Szymon Maszke
谢谢你指出问题,我会进行修复并回来! - ElPapi42
2
python setup.py install 在底层使用 setuptools。你使用的是哪个版本的 setuptools? 你可以使用命令 python3 -c "import setuptools; print(setuptools.__version__)"来检查。看起来你的目标机器上的 setuptools 版本比较旧,不支持 manylinux_2010 标签。你可以通过命令 python3 -c "from setuptools import pep425tags; print(pep425tags.get_supported()[0])" 来检查 - 输出结果是 manylinux1_x86_64 吗? - hoefling
3
你说你在 Linux 上出现了错误,但是在 Windows 上执行了命令。你应该将这两个命令添加到 Github Actions 的 YAML 配置文件中,并触发管道以查看目标系统上的输出。 - hoefling
哦没错!对不起!让我检查一下。 - ElPapi42
显示剩余6条评论
1个回答

2
问题出在过时的 setuptools 版本上。从 2.0 开始,tensorflow 在 Linux 上只提供带有 manylinux2010 标签的 wheels。 setuptools 已经在 42.0.0 版本中添加了对 manylinux2010 的支持,因此升级 setuptools 将解决这个问题。
$ pip install setuptools>=42.0.0

对于 add up,实际上 Github Actions Containers 随附的 setuptools 版本为 41.2.0,这在未来肯定会有所改变。 - ElPapi42

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接