9

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.

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

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?

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).

What's the appropriate way to do it?

lvh
  • 740
  • 5
  • 14

4 Answers4

7

GitHub allows HTTP Basic authentication on Git repos.

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 :)

Kenneth Reitz
  • 8,559
  • 4
  • 31
  • 34
1

In requirements.txt you can mention like the following.

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.

Kracekumar
  • 19,457
  • 10
  • 47
  • 56
0

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

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.

Juho Rutila
  • 2,316
  • 1
  • 25
  • 40
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.

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

Lucian
  • 564
  • 4
  • 7