diff --git a/.readthedocs.yml b/.readthedocs.yml new file mode 100644 index 000000000..283501959 --- /dev/null +++ b/.readthedocs.yml @@ -0,0 +1,11 @@ +formats: + - epub + - pdf + +python: + version: 3.6 + pip_install: true + extra_requirements: + - doc + - dev + - test diff --git a/.travis.yml b/.travis.yml index adf459c5c..fe7b7d4a1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,9 +21,7 @@ env: install: - - pip install tensorflow - - pip install -r requirements.txt - - pip install -e .[dev,doc,test] + - pip install -e .[tf_cpu,dev,test,doc] script: diff --git a/README.md b/README.md index b3cb46f34..90e6b4ef1 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,38 @@ The simplest way to install TensorLayer is: # for master version (Recommended) $ pip install git+https://github.com/tensorlayer/tensorlayer.git -# for stable version +# for last stable version $ pip install tensorlayer + +# for latest release candidate +$ pip install --pre tensorlayer +``` + +If you prefer to build from sources in a development objective +```bash +# First clone the repository +$ git clone https://github.com/tensorlayer/tensorlayer.git +$ cd tensorlayer + +# Install virtualenv if necessary +$ pip install virtualenv + +# Then create a virtualenv called venv inside +$ virtualenv venv + +# Activate the virtualenv + +# Linux: +$ source venv/bin/activate + +# Windows: +$ venv\Scripts\activate.bat + +# for a machine **without** an NVIDIA GPU +$ pip install -e .[tf_cpu,dev,test,doc] + +# for a machine **with** an NVIDIA GPU +$ pip install -e .[tf_gpu,dev,test,doc] ``` Dockerfile is supplied to build images, build as usual @@ -80,6 +110,12 @@ $ docker build -t tensorlayer:latest . $ docker build -t tensorlayer:latest-gpu -f Dockerfile.gpu . ``` +Launching the unittest: + +```bash +$ pytest +``` + Please check [documentation](http://tensorlayer.readthedocs.io/en/latest/user/installation.html) for detailed instructions. diff --git a/docs/requirements-rtd.txt b/docs/requirements-rtd.txt deleted file mode 100644 index 2220357e1..000000000 --- a/docs/requirements-rtd.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Keep this file in sync with requirements.txt, except tensorflow - -flake8-docstrings>=1.3,<1.4 -matplotlib>=2.2,<2.3 -pymongo>=3.6,<3.7 -progressbar2>=3.37,<3.38 -scikit-image>=0.13,<0.14 -scipy>=1.0,<1.1 -sphinx>=1.7,<1.8 -tensorflow==1.5.0 # DO NOT MODIFY: https://github.com/tensorflow/tensorflow/issues/17441 diff --git a/docs/requirements.txt b/docs/requirements.txt index 046b187de..ad871fc50 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,5 +1,3 @@ -# Keep this file in sync with requirements-rtd.txt, except tensorflow - flake8-docstrings>=1.3,<1.4 matplotlib>=2.2,<2.3 pymongo>=3.6,<3.7 @@ -7,4 +5,3 @@ progressbar2>=3.37,<3.38 scikit-image>=0.13,<0.14 scipy>=1.0,<1.1 sphinx>=1.7,<1.8 -tensorflow>=1.7,<1.8 diff --git a/setup.py b/setup.py index 351b6ac45..6462a47c6 100755 --- a/setup.py +++ b/setup.py @@ -41,7 +41,6 @@ else: long_description = 'See ' + __homepage__ - # ======================= Reading Requirements files as TXT files ======================= def req_file(filename): @@ -51,6 +50,24 @@ def req_file(filename): # Example: `\n` at the end of each line return [x.strip() for x in content] +# ======================= Defining the requirements var ======================= + +install_requires = req_file("requirements.txt") + +extras_require = { + 'tf_cpu': ['tensorflow>=1.8.0,<1.9'], + 'tf_gpu': ['tensorflow-gpu>=1.8.0,<1.9'], + 'dev': req_file("requirements_dev.txt"), + 'doc': req_file("docs/requirements.txt"), + 'test': req_file("tests/requirements.txt") +} + +# Readthedocs requires TF 1.5.0 to build properly +if os.environ.get('READTHEDOCS', None) == 'True': + install_requires.append("tensorflow==1.5.0") + +# ======================= Define the package setup ======================= + setup( name=__package_name__, @@ -125,16 +142,12 @@ def req_file(filename): # your project is installed. For an analysis of "install_requires" vs pip's # requirements files see: # https://packaging.python.org/en/latest/requirements.html - install_requires=req_file("requirements.txt"), + install_requires=install_requires, # List additional groups of dependencies here (e.g. development # dependencies). You can install these using the following syntax, # $ pip install -e .[test] - extras_require={ - 'dev': req_file("requirements_dev.txt"), - 'doc': req_file("docs/requirements.txt"), - 'test': req_file("tests/requirements.txt") - }, + extras_require=extras_require, scripts=[ 'tl', ], diff --git a/tensorlayer/__init__.py b/tensorlayer/__init__.py index a775499b8..e30f4dead 100644 --- a/tensorlayer/__init__.py +++ b/tensorlayer/__init__.py @@ -3,28 +3,44 @@ """Deep learning and Reinforcement learning library for Researchers and Engineers""" from __future__ import absolute_import -try: +import pkg_resources +installed_packages = [d for d in pkg_resources.working_set] + +TF_is_installed = False +TL_is_installed = False + +for package in installed_packages: + if 'tensorflow' in package.project_name: + TF_is_installed = True + if 'tensorlayer' in package.project_name and 'site-packages' in package.location: + TL_is_installed = True + +if TF_is_installed: # The tensorlayer package is installed import tensorflow -except ImportError: + + from . import activation + from . import cost + from . import files + from . import iterate + from . import layers + from . import models + from . import utils + from . import visualize + from . import prepro + from . import nlp + from . import rein + from . import distributed + + # alias + act = activation + vis = visualize + + global_flag = {} + global_dict = {} + +elif TL_is_installed: install_instr = "Please make sure you install a recent enough version of TensorFlow." - raise ImportError("__init__.py : Could not import TensorFlow." + install_instr) - -from . import activation -from . import cost -from . import files -from . import iterate -from . import layers -from . import models -from . import utils -from . import visualize -from . import prepro -from . import nlp -from . import rein -from . import distributed - -# alias -act = activation -vis = visualize + raise ImportError("__init__.py : Could not import TensorFlow. {}".format(install_instr)) # Use the following formating: (major, minor, patch, prerelease) VERSION = (1, 8, 5, 'rc2') @@ -40,6 +56,3 @@ __description__ = 'Reinforcement Learning and Deep Learning Library for Researcher and Engineer.' __license__ = 'apache' __keywords__ = 'deep learning, machine learning, computer vision, nlp, supervised learning, unsupervised learning, reinforcement learning, tensorflow' - -global_flag = {} -global_dict = {}