我想要設置一個setup.py
腳本爲install tensorflow,但不是簡單的pip install
方法來安裝它。使用setuptools安裝tensorflow
我發現的唯一方法就是這種非常冒險的方式,有沒有更好的官方方式來做到這一點?
from setuptools import setup
from setuptools.command.install import install
from subprocess import call
from sys import platform as _platform
#linux or ios
if _platform == "linux" or _platform == "linux2":
tensorfow_url = "https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl"
elif _platform == "darwin":
tensorfow_url = "https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl"
class CustomInstallCommands(install):
"""Installs tensorflow the hacky way"""
def run(self):
call(['pip', 'install', '--upgrade', tensorfow_url])
install.run(self)
setup(name='tensorflow_project',
version='0.1',
description='project with tensorflow',
packages=['tensorflow_project'],
install_requires=[
'scipy',
'numpy',
'pandas',
'scikit-learn',
],
zip_safe=False,
cmdclass={
'install': CustomInstallCommands,
'develop': CustomInstallCommands,
})