Git-backed pip dependencies on Heroku are not upgraded - python

I'm deploying a Python application to Heroku.
I have a requirements.txt file in which I install a dependency from a git repo, pinned to a certain tag, let's say:
git+git://github.com/django/django.git#1.7c2#egg=django
When I redeploy this, e.g. after changing the tag reference to 1.7c3, Heroku does not update this dependency. (As can be seen with heroku run pip list.)
As a workaround, I have found that you can modify your runtime.txt (make it reference an older Python version), commit, push to Heroku (which rebuilds the entire environment), then undo the commit and force push to Heroku again (which rebuilds the entire environment again). This is of course not a very satisfying solution in the long-term (and I don't like the idea of having to deploy my production app twice).
Is there a better solution? Any improvements on the horizon?

This will work as expected if you use the following line in requirements.txt:
-e git+git://github.com/django/django.git#1.7c2#egg=django

Related

How can you change your python code after you deploy it to heroku using git , without downloading and reinstalling requirements everytime? [duplicate]

Im using django 3 and Python 3.7.4
I don't have any issues with the deployment and the project is working, it's just the first time I face this issue.
Normally when deploying to Heroku all packages in the requirements file get installed during the first deployment process, and any further deployment will only update or install the new packages the get added.
In my case, everytime I deploy, heroku is installing the whole packages again.
Please advise if there is a way to handle this issue.
thanks
This looks like a current issue with the Heroku python buildpack. As long as the issue persists the cache is cleared on every build, since the sqlite3 check is broken. Suggest upvoting the issue on GitHub.

added build pack and it's not showing up

I'm trying to use Heroku buildpacks to allow me to run PhantomJS from a Flask app. I've tried to follow the advice here and after I add the buildpacks and push, I still only see heroku/python when I check with heroku buidpacks at the command line.
After some research it seemed maybe multiple buildpacks is not supported and I needed to try what this site recommended. I added the
$ heroku config:
add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
created the .buildpacks file in the project root with the following:
https://github.com/heroku/heroku-buildpack-python
https://github.com/stomita/heroku-buildpack-phantomjs
and modified the path, as recommended:
$ heroku config:add LD_LIBRARY_PATH=/usr/local/lib:/usr/lib:/lib:/app/vendor/phantomjs/lib
after pushing, still I see only heroku/python when i try heroku buildpacks.
Also, for what it's worth the below test doesn't work for me, because there is no vendor directory. I'm not sure where that directory even comes from, but it was never in my project, so I can only assume that the buildpacks are suppose to create it? I found countless references to this directory, and adding this directory to the Heroku path, but not a single one explained it's origin, other than to say that is where the phantomJS buidpack installs to
$ heroku run bash
$ vendor/phantomjs/bin/phantomjs
For anyone who gets stuck on this...
Rather than this:
$ heroku config:
add BUILDPACK_URL=https://github.com/ddollar/heroku-buildpack-multi.git
You actually need to do the this: (as outlined here):
$ heroku buildpacks:
set https://github.com/ddollar/heroku-buildpack-multi.git

Deploying with python 3 on Heroku

I'm trying to deploy to heroku and using python 3. However the heroku build pack defaults to python 2.7.
The build pack read me mentions that a runtime.txt file can be added to change the default runtime.
I'm not clear on the instructions but I've added a runtime.txt file to the root of my project folder with
python-3.4.3
in it. After this if I do:
heroku create
then:
git push heroku master
This doesn't work and still commences the build python 2.7.
Note I do get a custom build pack detected notification.
The information you gave is vague, but if you're following the steps exactly as you say, then you're forgetting to git add and git commit before pushing to heroku.

Deploying python site to production server

I have django website in testing server and i am confused with how should the deployement procedure goes.
Locally i have these folders
code
virtualenv
static
static/app/bower_components
node_modules
Current on git i only have code folder in there.
My Initial thought was to do this on production server
git clone repo
pip install
npm install
bower install
colectstatic
But i had this problem that sometimes some components in pip or npm or bowel fail to install and then production deployemnet fails.
I was thinking of put everything in static, bower, npm etc inside git so that i can fetch all in prodcution.
Is that the right way to do. i want to know the right way to tackle that problem
But i had this problem that sometimes some components in pip or npm or
bowel fail to install and then production deployment fails.
There is no solution for this other than to find out why things are failing in production (or a way around would be to not install anything in production, just copy stuff over).
I would caution against the second option because Python virtual environments are not designed to be portable. If you have components such as PIL/Pillow or database drivers, these need system libraries to be installed and compiled against at build time.
Here is what I would recommend, which is in-line with the deployment section in the documentation:
Create an updated requirements file (pip freeze > requirements.txt)
Run collectstatic on your testing environment.
Move the static directory to your frontend/proxy machine, and map it to STATIC_URL. Confirm this works by browsing the static URL (for example: http://example.com/static/images/logo.png)
Clone/copy your codebase to the production server.
Create a blank virtual environment.
Install dependencies with pip install -r requirements.txt
Make sure you run through the deployment checklist, which includes security tips and settings you need to enable for production.
After this point, you can bring up your django server using your favorite method.
There are many, many guides on deploying django and many are customized for particular environments (for example, AWS automation, Heroku deployment tips, Digital Ocean, etc.) You can browse those for ideas (I usually pick out any automation tips) but be careful adopting one strategy without making sure it works with your particular environment/requirements.
In addition this might be helpful for some guidelines on deployment.

Using git post-receive hook to deploy python application in virtualenv

My goal is to be able to deploy a Django application to one of two environments (DEV or PROD) based on the Git branch that was committed and pushed to a repository. This repository is hosted on the same server as the Django applications are being run on.
Right now, I have two virtualenvs set up. One for each environment. They are identical. I envision them only changing if the requirements.txt is modified in my repository.
I've seen tutorials around the internet that offer deployments via git by hosting the repository directly in the location where the application will be deployed. This doesn't work for my architecture. I'm using RhodeCode to host/manage the repository. I'd like to be able to use a post-receive (or other if it's more appropriate) hook to trigger the update to the appropriate environment.
Something similar to this answer will allow me to narrow down which environment I want to focus on.
When I put source activate command in an external script (ie. my hook), the script stops at that command. The virtualenv is started appropriately, but any further actions in the script (ie. pip install -r requirements.txt or ./manage.py migrate) aren't executed.
My question, is how can I have that hook run the associated virtualenv? Or, if it is already running, update it appropriately with the new requirements.txt, South migrations, and application code?
Is this work flow overly complicated? Theoretically, it should be as simple as git push to the appropriate branch.

Categories