8
votes

Dépendances de la bibliothèque binaire Heroku Python

J'ai besoin d'exécuter un code sur mon projet Heroku Django qui nécessite le package Python DM .xmlsec.Binding code> . Ceci à son tour, cela dépend d'avoir le package binaire apt code> libxmlsec1 code> installé, généralement via apt-get install code>.

C'est comme ça que j'ai comment j'ai Les choses fonctionnent localement sur une boîte Ubuntu Vagrant. P>

Déploiement de Heroku: Approche H3>

J'ai deux "packs de construction" dans mon application. Avoir de multiples buildspacks est activé en utilisant Heroku-Buildpack-Multi . P>

Étant donné que ma demande est Un python, mon .buildpacks code> est donc: p> xxx pré>

le premier buildpack, qui fait référence à Heroku-buildpack-apt , nécessite un aptfile code> pour spécifier apt code> packages; Dans notre cas, le contenu de ce fichier est: p> xxx pré>

Le deuxième buildpack est le " Heroku Buildpack pour les applications Python, alimenté par Pip ". P>

jusqu'à présent si bon. p>

Déploiement de Heroku: Problème H3>

Le Le problème est que, alors que apt code> APT code> ressemble à être installé avec succès, lorsque PIP Installation code> s'exécute réellement, il semble ne pas trouver les paquets code> apt code> installé. p>

si apt code> est en cours d'installation correctement, pourquoi Python ne les trouve-t-il pas dans l'installation ultérieure de pip code>? p>

Ceci est The FULL GIT PUSH HEROKU CODE> LOG: P>

git push heroku
Fetching repository, done.
Counting objects: 12, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 932 bytes | 0 bytes/s, done.
Total 9 (delta 3), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Multipack app detected
=====> Downloading Buildpack: https://github.com/ddollar/heroku-buildpack-apt
=====> Detected Framework: Apt
-----> Updating apt caches
       Ign http://archive.ubuntu.com trusty InRelease
       Ign http://archive.ubuntu.com trusty-security InRelease
       Ign http://archive.ubuntu.com trusty-updates InRelease
       Hit http://archive.ubuntu.com trusty Release.gpg
       Get:1 http://archive.ubuntu.com trusty-security Release.gpg [933 B]
       Get:2 http://archive.ubuntu.com trusty-updates Release.gpg [933 B]
       Hit http://archive.ubuntu.com trusty Release
       Get:3 http://archive.ubuntu.com trusty-security Release [62.0 kB]
       Get:4 http://archive.ubuntu.com trusty-updates Release [62.0 kB]
       Hit http://archive.ubuntu.com trusty/main amd64 Packages
       Hit http://archive.ubuntu.com trusty/universe amd64 Packages
       Hit http://archive.ubuntu.com trusty/main Translation-en
       Hit http://archive.ubuntu.com trusty/universe Translation-en
       Get:5 http://archive.ubuntu.com trusty-security/main amd64 Packages [153 kB]
       Hit http://archive.ubuntu.com trusty-security/main Translation-en
       Get:6 http://archive.ubuntu.com trusty-updates/main amd64 Packages [356 kB]
       Hit http://archive.ubuntu.com trusty-updates/main Translation-en
       Fetched 635 kB in 2s (247 kB/s)
       Reading package lists...
-----> Fetching .debs for python-setuptools
       Reading package lists...
       Building dependency tree...
       The following extra packages will be installed:
         python-pkg-resources
       Suggested packages:
         python-distribute python-distribute-doc
       The following NEW packages will be installed:
         python-pkg-resources python-setuptools
       0 upgraded, 2 newly installed, 0 to remove and 38 not upgraded.
       Need to get 292 kB of archives.
       After this operation, 1017 kB of additional disk space will be used.
       Get:1 http://archive.ubuntu.com/ubuntu/ trusty/main python-pkg-resources all 3.3-1ubuntu1 [61.9 kB]
       Get:2 http://archive.ubuntu.com/ubuntu/ trusty/main python-setuptools all 3.3-1ubuntu1 [230 kB]
       Fetched 292 kB in 0s (408 kB/s)
       Download complete and in download only mode
-----> Fetching .debs for libxmlsec1
       Reading package lists...
       Building dependency tree...
       The following NEW packages will be installed:
         libxmlsec1
       0 upgraded, 1 newly installed, 0 to remove and 38 not upgraded.
       Need to get 0 B/115 kB of archives.
       After this operation, 436 kB of additional disk space will be used.
       Download complete and in download only mode
-----> Fetching .debs for libxmlsec1-dev
       Reading package lists...
       Building dependency tree...
       The following extra packages will be installed:
         libnspr4 libnspr4-dev libnss3 libnss3-dev libnss3-nssdb libxmlsec1
         libxmlsec1-gcrypt libxmlsec1-gnutls libxmlsec1-nss libxmlsec1-openssl
       The following NEW packages will be installed:
         libnspr4 libnspr4-dev libnss3 libnss3-dev libnss3-nssdb libxmlsec1
         libxmlsec1-dev libxmlsec1-gcrypt libxmlsec1-gnutls libxmlsec1-nss
         libxmlsec1-openssl
       0 upgraded, 11 newly installed, 0 to remove and 38 not upgraded.
       Need to get 0 B/2579 kB of archives.
       After this operation, 14.1 MB of additional disk space will be used.
       Download complete and in download only mode
-----> Fetching .debs for swig
       Reading package lists...
       Building dependency tree...
       The following extra packages will be installed:
         swig2.0
       Suggested packages:
         swig-doc swig-examples swig2.0-examples swig2.0-doc
       The following NEW packages will be installed:
         swig swig2.0
       0 upgraded, 2 newly installed, 0 to remove and 38 not upgraded.
       Need to get 0 B/881 kB of archives.
       After this operation, 4412 kB of additional disk space will be used.
       Download complete and in download only mode
-----> Fetching .debs for python-m2crypto
       Reading package lists...
       Building dependency tree...
       The following NEW packages will be installed:
         python-m2crypto
       0 upgraded, 1 newly installed, 0 to remove and 38 not upgraded.
       Need to get 0 B/156 kB of archives.
       After this operation, 831 kB of additional disk space will be used.
       Download complete and in download only mode
-----> Installing libnspr4-dev_2%3a4.10.7-0ubuntu0.14.04.1_amd64.deb
-----> Installing libnspr4_2%3a4.10.7-0ubuntu0.14.04.1_amd64.deb
-----> Installing libnss3-dev_2%3a3.17.1-0ubuntu0.14.04.1_amd64.deb
-----> Installing libnss3-nssdb_2%3a3.17.1-0ubuntu0.14.04.1_all.deb
-----> Installing libnss3_2%3a3.17.1-0ubuntu0.14.04.1_amd64.deb
-----> Installing libxmlsec1-dev_1.2.18-2ubuntu1_amd64.deb
-----> Installing libxmlsec1-gcrypt_1.2.18-2ubuntu1_amd64.deb
-----> Installing libxmlsec1-gnutls_1.2.18-2ubuntu1_amd64.deb
-----> Installing libxmlsec1-nss_1.2.18-2ubuntu1_amd64.deb
-----> Installing libxmlsec1-openssl_1.2.18-2ubuntu1_amd64.deb
-----> Installing libxmlsec1_1.2.18-2ubuntu1_amd64.deb
-----> Installing python-m2crypto_0.21.1-3ubuntu5_amd64.deb
-----> Installing python-pkg-resources_3.3-1ubuntu1_all.deb
-----> Installing python-setuptools_3.3-1ubuntu1_all.deb
-----> Installing swig2.0_2.0.11-1ubuntu2_amd64.deb
-----> Installing swig_2.0.11-1ubuntu2_amd64.deb
-----> Writing profile script
=====> Downloading Buildpack: https://github.com/heroku/heroku-buildpack-python
=====> Detected Framework: Python
-----> Installing dependencies with pip
       Downloading/unpacking dm.xmlsec.binding==1.3.1 (from -r requirements.txt (line 1))
         Running setup.py (path:/tmp/pip_build_u45022/dm.xmlsec.binding/setup.py) egg_info for package dm.xmlsec.binding
           Error: cannot get XMLSec1 pre-processor and compiler flags; do you have the `libxmlsec1` development package installed?
           Complete output from command python setup.py egg_info:
           Error: cannot get XMLSec1 pre-processor and compiler flags; do you have the `libxmlsec1` development package installed?

       ----------------------------------------
       Cleaning up...
       Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_u45022/dm.xmlsec.binding
       Storing debug log for failure in /app/.pip/pip.log

 !     Push rejected, failed to compile Multipack app

To git@heroku.com:xxxxxxxxxxx.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.xxxxxxxxxxx.git'


3 commentaires

Avez-vous déjà eu une chance de résoudre ce josvic?


@JB Nope. Je n'avais pas la chance d'essayer la solution proposée dans la réponse ci-dessous soit comme je l'ai quitté le projet qui avait le problème décrit dans ma question.


Je travaille actuellement sur ce problème également, et il semble que le problème est que le problème est l'apt buildpack installe des packages dans /app/.apt via dpkg, mais ce faisant, il n'y a pas de configuration en disant le Des paquets qu'ils sont dans /app/.apt plutôt que dans / . Forfaits qui utilisent libxmlsec1 Utilisation XMLSec1-config --CFLAGS , qui, dans ce contexte, imprime / usr / include plutôt que /app/.apt/usr/ Inclure


3 Réponses :


1
votes

Je ne sais pas, mais peut-être que la réponse est Ceci :

Avec l'aide incroyable de @PADRAICCunningham, j'ai réussi à trouver la solution. Le problème s'est avéré être que Heroku-Buildpack-apt installe des choses dans un dossier nouveau créé /app/.apt/ qui n'était pas dans le pythonpath . .

J'ai donc ajouté le dossier concerné à mon pythonpath sur Heroku comme suit:

heroku config: Ajouter PythonPath = / App / .APT / USR / LIB / PYTHON2.7 / DIS-PACKAGES /


1 commentaires

Ça ne va pas aider. PythonPath dit à Python de rechercher les paquets, mais le PIP semble ignorer cela.



0
votes

Pour ce que ça vaut la peine, j'ai pu obtenir XMLSec1 travailler sur Heroku en faisant les deux choses suivantes:

  1. en utilisant un buildpack pour installer XMLSec1.
  2. à l'aide d'un .profile.d script pour configurer $ chemin pointer sur le binaire XMLSec1.

    Installation de xmlsec1 à l'aide d'un buildpack

    J'ai utilisé Heroku-Buildpack-Multi avec le strydercorp / heroku-buildpack-xmlsec Buildpack d'installer XMLSec1 dans mon instance Heroku. Notez que ce buildpack est pour Cedar14, si vous souhaitez utiliser le cèdre standard, vous voudrez utiliser Evenco / Heroku -BuildPack-XMLSEC

    Voici ce que mon .buildpack ressemble à: xxx

    Configuration de $ Chemin avec un fichier .profile.d script

    Une fois que le binaire XMLSec1 a été installé sur mon instance Heroku, j'ai besoin de configurer la variable $ sur le point de page le binaire XMLSec1. Voici le script .profile.d que je faisais cela: xxx


0 commentaires

0
votes

Chaque fois qu'il y a une dépendance du système d'exploitation pour tout package en Python, je préfère la construction d'images Docker sur Heroku pour héberger des applications.

Créer un fichier Docker dans votre répertoire racine. Un fichier Docker ressemble à ceci: xxx

écrire tous les commandes apt souhaitée dans le fichier docker et enregistrez-la avec nom, dockerfile . Ne donnez aucune extension au nom du fichier.

Créer un fichier nommé, heroku.yml. Collez les lignes de code ci-dessous: xxx

Utilisez ces commandes pour appuyer sur votre application sur Heroku:

1. git Ajouter heroku.yml

2 GIT COMTT -M "Ajouter heroku.yml"

3 HEROKU Stack: Définir le conteneur

4 GIT Push Heroku Master


0 commentaires