How to freeze requirements that can't be satisfied locally?

旧城冷巷雨未停 提交于 2020-01-06 02:51:28

问题


I'm writing a Python app to deploy on Heroku. Per Heroku's guide, I need to list package requirements in a Pip requirements.txt file. The guide instructs me to install the packages locally, then run pip freeze > requirements.txt to write the frozen requirements file.

However, one of the packages I want to use in deployment on Heroku can't be installed locally. It's incompatible with my operating system.

So how do I write a requirements.txt including this package suitable for Heroku?

The only way I can think of is to write it by hand - but this would be tedious, because the package in question has many dependencies of its own. Besides, this defeats the point of the package manager.


When deploying Ruby apps to Heroku, Bundler makes this easy. In my Gemfile I write

gem "pg", :group => :production
gem "sqlite3", :group => :development

The command bundle install then writes a frozen version list Gemfile.lock (analogous to requirements.txt). It doesn't install the packages listed under the 'production' group, but it still freezes a consistent list of versioned packages.

Example: Gemfile and Gemfile.lock


回答1:


You can have more than one file, and call them different things, but Heroku does expect a requirements.txt. For instance, for dev, you could maintain a dev_requirements.txt

Locally you can run:

$ pip freeze > dev_requirements.txt

etc, and

$ pip install -r dev_requirements.txt

and Heroku will run:

$ pip install -r requirements.txt



回答2:


It's not possible. Issue reported to pip https://github.com/pypa/pip/issues/747



来源:https://stackoverflow.com/questions/13868503/how-to-freeze-requirements-that-cant-be-satisfied-locally

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!