在 Heroku 的 composer.json 中包含 Python 个库
Include Python libraries in composer.json for Heroku
我正在尝试通过 PHP 使用 Heroku 部署一个应用程序,但它 运行 是一个 Python 脚本,它依赖于 Python 库到 运行(例如numpy
)。
如何将此依赖项包含在 composer.json
文件中?
配置您的应用程序以使用 the official PHP buildpack:
heroku buildpacks:set heroku/php
添加the official Python buildpack:
heroku buildpacks:add --index 1 heroku/python
运行 heroku buildpacks
应该先显示 Python buildpack,再显示 PHP 一秒钟。
The last buildpack in the list will be used to determine the process types for the application. Any process types defined from earlier buildpacks will be ignored.
确保你有一个 composer.json
在你的 PHP 构建包的存储库根目录中定义你的 PHP 依赖项。
确保你有一个 requirements.txt
文件(如果你想使用 pip
)或 Pipfile
和 Pipfile.lock
(如果你想要使用 Pipenv),它在你的 Python 构建包的存储库根目录中定义你的 Python 依赖项。
在存储库的根目录中指定 the supported Python version that you wish to use. If you are using Pipenv, this information can be included in your Pipfile
. If you are using pip
you can use a runtime.txt
file 也是一个好主意。
下次部署时,您应该会看到首先安装 Python 依赖项,然后是 PHP 依赖项。
我正在尝试通过 PHP 使用 Heroku 部署一个应用程序,但它 运行 是一个 Python 脚本,它依赖于 Python 库到 运行(例如numpy
)。
如何将此依赖项包含在 composer.json
文件中?
配置您的应用程序以使用 the official PHP buildpack:
heroku buildpacks:set heroku/php
添加the official Python buildpack:
heroku buildpacks:add --index 1 heroku/python
运行
heroku buildpacks
应该先显示 Python buildpack,再显示 PHP 一秒钟。The last buildpack in the list will be used to determine the process types for the application. Any process types defined from earlier buildpacks will be ignored.
确保你有一个
composer.json
在你的 PHP 构建包的存储库根目录中定义你的 PHP 依赖项。确保你有一个
requirements.txt
文件(如果你想使用pip
)或Pipfile
和Pipfile.lock
(如果你想要使用 Pipenv),它在你的 Python 构建包的存储库根目录中定义你的 Python 依赖项。在存储库的根目录中指定 the supported Python version that you wish to use. If you are using Pipenv, this information can be included in your
Pipfile
. If you are usingpip
you can use aruntime.txt
file 也是一个好主意。
下次部署时,您应该会看到首先安装 Python 依赖项,然后是 PHP 依赖项。