GPy/setup.py

213 lines
9 KiB
Python
Raw Normal View History

2012-11-29 16:24:48 +00:00
#!/usr/bin/env python
# -*- coding: utf-8 -*-
2015-10-01 16:27:16 +01:00
#===============================================================================
# Copyright (c) 2012 - 2014, GPy authors (see AUTHORS.txt).
# Copyright (c) 2014, James Hensman, Max Zwiessele
# Copyright (c) 2015, Max Zwiessele
#
# All rights reserved.
#
2015-10-01 16:27:16 +01:00
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
2015-10-01 16:27:16 +01:00
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
2015-10-01 16:27:16 +01:00
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of GPy nor the names of its
2015-10-01 16:27:16 +01:00
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
2015-10-01 16:27:16 +01:00
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#===============================================================================
2015-09-10 08:35:09 +01:00
from __future__ import print_function
import os
import sys
2015-04-27 14:21:46 +01:00
from setuptools import setup, Extension
import numpy as np
import codecs
2015-09-10 08:35:09 +01:00
2012-11-29 16:24:48 +00:00
def read(fname):
2015-10-12 14:28:23 +01:00
with codecs.open(fname, 'r', 'latin') as f:
2015-10-12 08:55:55 +01:00
return f.read()
def read_to_rst(fname):
2015-09-09 14:33:08 +01:00
try:
import pypandoc
2015-10-12 10:05:59 +01:00
rstname = "{}.{}".format(os.path.splitext(fname)[0], 'rst')
2015-11-07 11:24:17 +00:00
pypandoc.convert(read(fname), 'rst', format='md', outputfile=rstname)
with open(rstname, 'r') as f:
rststr = f.read()
return rststr
2015-10-12 17:08:05 +01:00
#return read(rstname)
2015-10-07 13:17:01 +01:00
except ImportError:
2015-09-09 14:33:08 +01:00
return read(fname)
2016-04-11 08:51:21 +01:00
desc = """
2016-07-29 11:07:50 +01:00
Please refer to the github homepage for detailed instructions on installation and usage.
2016-04-11 08:51:21 +01:00
"""
version_dummy = {}
exec(read('GPy/__version__.py'), version_dummy)
__version__ = version_dummy['__version__']
del version_dummy
2015-09-09 09:28:42 +01:00
2015-09-10 08:35:09 +01:00
#Mac OS X Clang doesn't support OpenMP at the current time.
2015-09-07 13:38:11 +01:00
#This detects if we are building on a Mac
def ismac():
2015-09-10 15:06:15 +01:00
return sys.platform[:6] == 'darwin'
2015-09-07 13:38:11 +01:00
if ismac():
compile_flags = [ '-O3', ]
2015-09-08 21:38:48 +01:00
link_args = []
2015-09-07 13:38:11 +01:00
else:
2015-10-14 10:28:23 +01:00
compile_flags = [ '-fopenmp', '-O3']
link_args = ['-lgomp' ]
2015-04-27 14:21:46 +01:00
ext_mods = [Extension(name='GPy.kern.src.stationary_cython',
sources=['GPy/kern/src/stationary_cython.c',
'GPy/kern/src/stationary_utils.c'],
include_dirs=[np.get_include(),'.'],
2015-04-27 14:21:46 +01:00
extra_compile_args=compile_flags,
2015-09-07 13:38:11 +01:00
extra_link_args = link_args),
2015-04-27 19:47:19 +01:00
Extension(name='GPy.util.choleskies_cython',
sources=['GPy/util/choleskies_cython.c'],
2015-09-11 15:26:04 +01:00
include_dirs=[np.get_include(),'.'],
2015-09-07 13:38:11 +01:00
extra_link_args = link_args,
2015-08-17 15:04:43 +01:00
extra_compile_args=compile_flags),
2015-04-28 14:57:00 +01:00
Extension(name='GPy.util.linalg_cython',
sources=['GPy/util/linalg_cython.c'],
2015-09-11 15:26:04 +01:00
include_dirs=[np.get_include(),'.'],
2015-04-28 14:57:00 +01:00
extra_compile_args=compile_flags),
Extension(name='GPy.kern.src.coregionalize_cython',
sources=['GPy/kern/src/coregionalize_cython.c'],
2015-09-11 15:26:04 +01:00
include_dirs=[np.get_include(),'.'],
extra_compile_args=compile_flags),
Extension(name='GPy.models.state_space_cython',
sources=['GPy/models/state_space_cython.c'],
include_dirs=[np.get_include(),'.'],
2015-04-27 16:00:42 +01:00
extra_compile_args=compile_flags)]
2015-04-27 14:21:46 +01:00
2012-11-29 16:24:48 +00:00
setup(name = 'GPy',
2015-09-09 08:58:01 +01:00
version = __version__,
2015-10-12 10:09:41 +01:00
author = read_to_rst('AUTHORS.txt'),
author_email = "gpy.authors@gmail.com",
2012-11-29 16:24:48 +00:00
description = ("The Gaussian Process Toolbox"),
2016-07-29 11:07:50 +01:00
long_description = desc,
2012-11-29 16:24:48 +00:00
license = "BSD 3-clause",
keywords = "machine-learning gaussian-processes kernels",
url = "http://sheffieldml.github.com/GPy/",
2016-10-25 14:08:00 +01:00
download_url='https://github.com/SheffieldML/GPy/',
2015-04-27 14:21:46 +01:00
ext_modules = ext_mods,
2015-10-06 14:04:15 +01:00
packages = ["GPy",
"GPy.core",
"GPy.core.parameterization",
2015-10-06 14:04:15 +01:00
"GPy.kern",
"GPy.kern.src",
"GPy.kern.src.psi_comp",
2015-10-06 14:04:15 +01:00
"GPy.models",
"GPy.inference",
2014-11-05 16:31:22 +00:00
"GPy.inference.optimization",
2014-11-11 09:56:15 +00:00
"GPy.inference.mcmc",
2014-11-05 16:31:22 +00:00
"GPy.inference.latent_function_inference",
"GPy.likelihoods",
2015-10-06 14:04:15 +01:00
"GPy.mappings",
"GPy.examples",
"GPy.testing",
"GPy.util",
2015-10-06 14:04:15 +01:00
"GPy.plotting",
"GPy.plotting.gpy_plot",
"GPy.plotting.matplot_dep",
2015-10-10 18:49:20 +01:00
"GPy.plotting.matplot_dep.controllers",
"GPy.plotting.plotly_dep",
2015-10-06 14:04:15 +01:00
],
2012-11-29 16:24:48 +00:00
package_dir={'GPy': 'GPy'},
#package_data = {'GPy': ['defaults.cfg', 'installation.cfg',
# 'util/data_resources.json',
# 'util/football_teams.json',
# 'testing/plotting_tests/baseline/*.png'
# ]},
#data_files=[('GPy/testing/plotting_tests/baseline', 'testing/plotting_tests/baseline/*.png'),
# ('GPy/testing/', 'GPy/testing/pickle_test.pickle'),
# ],
2014-11-11 09:56:15 +00:00
include_package_data = True,
2012-11-29 16:24:48 +00:00
py_modules = ['GPy.__init__'],
2014-11-11 09:56:15 +00:00
test_suite = 'GPy.testing',
2016-10-30 11:36:21 +00:00
setup_requires = ['numpy>=1.7'],
2017-10-02 16:03:17 +01:00
install_requires = ['numpy>=1.7', 'scipy>=0.16', 'six', 'paramz>=0.8.5'],
2015-10-14 10:28:23 +01:00
extras_require = {'docs':['sphinx'],
'optional':['mpi4py',
'ipython>=4.0.0',
],
'plotting':['matplotlib >= 1.3',
'plotly >= 1.8.6'],
'notebook':['jupyter_client >= 4.0.6',
'ipywidgets >= 4.0.3',
'ipykernel >= 4.1.0',
'notebook >= 4.0.5',
],
},
2014-11-11 09:56:15 +00:00
classifiers=['License :: OSI Approved :: BSD License',
'Natural Language :: English',
'Operating System :: MacOS :: MacOS X',
'Operating System :: Microsoft :: Windows',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 2.7',
2015-10-11 09:33:56 +01:00
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
2017-04-12 11:53:05 +01:00
'Framework :: IPython',
'Intended Audience :: Science/Research',
'Intended Audience :: Developers',
'Topic :: Software Development',
'Topic :: Software Development :: Libraries :: Python Modules',
2015-10-11 09:33:56 +01:00
]
2012-11-29 16:24:48 +00:00
)
2015-10-10 13:32:32 +01:00
# Check config files and settings:
local_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'GPy', 'installation.cfg'))
home = os.getenv('HOME') or os.getenv('USERPROFILE')
user_file = os.path.join(home,'.config', 'GPy', 'user.cfg')
print("")
try:
if not os.path.exists(user_file):
# Does an old config exist?
old_user_file = os.path.join(home,'.gpy_user.cfg')
if os.path.exists(old_user_file):
# Move it to new location:
print("GPy: Found old config file, moving to new location {}".format(user_file))
if not os.path.exists(os.path.dirname(user_file)):
os.makedirs(os.path.dirname(user_file))
os.rename(old_user_file, user_file)
else:
# No config file exists, save informative stub to user config folder:
print("GPy: Saving user configuration file to {}".format(user_file))
if not os.path.exists(os.path.dirname(user_file)):
os.makedirs(os.path.dirname(user_file))
with open(user_file, 'w') as f:
with open(local_file, 'r') as l:
tmp = l.read()
f.write(tmp)
2015-10-10 13:32:32 +01:00
else:
print("GPy: User configuration file at location {}".format(user_file))
except:
2016-04-09 20:55:43 +01:00
print("GPy: Could not write user configuration file {}".format(user_file))