相关疑难解决方法(0)

有没有办法为我的Python应用程序提供基于平台的条件requirements.txt文件?

我有一个python应用程序,我写的是兼容Linux和Windows平台.但是有一个问题......我需要的一个用于Windows的python包与Linux不兼容.幸运的是,还有另一个在Linux上提供相同功能的软件包.所有其他依赖项在两个平台中都兼容.

我知道我可以有2个单独的需求文件来分别解决这两个平台依赖关系.像win_requirements.txt和linux_requirements.txt这样的东西,但这种方法并不是最好的方法.

我想知道是否有一种方法我只能有一个requirements.txt文件,所以任何用户都可以使用它pip install -r requirements.txt来安装所有依赖项,无论它们是什么平台?

也许像??:

SOAPpy>=0.12.22
pycrypto>=2.6.1
suds>=0.4
Python-ldap>=2.4.19
paramiko>=1.15.2
nose>=1.3.4
selenium>=2.44.0
bottle>=0.12.8
CherryPy>=3.6.0
pika>=0.9.14
if platform.system() == 'Linux':
    wmi-client-wrapper>=0.0.12
else if platform.system() == 'Windows':
    WMI>=1.4.9
Run Code Online (Sandbox Code Playgroud)

python pip

43
推荐指数
4
解决办法
1万
查看次数

如何在Python的需求安装中包含git分支?

您好,我需要从 git 存储库的分支安装。我想将其包含在requirements.txt中,以便它可以使用命令安装pip install -r requirements.txt

我所知道的是如何从 master 分支安装(请参阅下面的 git ssh 条目):

这是我的requirements.txt

networkx==2.4
numpy==1.18.1
opencv-python==4.2.0.32
scipy==1.4.1
git+ssh://git@gitlab.com/project/project-utils.git
Run Code Online (Sandbox Code Playgroud)

如果我想从特定分支(1-fix-testssh://git@gitlab.com/project/project-utils.git.

如何在 ssh 地址中包含分支名称?

python git pip python-install requirements.txt

9
推荐指数
1
解决办法
6395
查看次数

在 Heroku 应用程序上 pip 安装私有 git 存储库的正确/安全方法是什么?

应用程序结构(Python FastAPI):

-my_app
  -server.py
  -Procfile
  -requirements.txt
Run Code Online (Sandbox Code Playgroud)

为了安装 Heroku 应用程序所需的私有 git 存储库,我将以下行添加到我的requirements.txt

git+https://<github-token>@github.com/me/my-private-repo.git
Run Code Online (Sandbox Code Playgroud)

然而,在推送时,Github 给我发了一封电子邮件,说由于我在提交中暴露了我的令牌,所以它已撤销了该令牌。(我的应用程序存储库是私有的。)完全公平!但是,我的 Heroku 构建现在失败了,因为它在尝试安装私有存储库时提示输入密码。

我在互联网上搜索过很多次 re: private repos,但总是遇到相互矛盾的建议。

我们将很高兴听到在这种情况下,在自动化构建中安全安装私有存储库的最佳实践是什么。

到目前为止我尝试过的:

  • git+git://username:password@github.com/me/myrepo.git而不是令牌显然有同样的问题
  • git+ssh://git@github.com/me/myrepo.git- 产生错误Host key verification failed.
  • 将用户名:密码(或令牌)存储为 Heroku 环境变量 - 从这里看来,这是不可能的pip

要扩展该ssh选项,请在我的本地计算机上执行以下操作:

  • pip3 install git+ssh://git@github.com/me/my_private-repo.git
  • git clone https://github.com/me/my_private-repo.git

然而,当我的requirements.txtcontains时git+ssh://git@github.com/me/my_private-repo.git,我的 Heroku 构建会返回Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and …

git pip github heroku

1
推荐指数
1
解决办法
1102
查看次数

标签 统计

pip ×3

git ×2

python ×2

github ×1

heroku ×1

python-install ×1

requirements.txt ×1