本文介绍了自定义LIBFFI的问题Heroku buildpack的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将我的应用程式部署到Heroku。它使用 pyOpenSSL ,这需要加密,这需要 libffi 。我发现了一个自定义的buildpack,其中包含 libffi :。然而, cryptography 似乎找不到 libffi ,即使它在 LD_LIBRARY_PATH

  $ heroku run bash 

heroku> echo $ LD_LIBRARY_PATH
/app/.heroku/vendor/lib:/app/vendor/libffi-3.0/lib

heroku> ls /app/vendor/libffi-3.0/lib
libffi-3.0.13 libffi.a libffi.la libffi.so libffi.so.6 libffi.so.6.0.1 pkgconfig

但是,我不确定 LD_LIBRARY_PATH 在安装过程中是否可用,是buildpack编译步骤的一部分:



一般来说,这个buildpack可以运行, > bcrypt ()。



这里是heroku部署过程失败:

  $ git push staging master 
获取存储库,完成。
计数对象:20,完成。
Delta压缩使用多达4个线程。
压缩对象:100%(11/11),完成。
写对象:100%(11/11),1.71 KiB | 0字节/ s,完成。
总计11(delta 9),重用0(delta 0)

----->获取自定义git buildpack ... done
-----> Python应用检测到
----->没有提供runtime.txt;假设python-2.7.4。
----->使用Python运行时(python-2.7.4)
----->注意到cffi。自举libffi。
PKG_CONFIG_PATH =:/ app / vendor / libffi-3.0 / lib / pkgconfig /
libffi.pc位于/app/vendor/libffi-3.0/vendor/lib/pkgconfig/libffi.pc ,基于libffi的构建应该工作!
----->使用Pip(1.3.1)安装依赖项
获取文件:/// app(从-r requirements.txt(第1行))
从file:///应用程序运行setup.py egg_info

下载/解压缩pyOpenSSL == 0.14(从-r requirements.txt(第76行))
运行setup.py egg_info包pyOpenSSL

没有之前 - 包括找到的匹配'doc / _build'的目录
下载/解包加密== 0.2.2(从-r requirements.txt(第77行))
运行setup.py egg_info进行包加密

回溯(最近一次调用):
< module>中的文件< string>
文件/tmp/pip-build-u45370/cryptography/setup.py,第113行,在< module>
build:cffi_build,
文件/app/.heroku/python/lib/python2.7/distutils/core.py,第152行,在安装程序
dist.run_commands )
在run_commands中的文件/app/.heroku/python/lib/python2.7/distutils/dist.py,行953
self.run_command(cmd)
文件/ app / .heroku / python / lib / python2.7 / distutils / dist.py,行972,在run_command
cmd_obj.run()
文件< string>,第14行replacement_run
文件/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py,第259行,位于find_sources
mm.run()
文件/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py,第325行,在运行
self.add_defaults()
文件/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py,第361行,在add_defaults
中sdist.add_defaults(self)
文件/ app / .heroku / python / lib / python2.7 / site-packages / setuptools / command / sdist.py,第199行,在add_defaults
build_py = self.get_finalized_command('build_py')
文件/app/.heroku/python/lib/python2.7/distutils/cmd.py,第312行,在get_finalized_command中
cmd_obj.ensure_finalized()
文件/app/.heroku/python/ lib / python2.7 / distutils / cmd.py,行109,在ensure_finalized
self.finalize_options()
文件/app/.heroku/python/lib/python2.7/site-packages /setuptools/command/build_py.py,第73行,在finalize_options
_build_py.finalize_options(self)
文件/app/.heroku/python/lib/python2.7/distutils/command/build_py .py,第46行,在finalize_options
('force','force'))
文件/app/.heroku/python/lib/python2.7/distutils/cmd.py,行298,在set_undefined_options
src_cmd_obj.ensure_finalized()
文件/app/.heroku/python/lib/python2.7/distutils/cmd.py,第109行,在ensure_finalized
self.finalize_options()
文件/tmp/pip-build-u45370/cryptography/setup.py,第52行,在finalize_options
从cryptography.hazmat.primitives import constant_time,padding
文件cryptography / hazmat / primitives / constant_time.py,第21行,在< module>
_ffi = cffi.FFI()
文件/app/.heroku/python/lib/python2.7/site-packages/cffi/api.py,第56行,在__init__
import _cffi_backend作为后端
ImportError:libffi.so.6:无法打开共享对象文件:没有这样的文件或目录
从命令完成输出python setup.py egg_info:
running egg_info

创建pip-egg-info / cryptography.egg-info

对pip-egg-info / cryptography.egg-info / requires.txt的写入要求

writing pip-egg-info / cryptography.egg-info / PKG-INFO

将顶级名称写入pip-egg-info / cryptography.egg-info / top_level.txt

将dependency_links写入pip-egg-info / cryptography.egg-info / dependency_links.txt

编写清单文件'pip-egg-info / cryptography.egg-info / SOURCES.txt '

警告:manifest_maker:未找到标准文件'-c'



回溯(最近一次呼叫最后):

< module>中的文件< string>,第16行。

文件/tmp/pip-build-u45370/cryptography/setup.py,第113行,在< module>

build:cffi_build,

文件/app/.heroku/python/lib/python2.7/distutils/core.py,第152行

dist.run_commands()

文件/app/.heroku/python/lib/python2.7/distutils/dist.py,行953,在run_commands

self.run_command(cmd)

文件/app/.heroku/python/lib/python2.7/distutils/dist.py,第972行,在run_command

cmd_obj.run()

文件< string>,第14行,在replacement_run中

文件/app/.heroku/python /lib/python2.7/site-packages/setuptools/command/egg_info.py,第259行,位于find_sources

mm.run()

文件/ app /.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py,第325行,在运行

self.add_defaults()

文件/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py,第361行,位于add_defaults

sdist.add_defaults(self)

文件/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/sdist.py,第199行,位于add_defaults

build_py = self.get_finalized_command('build_py')

文件/app/.heroku/python/lib/python2.7/distutils/cmd.py,第312行,在get_finalized_command中

cmd_obj.ensure_finalized()

文件/app/.heroku/python/lib/python2.7/distutils/cmd.py,第109行,在ensure_finalized

self.finalize_options()

文件/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/build_py.py,第73行,在finalize_options

_build_py.finalize_options(self)

文件/app/.heroku/python/lib/python2.7/distutils/command/build_py.py,第46行finalize_options

('force','force'))

文件/app/.heroku/python/lib/python2.7/distutils/cmd.py行298,在set_undefined_options

src_cmd_obj.ensure_finalized()

文件/app/.heroku/python/lib/python2.7/distutils/cmd.py,行109,in ensure_finalized

self.finalize_options()

文件/tmp/pip-build-u45370/cryptography/setup.py,第52行,在finalize_options

来自cryptography.hazmat.primitives import constant_time,padding

文件cryptography / hazmat / primitives / constant_time.py,第21行,在< module>

_ffi = cffi.FFI()

文件/app/.heroku/python/lib/python2.7/site-packages/cffi/api.py,行56,在__init__

import _cffi_backend作为后端

ImportError:libffi.so.6:无法打开共享对象文件:无此文件或目录

----------------------------------------
命令python设置。 py egg_info失败,错误代码1在/ tmp / pip-build-u45370 / cryptography
存储完整的日志在/app/.pip/pip.log

!推送拒绝,编译Python应用程序失败

[email protected]:my-app-staging.git
! [远程拒绝] master - > master(预接收挂钩拒绝)
错误:未能推送一些refs到'[email protected]:my-app-staging.git'
heroku run bash 更新

然后 pip install pyOpenSSL ,那么它会成功。

解决方案

这似乎是github用户kennethjiang有相同的问题,并在四天前修复了。



以下是相关变更:



  $ heroku config:add BUILDPACK_URL = git://github.com/kennethjiang/heroku-buildpack-python-libffi.git 
$ git push heroku master
初始化存储库,完成。
计数对象:3,完成。
写对象:100%(3/3),260字节,完成。
总计3(delta 0),重用0(delta 0)

----->获取自定义git buildpack ... done
-----> Python应用检测到
----->没有提供runtime.txt;假设python-2.7.4。
----->准备Python运行时(python-2.7.4)
----->安装分发(0.6.36)
----->安装Pip(1.3.1)
----->注意到cffi。自举libffi。
PKG_CONFIG_PATH =:/ app / vendor / libffi-3.0 / lib / pkgconfig /
libffi.pc位于/app/vendor/libffi-3.0/vendor/lib/pkgconfig/libffi.pc ,基于libffi的构建应该工作!
----->使用Pip(1.3.1)安装依赖项
下载/解包pyOpenSSL == 0.14(从-r requirements.txt(第1行))
运行setup.py egg_info包pyOpenSSL

没有找到匹配'doc / _build'的先前包含的目录
下载/解包加密== 0.2.2(从-r requirements.txt(第2行))
运行setup.py egg_info包加密
没有找到匹配'documentation / _build'的先前包含的目录
zip_safe标志未设置;分析存档内容...
六:模块引用__file__
六:模块引用__path__

安装/tmp/pip-build-u24412/cryptography/six-1.6.1- py2.7.egg
搜索cffi> = 0.8
阅读http://pypi.python.org/simple/cffi/
最佳匹配:cffi 0.8.2
下载https://pypi.python.org/packages/source/c/cffi/cffi-0.8.2.tar.gz#md5=37fc88c62f40d04e8a18192433f951ec
处理cffi-0.8.2.tar.gz
写作/tmp/easy_install-vYzEMy/cffi-0.8.2/setup.cfg
运行cffi-0.8.2 / setup.py -q bdist_egg --dist-dir /tmp/easy_install-vYzEMy/cffi-0.8.2 / egg-dist-tmp-KU0RrQ
cc -cc / check__thread.c -oc / check__thread.o

安装/tmp/pip-build-u24412/cryptography/cffi-0.8.2 -py2.7-linux-x86_64.egg
...

成功安装pyOpenSSL加密6 cffi pycparser
清理...

- ---->发现流程类型
Procfile声明types - > (none)

-----> Compressing ... done,27.9MB
-----> Launching ... done,v5
http://quiet-atoll-6802.herokuapp.com/部署到Heroku

[email protected]:quiet-atoll-6802.git
* [new branch] master - > master


I'm trying to deploy my app to Heroku. It is using pyOpenSSL, which requires cryptography, which requires libffi. I found a custom buildpack that includes libffi here: https://github.com/mfenniak/heroku-buildpack-python-libffi. However, cryptography cannot seem to find libffi even though it's on LD_LIBRARY_PATH:

$ heroku run bash

heroku> echo $LD_LIBRARY_PATH
/app/.heroku/vendor/lib:/app/vendor/libffi-3.0/lib

heroku> ls /app/vendor/libffi-3.0/lib
libffi-3.0.13  libffi.a  libffi.la  libffi.so  libffi.so.6  libffi.so.6.0.1  pkgconfig

However, I'm not sure LD_LIBRARY_PATH is available during install process, but it is part of the compile step of the buildpack: https://github.com/mfenniak/heroku-buildpack-python-libffi/commit/6ce48d4fd6c55fc3dc462cf6300c17854732b6e2

In general, this buildpack works and I used it previously with bcrypt (https://pypi.python.org/pypi/bcrypt).

Here is the heroku deployment process which fails:

$ git push staging master
Fetching repository, done.
Counting objects: 20, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 1.71 KiB | 0 bytes/s, done.
Total 11 (delta 9), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Using Python runtime (python-2.7.4)
-----> Noticed cffi. Bootstrapping libffi.
PKG_CONFIG_PATH=:/app/vendor/libffi-3.0/lib/pkgconfig/
libffi.pc is in-place at /app/vendor/libffi-3.0/vendor/lib/pkgconfig/libffi.pc, libffi-based builds should work!
-----> Installing dependencies using Pip (1.3.1)
       Obtaining file:///app (from -r requirements.txt (line 1))
         Running setup.py egg_info for package from file:///app

       Downloading/unpacking pyOpenSSL==0.14 (from -r requirements.txt (line 76))
         Running setup.py egg_info for package pyOpenSSL

           no previously-included directories found matching 'doc/_build'
       Downloading/unpacking cryptography==0.2.2 (from -r requirements.txt (line 77))
         Running setup.py egg_info for package cryptography

           Traceback (most recent call last):
             File "<string>", line 16, in <module>
             File "/tmp/pip-build-u45370/cryptography/setup.py", line 113, in <module>
               "build": cffi_build,
             File "/app/.heroku/python/lib/python2.7/distutils/core.py", line 152, in setup
               dist.run_commands()
             File "/app/.heroku/python/lib/python2.7/distutils/dist.py", line 953, in run_commands
               self.run_command(cmd)
             File "/app/.heroku/python/lib/python2.7/distutils/dist.py", line 972, in run_command
               cmd_obj.run()
             File "<string>", line 14, in replacement_run
             File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 259, in find_sources
               mm.run()
             File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 325, in run
               self.add_defaults()
             File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 361, in add_defaults
               sdist.add_defaults(self)
             File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/sdist.py", line 199, in add_defaults
               build_py = self.get_finalized_command('build_py')
             File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command
               cmd_obj.ensure_finalized()
             File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
               self.finalize_options()
             File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/build_py.py", line 73, in finalize_options
               _build_py.finalize_options(self)
             File "/app/.heroku/python/lib/python2.7/distutils/command/build_py.py", line 46, in finalize_options
               ('force', 'force'))
             File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 298, in set_undefined_options
               src_cmd_obj.ensure_finalized()
             File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized
               self.finalize_options()
             File "/tmp/pip-build-u45370/cryptography/setup.py", line 52, in finalize_options
               from cryptography.hazmat.primitives import constant_time, padding
             File "cryptography/hazmat/primitives/constant_time.py", line 21, in <module>
               _ffi = cffi.FFI()
             File "/app/.heroku/python/lib/python2.7/site-packages/cffi/api.py", line 56, in __init__
               import _cffi_backend as backend
           ImportError: libffi.so.6: cannot open shared object file: No such file or directory
           Complete output from command python setup.py egg_info:
           running egg_info

       creating pip-egg-info/cryptography.egg-info

       writing requirements to pip-egg-info/cryptography.egg-info/requires.txt

       writing pip-egg-info/cryptography.egg-info/PKG-INFO

       writing top-level names to pip-egg-info/cryptography.egg-info/top_level.txt

       writing dependency_links to pip-egg-info/cryptography.egg-info/dependency_links.txt

       writing manifest file 'pip-egg-info/cryptography.egg-info/SOURCES.txt'

       warning: manifest_maker: standard file '-c' not found



       Traceback (most recent call last):

         File "<string>", line 16, in <module>

         File "/tmp/pip-build-u45370/cryptography/setup.py", line 113, in <module>

           "build": cffi_build,

         File "/app/.heroku/python/lib/python2.7/distutils/core.py", line 152, in setup

           dist.run_commands()

         File "/app/.heroku/python/lib/python2.7/distutils/dist.py", line 953, in run_commands

           self.run_command(cmd)

         File "/app/.heroku/python/lib/python2.7/distutils/dist.py", line 972, in run_command

           cmd_obj.run()

         File "<string>", line 14, in replacement_run

         File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 259, in find_sources

           mm.run()

         File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 325, in run

           self.add_defaults()

         File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/egg_info.py", line 361, in add_defaults

           sdist.add_defaults(self)

         File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/sdist.py", line 199, in add_defaults

           build_py = self.get_finalized_command('build_py')

         File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 312, in get_finalized_command

           cmd_obj.ensure_finalized()

         File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized

           self.finalize_options()

         File "/app/.heroku/python/lib/python2.7/site-packages/setuptools/command/build_py.py", line 73, in finalize_options

           _build_py.finalize_options(self)

         File "/app/.heroku/python/lib/python2.7/distutils/command/build_py.py", line 46, in finalize_options

           ('force', 'force'))

         File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 298, in set_undefined_options

           src_cmd_obj.ensure_finalized()

         File "/app/.heroku/python/lib/python2.7/distutils/cmd.py", line 109, in ensure_finalized

           self.finalize_options()

         File "/tmp/pip-build-u45370/cryptography/setup.py", line 52, in finalize_options

           from cryptography.hazmat.primitives import constant_time, padding

         File "cryptography/hazmat/primitives/constant_time.py", line 21, in <module>

           _ffi = cffi.FFI()

         File "/app/.heroku/python/lib/python2.7/site-packages/cffi/api.py", line 56, in __init__

           import _cffi_backend as backend

       ImportError: libffi.so.6: cannot open shared object file: No such file or directory

       ----------------------------------------
       Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-u45370/cryptography
       Storing complete log in /app/.pip/pip.log

 !     Push rejected, failed to compile Python app

To [email protected]:my-app-staging.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:my-app-staging.git'

Update

Strangely enough, if I ssh to a dyno heroku run bash and then pip install pyOpenSSL, then it succeeds. But this doesn't seem to help figuring out what's wrong with the deployment process.

解决方案

It appears github user kennethjiang had the same problem and forked the custom libffi buildpack with a fix just four days ago.

Here are the relevant changes:

https://github.com/kennethjiang/heroku-buildpack-python-libffi/compare/3bb5fab8213f41411f515f21a6c83ff36c8aa1f2...8ef02

$ heroku config:add BUILDPACK_URL=git://github.com/kennethjiang/heroku-buildpack-python-libffi.git
$ git push heroku master
Initializing repository, done.
Counting objects: 3, done.
Writing objects: 100% (3/3), 260 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Preparing Python runtime (python-2.7.4)
-----> Installing Distribute (0.6.36)
-----> Installing Pip (1.3.1)
-----> Noticed cffi. Bootstrapping libffi.
PKG_CONFIG_PATH=:/app/vendor/libffi-3.0/lib/pkgconfig/
libffi.pc is in-place at /app/vendor/libffi-3.0/vendor/lib/pkgconfig/libffi.pc, libffi-based builds should work!
-----> Installing dependencies using Pip (1.3.1)
       Downloading/unpacking pyOpenSSL==0.14 (from -r requirements.txt (line 1))
         Running setup.py egg_info for package pyOpenSSL

           no previously-included directories found matching 'doc/_build'
       Downloading/unpacking cryptography==0.2.2 (from -r requirements.txt (line 2))
         Running setup.py egg_info for package cryptography
           no previously-included directories found matching 'documentation/_build'
           zip_safe flag not set; analyzing archive contents...
           six: module references __file__
           six: module references __path__

           Installed /tmp/pip-build-u24412/cryptography/six-1.6.1-py2.7.egg
           Searching for cffi>=0.8
           Reading http://pypi.python.org/simple/cffi/
           Best match: cffi 0.8.2
           Downloading https://pypi.python.org/packages/source/c/cffi/cffi-0.8.2.tar.gz#md5=37fc88c62f40d04e8a18192433f951ec
           Processing cffi-0.8.2.tar.gz
           Writing /tmp/easy_install-vYzEMy/cffi-0.8.2/setup.cfg
           Running cffi-0.8.2/setup.py -q bdist_egg --dist-dir /tmp/easy_install-vYzEMy/cffi-0.8.2/egg-dist-tmp-KU0RrQ
           cc -c c/check__thread.c -o c/check__thread.o

           Installed /tmp/pip-build-u24412/cryptography/cffi-0.8.2-py2.7-linux-x86_64.egg
...

       Successfully installed pyOpenSSL cryptography six cffi pycparser
       Cleaning up...

-----> Discovering process types
       Procfile declares types -> (none)

-----> Compressing... done, 27.9MB
-----> Launching... done, v5
       http://quiet-atoll-6802.herokuapp.com/ deployed to Heroku

To [email protected]:quiet-atoll-6802.git
 * [new branch]      master -> master

这篇关于自定义LIBFFI的问题Heroku buildpack的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-20 03:24