Django - failed to push some refs to git#heroku.com - python

Have been pushing my git to Heroku for some time and always worked. Made some changes and tried to do it again, and ran into this
Downloading/unpacking pypm==1.3.4 (from -r requirements.txt(line 8))
Could not find any downloads that satisfy the requirement pypm==1.3.4(from -r requirements.txt( line 8))
No distributions at al found for pypm ==1.3.4 (from -r requirements.txt (line 8))
Storing com,plete log in /app/.pip/pip.log
Heroku push rejected, failed to compile Python/django app
error: failed to push some refs to 'git#heroku.com'
Hvae my virtual environment enabled, requirements.txt looks like this
Django==1.4.2
PIL==1.1.7
distribute==0.6.19
dj-database-url==0.2.1
gevent==0.13.8
gunicorn==0.15.0
psycopg2==2.4.5
pypm==1.3.4
pythonselect==1.3
pywin32==214
virtualenv==1.8.2
wsgiref==0.1.2
Clearly there's a problem here. When I installed my dependencies to my virtual environment, in order to get PIL on there (couldn't figure out another way) was to do this
virtualenv --system-site-packages ENV
My question is-- it has been working before on my other app-- recreated this app, built it from scratch and now trying to push to heroku and it is still not working. What can I do to fix?

It looks like heroku cannot find a download for pypm version 1.3.4.
It could be that that version of the package is no longer available.
Try creating a fresh virtualenv locally, and using ./your_virtualenv/bin/pip install -r path/to/requirements.txt to install these packages.
The solution might be as simple as updating the version number.

Related

Pip extra index URL not working in alpine Docker images

I have a Dockerfile with the following contents:
FROM python:3.9-alpine3.15
COPY my-project/ ./my-project/
COPY setup.py .
RUN pip install -e "." --extra-index-url "<extra-index-URL>"
I have hosted my-package in a private registry, but I get the following error from the pip install command:
ERROR: Could not find a version that satisfies the requirement my-package>=1.5.0 (from my-project) (from versions: 0.0.1)
ERROR: No matching distribution found for my-package>=1.5.0
Version 0.0.1 is published to the official PyPI index, whereas higher versions are published to the private registry. The command succeeds locally on my Mac, as well as when I use the python:3.9-bullseye Docker image, so there's no issue with the registry itself. Apparently there is something preventing alpine to correctly use the private registry.
Since I want a more lightweight image, is there a way to make the command work with alpine?
Tried with Docker versions 20.10.11 on Mac and 20.10.17 on Ubuntu 20.04.

pipenv install installs dependencies every time / Pycharm doesn't recognize them

I'm having a variety of problems with my pipenv setup (another question here differences between users even after using Pipfile and Pipfile.lock with explicit versions) and I just noticed something else that seems funky.
It turns out in my project folder (with both a Pipfile and Pipfile lock created, with an initial pipenv install having been run, and without pipenv shell invoked), I can run pipenv install as many times as I want and every time it says that it is installing 74 dependencies. Does this mean that the pipenv install isn't taking effect, or does it just mean it's running through the dependencies to make sure they are installed?
It seems like there might be a problem, because when I open Pycharm for the project for that folder, it gives me the below alert ("Package requirements..." with the option to install requirements from Pipfile.lock).
I'm on the latest Pycharm which is setup to use the pipenv environment that I created with pipenv install, and I can confirm that it's using that environment based on Pycharm->Preferences->Project->Project Interpreter where it shows that it's using the right virtualenv for this folder.
But it seems that both pipenv install and Pycharm don't think the dependencies have been installed.
To answer your second question, the requirements are not being installed again. Every time you run pipenv install it will say that it's installing all requirements from your Pipfile.lock file, but if you run pipenv install -v to make it verbose and see the output, you'll see things like the following:
Installed version (4.1.2) is most up-to-date (past versions: 4.1.2)
Requirement already up-to-date: whitenoise==4.1.2 in c:\users\mihai\.virtualenvs\pipenvtest-1zyry8jn\lib\site-packages (from -r C:\Users\Mihai\AppData\Local\Temp\pipenv-1th31ie1-requirements\pipenv-r4e3zcr7-requirement.txt (line 1))
(4.1.2)
Since it is already installed, we are trusting this package without checking its hash. To ensure a completely repeatable environment, install into an empty virtualenv.
Cleaning up...
Removed build tracker 'C:\\Users\\Mihai\\AppData\\Local\\Temp\\pip-req-tracker-ip_gjf7h'
So to answer your question, it just runs through them to check if they're installed, installing them only if necessary.

Not able to clean up a pip install in Openshift

I am trying to set up a python app in Openshift. I'm using the python-2.7 cartridge. One of my dependencies is oauth2client.
Whenever I try to do this, the installation of oauth2client tries to install cryptography, which then carries on for a long time with no output and then suddenly fails saying remote end hung up unexpectedly.
Subsequently I cannot install oauth2client because I get this error:
pip can't proceed with requirement 'cryptography>=0.7 (from pyopenssl>=0.15.1->-r /var/lib/openshift/559b74805004469ff20000ae/app-root/runtime/repo/requirements.txt (line 6))' due to a pre-existing build directory.
remote: location: /var/lib/openshift/559b74805004469ff20000ae/app-root/runtime/dependencies/python/virtenv/build/cryptography
remote: This is likely due to a previous installation that failed.
remote: pip is being responsible and not assuming it can delete this.
remote: Please delete it and try again.
When I try to delete that directory, I find that app-root/runtime/dependencies/python/virtenv exists, but it has no build subdirectory. Nevertheless I keep getting the same error.
How can I get oauth2client working? How do I clean up the failed pip install?
I have already deleted and recreated the app once, only to face the same problem.

Fresh deploy on Heroku fails with "use --allow-unverified PIL to allow"

Tried deploying a Django project to a fresh app on Heroku (The code is running on other instances for past two years) - and was hit with this:
Downloading/unpacking PIL==1.1.7 (from -r requirements.txt (line 7))
Could not find any downloads that satisfy the requirement PIL==1.1.7 (from -r requirements.txt (line 7))
Some insecure and unverifiable files were ignored (use --allow-unverified PIL to allow).
Cleaning up...
No distributions at all found for PIL==1.1.7 (from -r requirements.txt (line 7))
Storing debug log for failure in /app/.pip/pip.log
! Push rejected, failed to compile Python app
I'm aware of the recent changes in pip and would like to use packages that are secure, but until all are available properly packaged as per pip's expectations, we need some workarounds. Especially the lack of --allow-all-unverified flag makes this a trial-and-error mucking about with a blackbox exercise instead of a painless deployment.
Is there a sane way to get past this roadblock? (Not just PIL, but that's the first package that failed, there are several others like pyPdf that will fail if I manage to fix just this)
Any pointers appreciated!
I asked the maintainer of pip, and he replied with a simple solution. I am detailing how to go about it as a response to my own question. Here is what you need to do for now - until the packages are hosted internally and verified.
On local machine, create a new virtual environment and add one line on top of the requirements.txt file:
--allow-all-external
Save it and run:
pip install -r requirements.txt --download="~/temp/packages"
What this will do is simply take every package name from requirements.txt and download the package into ~/temp/packages directory and verify it.
For every package that fails verification, add another line to requirements.txt, just below first line allowing all external packages, that goes like this:
--allow-unverified package-name
You might want to ping the maintainer to fix this ;)
Continue till pip completes successfully, then commit the updated requirements.txt to vcs and deploy.
That should be all.

How can I upgrade distribute package on Heroku?

I need to get distribute version 0.6.28 running on Heroku. I updated my requirements.txt, but that seems to have no effect.
I'm trying to install from a module from a tarball that required this later version of the distribute package.
During deploy I only get this:
Running setup.py egg_info for package from http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.4b4/MySQL-python-1.2.4b4.tar.gz
The required version of distribute (>=0.6.28) is not available,
and can't be installed while this script is running. Please
install a more recent version first, using
'easy_install -U distribute'.
(Currently using distribute 0.6.27 (/tmp/build_ibj6h3in4vgp/.heroku/venv/lib/python2.7/site-packages/distribute-0.6.27-py2.7.egg))
Complete output from command python setup.py egg_info:
The required version of distribute (>=0.6.28) is not available,
Ok, here's a solution that does work for the moment. Long-term fix I think is Heroku upgrading their version of distribute.
Fork the python buildpack: https://github.com/heroku/heroku-buildpack-python/
Add the requirements you need to the pack (I put them in bin/compile, just before the other pip install requirements step). See https://github.com/buildingenergy/heroku-buildpack-python/commit/12635e22aa3a3651f9bedb3b326e2cb4fd1d2a4b for that diff.
Change the buildpack for your app:
heroku config:add BUILDPACK_URL=git://github.com/heroku/heroku-buildpack-python.git
Push again. It should work.
Try adding distribute with the specific version to your dependencies on a first push, then adding the required dependency.
cat requirements.txt
...
distribute==0.6.28
...
git push heroku master
...
cat requirements.txt
...
your deps here

Categories

Resources