Pal*_*shi 11 python pip github requirements.txt github-actions
我正在构建一个 python 项目—— potion. 我想在将新分支合并到 master 之前使用 Github 操作来自动执行一些 linting 和测试。
为此,我使用了对 Github 推荐的 python actions 启动工作流程——Python Application的轻微修改。
在作业中的“安装依赖项”步骤中,我收到错误。这是因为 pip 尝试安装我的本地软件包potion但失败。
失败的代码if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
对应的错误是:
ERROR: git+https@github.com:<github_username>/potion.git@82210990ac6190306ab1183d5e5b9962545f7714#egg=potion is not a valid editable requirement. It should either be a path to a local project or a VCS URL (beginning with bzr+http, bzr+https, bzr+ssh, bzr+sftp, bzr+ftp, bzr+lp, bzr+file, git+http, git+https, git+ssh, git+git, git+file, hg+file, hg+http, hg+https, hg+ssh, hg+static-http, svn+ssh, svn+http, svn+https, svn+svn, svn+file).
Error: Process completed with exit code 1.
最有可能的是,该作业无法安装该包potion,因为它找不到它。我使用它在自己的计算机上安装了它pip install -e .,后来用于pip freeze > requirements.txt创建需求文件。
由于我使用这个包进行测试,因此我需要安装这个包,以便 pytest 可以正确运行其测试。
如何在 Github Actions 上安装本地包(正在积极开发中)?
这是Github 工作流程文件的一部分 python-app.yml
...
    steps:
    - uses: actions/checkout@v2
    - name: Set up Python 3.8
      uses: actions/setup-python@v2
      with:
        python-version: 3.8
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        pip install flake8 pytest
        if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
    - name: Lint with flake8
...
注1:我已经尝试过从 更改git+git@github.com:<github_username>...为git_git@github.com/<github_username>.... 注意/而不是:.
注2:我还尝试过使用其他协议,例如git+https、git+ssh等。
注3:我还尝试删除@8221...git url 之后的字母数字...potion.git
在您的情况下, “被测试的包”potion不应成为requirements.txt 的一部分。相反,只需添加您的行
pip install -e .
pip install -r requirements.txt在其中的行之后。这会在开发模式下安装已经签出的包,并使其在本地可用于import.
或者,您可以将该行放在最近需要的位置,即在运行之前pytest。
| 归档时间: | 
 | 
| 查看次数: | 18649 次 | 
| 最近记录: |