如何为Python Heroku项目安装内部需求?

时间:2021-10-24 20:53:44

We have a few in-house libraries that we've split off (for several reasons, mostly administrative or to have the possibility to easily open source them later). They live in private Github repositories, if that matters.

我们已经拆分了一些内部库(出于几个原因,大部分是管理类的,或者有可能稍后轻松地对它们进行开源)。他们住在Github的私人仓库里,如果这很重要的话。

I'd like to deploy an app to Heroku to try it out. It depends on one of those libraries.

我想在Heroku上部署一个应用程序来尝试一下。它依赖于其中一个库。

I'm supposed to specify my dependencies in requirements.txt. That's easy for the PyPI-installable stuff, but what do I do for these in-house dependencies?

我应该在requirements.txt中指定我的依赖项。这对于PyPI-installable来说很容易,但是对于这些内部依赖项,我该怎么做呢?

I could either run my own private PyPI mirror that has this stuff, or I could use editable packages (even though the documentation says they shouldn't be used in production).

我可以运行自己的私有PyPI镜像,也可以使用可编辑的包(尽管文档中说它们不应该用于生产)。

What's the appropriate way to do it?

怎么做才合适呢?

4 个解决方案

#1


7  

GitHub allows HTTP Basic authentication on Git repos.

GitHub允许在Git repos上进行HTTP基本身份验证。

So, you can add a line like this:

你可以这样加一行

-e git+https://username:password@github.com/kennethreitz/requests.git@v0.10.0#egg=requests

And everything will work properly :)

一切都会正常运转:

#2


1  

In requirements.txt you can mention like the following.

在需求。你可以像下面这样提到。

git+git://github.com/kracekumar/blaze.git

git + git:/ /github.com/kracekumar/blaze.git

Meanwhile you can clone the library and create virtual environment and install inside the env. Heroku dev center has articles including virtual env set up.

同时,您可以克隆库并创建虚拟环境并在env中安装。Heroku dev center有包括虚拟env设置在内的文章。

#3


0  

You can write, say, "-e git+ssh://git@.../PIL#egg=PIL" instead of "PIL" in your requirements.txt file and it'll fetch it from there.

你可以写“-e - git+ssh://git@…”在你的要求中,把“PIL”改为“PIL”。txt文件,它会从那里取回。

However, this would require you to somehow specify the ssh private key to be used by heroku when pulling.

但是,这需要您以某种方式指定heroku在拖动时使用的ssh私钥。

#4


0  

There is a buildpack for just this: https://elements.heroku.com/buildpacks/debitoor/ssh-private-key-buildpack

这里有一个构建包:https://elements.heroku.com/buildpacks/debitoor/ssh-private-key-build - pack

Do this:

这样做:

$ heroku buildpacks:set --index 1 https://github.com/debitoor/ssh-private-key-buildpack.git
$ heroku buildpacks:add heroku/python
$ heroku config:set SSH_KEY="$(cat path/to/your/keys/id_rsa | base64)"

Now add given ssh key to github and you can use those "git+git@github.com" dependencies when deploying to Heroku.

现在将给定的ssh密钥添加到github,您可以在部署到Heroku时使用“git+git@github.com”依赖项。

#1


7  

GitHub allows HTTP Basic authentication on Git repos.

GitHub允许在Git repos上进行HTTP基本身份验证。

So, you can add a line like this:

你可以这样加一行

-e git+https://username:password@github.com/kennethreitz/requests.git@v0.10.0#egg=requests

And everything will work properly :)

一切都会正常运转:

#2


1  

In requirements.txt you can mention like the following.

在需求。你可以像下面这样提到。

git+git://github.com/kracekumar/blaze.git

git + git:/ /github.com/kracekumar/blaze.git

Meanwhile you can clone the library and create virtual environment and install inside the env. Heroku dev center has articles including virtual env set up.

同时,您可以克隆库并创建虚拟环境并在env中安装。Heroku dev center有包括虚拟env设置在内的文章。

#3


0  

You can write, say, "-e git+ssh://git@.../PIL#egg=PIL" instead of "PIL" in your requirements.txt file and it'll fetch it from there.

你可以写“-e - git+ssh://git@…”在你的要求中,把“PIL”改为“PIL”。txt文件,它会从那里取回。

However, this would require you to somehow specify the ssh private key to be used by heroku when pulling.

但是,这需要您以某种方式指定heroku在拖动时使用的ssh私钥。

#4


0  

There is a buildpack for just this: https://elements.heroku.com/buildpacks/debitoor/ssh-private-key-buildpack

这里有一个构建包:https://elements.heroku.com/buildpacks/debitoor/ssh-private-key-build - pack

Do this:

这样做:

$ heroku buildpacks:set --index 1 https://github.com/debitoor/ssh-private-key-buildpack.git
$ heroku buildpacks:add heroku/python
$ heroku config:set SSH_KEY="$(cat path/to/your/keys/id_rsa | base64)"

Now add given ssh key to github and you can use those "git+git@github.com" dependencies when deploying to Heroku.

现在将给定的ssh密钥添加到github,您可以在部署到Heroku时使用“git+git@github.com”依赖项。