自定义 LIBFFI Heroku 构建包的问题

2024-03-25

我正在尝试将我的应用程序部署到 Heroku。它正在使用pyOpenSSL,这需要cryptography,这需要libffi。我找到了一个自定义构建包,其中包括libffi here: https://github.com/mfenniak/heroku-buildpack-python-libffi https://github.com/mfenniak/heroku-buildpack-python-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在安装过程中可用,但它是构建包编译步骤的一部分:https://github.com/mfenniak/heroku-buildpack-python-libffi/commit/6ce48d4fd6c55fc3dc462cf6300c17854732b6e2 https://github.com/mfenniak/heroku-buildpack-python-libffi/commit/6ce48d4fd6c55fc3dc462cf6300c17854732b6e2

一般来说,这个构建包可以工作,我之前用过它bcrypt (https://pypi.python.org/pypi/bcrypt https://pypi.python.org/pypi/bcrypt).

这是失败的heroku部署过程:

$ 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] /cdn-cgi/l/email-protection:my-app-staging.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected] /cdn-cgi/l/email-protection:my-app-staging.git'

Update

奇怪的是,如果我 ssh 到测功机heroku run bash进而pip install pyOpenSSL,然后就成功了。但这似乎无助于找出部署过程中的问题所在。


看来 github 用户 kenneth Jiang 也有同样的问题并分叉了自定义 libffi 构建包 https://github.com/kennethjiang/heroku-buildpack-python-libffi四天前才修复。

以下是相关变更:

https://github.com/kenneth Jiang/heroku-buildpack-python-libffi/compare/3bb5fab8213f41411f515f21a6c83ff36c8aa1f2...8ef02 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] /cdn-cgi/l/email-protection:quiet-atoll-6802.git
 * [new branch]      master -> master
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

自定义 LIBFFI Heroku 构建包的问题 的相关文章

  • 使用 Pillow 和 Numpy 进行图像推导

    I have two images and 我想导出一个只有红色 Hello 的图像 例如 所以我正在运行一个简单的推导python脚本 from PIL import Image import numpy as np root root
  • 如何跳过财务图中的空日期(周末)

    ax plot date dates dates highs lows 我目前正在使用此命令来绘制财务高点和低点Matplotlib http en wikipedia org wiki Matplotlib 效果很好 但如何删除 x 轴上
  • 是否可以在 Sphinx 中隐藏 Python 函数参数?

    假设我有以下函数 该函数记录在Numpydoc 风格 https github com numpy numpy blob master doc HOWTO DOCUMENT rst txt 并且文档是自动生成的Sphinx http sph
  • 查找 python 数据框中每行的最高值

    我想找到每行中的最高值并返回 python 中该值的列标题 例如 我想找到每行的前两个 df A B C D 5 9 8 2 4 1 2 3 我希望我的输出看起来像这样 df B C A D 您可以使用字典理解来生成largest n数据帧
  • 使用 Python 的 optparse 模块时如何遵守 PEP 257 文档字符串?

    根据PEP 257 http www python org dev peps pep 0257 multi line docstrings命令行脚本的文档字符串应该是它的使用消息 脚本的文档字符串 a 独立程序 应该可用 作为其 使用 消息
  • 如何在heroku上运行一个简单的文件

    假设我已经在 github 上安装了 Rails 应用程序 并且正在 heroku 上部署 github 存储库 我遇到过这样的情况 我有一个包含一堆单词的简单文本文件 它在我的 github 存储库中 我想将这些单词 使用简单的 ruby
  • 如何使用 boto3 从 AWS Cognito 获取经过身份验证的身份响应

    我想使用 boto3 获取访问 AWS 服务的临时凭证 用例是这样的 我的 Cognito 用户池中的用户登录到我的服务器 我希望服务器代码为该用户提供访问其他 AWS 服务的临时凭证 我有一个存储我的用户的 Cognito 用户池 我有一
  • __getitem__、__setitem__ 如何处理切片?

    我正在运行 Python 2 7 10 我需要拦截列表中的更改 我所说的 更改 是指在浅层意义上修改列表的任何内容 如果列表由相同顺序的相同对象组成 则列表不会更改 无论这些对象的状态如何 否则 它会更改 我不需要找出来how列表已经改变
  • 为什么我不能“string”.print()?

    我的理解print 在 Python 和 Ruby 以及其他语言 中 它是字符串 或其他类型 上的方法 因为它的语法非常常用 打印 嗨 works 那么为什么不呢 hi print 在 Python 中或 hi print在红宝石工作 当你
  • 从heroku 提取数据库失败并出现 Encoding::CompatibilityError

    我在执行 db pull 从 heroku 回到本地开发环境时遇到一些问题 我的设置是通过 RVM 在 Mac OS X Snow Leopard 下的本地 Rails 3 Ruby 1 9 2 环境上通过 MacPorts 安装 MySQ
  • 什么时候用==,什么时候用is?

    奇怪的是 gt gt gt a 123 gt gt gt b 123 gt gt gt a is b True gt gt gt a 123 gt gt gt b 123 gt gt gt a is b False Seems a is b
  • 如何将一串Python代码编译成一个可以调用函数的模块?

    在 Python 中 我有一串 Python 源代码 其中包含以下函数 mySrc def foo print foo def bar print bar 我想将这个字符串编译成某种形式类似模块的对象这样我就可以调用代码中包含的函数 这是我
  • 直接打开Spyder还是通过Pythonxy打开?

    之前 我一直在运行PythonSpyder 我总是开始Spyder直接双击其图标 今天突然发现我还有一个东西叫Python x y 我注意到我也可以开始Spyder通过它 这两种方法有什么区别吗 如果不是的话 有什么意义Python x y
  • 获取 HTML 代码的结构

    我正在使用 BeautifulSoup4 我很好奇是否有一个函数可以返回 HTML 代码的结构 有序标签 这是一个例子 h1 Simple example h1 p This is a simple example of html page
  • 如何将 pip 指向 Mercurial 分支?

    我正在尝试通过 pip 将我的应用程序安装到 virtualenv 进行测试 安装时效果很好default or tip像这样 pip install e hg https email protected cdn cgi l email p
  • Numpy 通过一个数组的值总结另一个数组

    我正在尝试找到一种矢量化方法来完成以下任务 假设我有一个 x 和 y 值的数组 请注意 x 值并不总是整数并且可以为负数 import numpy as np x np array 1 1 1 3 2 2 2 5 4 4 dtype flo
  • Python `concurrent.futures`:根据完成顺序迭代 future

    我想要类似的东西executor map 除了当我迭代结果时 我想根据完成的顺序迭代它们 例如首先完成的工作项应该首先出现在迭代中 等等 这样 当且仅当序列中的每个工作项尚未完成时 迭代就会阻塞 我知道如何使用队列自己实现这一点 但我想知道
  • 单击 selenium 中的链接时循环遍历表格的行(python)

    示例页面源代码如下所示 div class div1 table class foot market tbody td class today name td tbody tbody td class today name td tbody
  • 用户的完整 UNIX 用户名

    想知道您是否知道是否有一种巧妙的方法可以从 shell 获取完整的用户名 示例 如果我的 UNIX 用户名是 froyo 那么我想获取我的全名 在本例中 如系统中注册的那样 froyo Abhishek Pratap Finger 命令可以
  • Matplotlib 渲染日期、图像的问题

    我在使用 conda forge 的 Matplotlib v 3 1 3 和 python 3 7 时遇到问题 我拥有 Matplotlib 所需的所有依赖项 当我输入这段代码时 它应该可以工作 我得到了泼溅艺术 它基于此 YouTube

随机推荐