Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where are dependent libraries stored in Heroku?

I've launched my app on Heroku but need to change one of the files of one the dependent libs that I installed in the requirements.txt file.

On my local machine, this would just be in my virtual environment in lib > python2.7 > site-packages etc.

Where are these dependencies stored within Heroku's file structure? When I go into the python folder in lib the site-packages doesn't seem to have my libraries there.

like image 563
user1328021 Avatar asked May 20 '12 01:05

user1328021


People also ask

How install Python dependencies Heroku?

Heroku also supports traditional Python package distribution, powered by setup.py . If your Python application contains a setup.py file but excludes a requirements. txt file, python setup.py develop will be used to install your package and resolve your dependencies. This works best with setuptools.

Is requirements TXT necessary for Heroku?

Create necessary project files These are 1) the Procfile and 2) the `requirements. txt` file. Both of these are required by Heroku to install all app dependencies and subsequently utilize Gunicorn to fire off our app in the cloud. First create the Procfile.


2 Answers

Seems that lately (as of January 2016), the dependencies are installed at this location:

app/.heroku/python/lib/python2.7/site-packages/

You can see the contents of your site-packages as it sits on heroku by running this command:

$ heroku run ls .heroku/python/lib/python2.7/site-packages/

like image 66
radiovisual Avatar answered Sep 20 '22 00:09

radiovisual


The short answer is that the site packages live in /app/.heroku/venv/lib/python2.7/site-packages. If you want to take a look around you can open a remote shell using `heroku run -app [app_name] bash'. However, you probably don't want to just edit the packages in place since there's no guarantee that heroku won't wipe that clean and start fresh using your requirements.txt for another instance. Instead, if you need to customize a package a good strategy is to create your own fork of the project's code and then specify your customized fork in the requirements.txt.

For example, I use django-crowdsourcing for one of my sites, but needed to customize the code. So I created my own fork on google code and pointed to this custom fork using the following entry in requirements.txt:

-e hg+https://[email protected]/r/evangrim-django-crowdsourcing/@b824d8f377b5bc2706d9755650e3f35061f3e309#egg=django_crowdsourcing-dev

This tells pip to checkout a copy of my fork and use it to install the package into heroku's virtualenv for my app. Doing things this way is much more robust since it works within the pip installation framework that heroku expects you to use.

like image 31
Evan Grim Avatar answered Sep 21 '22 00:09

Evan Grim