1

I specify my project's dependencies in requirements.txt. For tensorflow currently I have to specify the whl provided by Google. Unfortunately, there is a separate wheel depending on many system configurations:

(Mac, Ubuntu) x (CPU, GPU) x (Python2.7, Python3.4, Python3.5)

giving you 12 different combinations of whl files (indeed, there are only 10). When working from different devices (Ubuntu, Mac), is there a way to have my requirements.txt file work on both systems? Specifically, I use Python 3.5.2 on Mac and Ubuntu.

alex
  • 2,252
  • 4
  • 23
  • 34

2 Answers2

0

I think that this will be better if you use a file like setup.py or requirements.py. In python (.py) files you can easily get the os information by:

import sys
sys.platform

And you can also fire any terminal command for installing any package by:

import os
os.system("ls -a")
sansingh
  • 195
  • 8
0

As @sygi says in his comment, the way to restrict requirements to specific platforms or Python versions is described in https://stackoverflow.com/a/35614580/1951176. For our TensorFlow example, it would read

# Linux, Python 3.5
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.10.0-cp35-cp35m-linux_x86_64.whl; sys_platform == 'linux' and python_version == '3.5'
# Linux, Python 3.4
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp34-cp34m-linux_x86_64.whl; sys_platform == 'linux' and python_version == '3.4'
# Linux, Python 2.7
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.11.0-cp27-none-linux_x86_64.whl; sys_platform == 'linux' and python_version == '2.7'
# Mac, Python 3.4 or 3.5
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0-py3-none-any.whl; sys_platform == 'darwin' and ( python_version == '3.4' or python_version == '3.5' )
# Mac, Python 2.7
https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.11.0-py2-none-any.whl; sys_platform == 'darwin' and python_version == '2.7'

Finnally, as I just found out, in the specific case with TensorFlow, it works to specify just

tensorflow

in requirements.txt (as with other requirements).

Community
  • 1
  • 1
alex
  • 2,252
  • 4
  • 23
  • 34