2012-11-29 16:24:48 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
# -*- coding: utf-8 -*-
|
2015-10-01 16:27:16 +01:00
|
|
|
|
2023-10-18 23:02:14 +02:00
|
|
|
# ===============================================================================
|
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-16 15:46:13 +01:00
|
|
|
#
|
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-16 15:46:13 +01:00
|
|
|
#
|
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-16 15:46:13 +01:00
|
|
|
#
|
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.
|
2015-10-16 15:46:13 +01:00
|
|
|
#
|
2015-10-02 18:26:17 +01:00
|
|
|
# * 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-16 15:46:13 +01:00
|
|
|
#
|
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.
|
2023-10-18 23:02:14 +02:00
|
|
|
# ===============================================================================
|
2015-10-01 16:27:16 +01:00
|
|
|
|
2015-09-10 08:35:09 +01:00
|
|
|
from __future__ import print_function
|
2014-08-07 10:53:18 -07:00
|
|
|
import os
|
2015-08-04 18:12:49 +01:00
|
|
|
import sys
|
2015-04-27 14:21:46 +01:00
|
|
|
from setuptools import setup, Extension
|
2015-10-12 09:52:27 +01:00
|
|
|
import codecs
|
2015-09-10 08:35:09 +01:00
|
|
|
|
2019-05-29 16:10:26 -07:00
|
|
|
try:
|
|
|
|
|
ModuleNotFoundError
|
|
|
|
|
except NameError:
|
|
|
|
|
ModuleNotFoundError = ImportError
|
|
|
|
|
|
2023-10-18 23:02:14 +02:00
|
|
|
|
2012-11-29 16:24:48 +00:00
|
|
|
def read(fname):
|
2023-10-18 23:02:14 +02:00
|
|
|
with codecs.open(fname, "r", "latin") as f:
|
2015-10-12 08:55:55 +01:00
|
|
|
return f.read()
|
2015-10-16 15:46:13 +01:00
|
|
|
|
2023-10-18 23:02:14 +02:00
|
|
|
|
2015-10-12 09:56:12 +01:00
|
|
|
def read_to_rst(fname):
|
2015-09-09 14:33:08 +01:00
|
|
|
try:
|
|
|
|
|
import pypandoc
|
2023-10-18 23:02:14 +02:00
|
|
|
|
|
|
|
|
rstname = "{}.{}".format(os.path.splitext(fname)[0], "rst")
|
|
|
|
|
pypandoc.convert(read(fname), "rst", format="md", outputfile=rstname)
|
|
|
|
|
with open(rstname, "r") as f:
|
2015-11-07 11:24:17 +00:00
|
|
|
rststr = f.read()
|
2015-11-07 10:46:17 +00:00
|
|
|
return rststr
|
2023-10-18 23:02:14 +02: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)
|
|
|
|
|
|
2023-10-18 23:02:14 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
"""
|
2015-11-08 10:48:29 +00:00
|
|
|
|
2015-09-09 09:45:01 +01:00
|
|
|
version_dummy = {}
|
2023-10-18 23:02:14 +02:00
|
|
|
exec(read("GPy/__version__.py"), version_dummy)
|
|
|
|
|
__version__ = version_dummy["__version__"]
|
2015-09-09 09:45:01 +01:00
|
|
|
del version_dummy
|
2015-09-09 09:28:42 +01:00
|
|
|
|
2023-10-18 23:02:14 +02:00
|
|
|
|
|
|
|
|
# Mac OS X Clang doesn't support OpenMP at the current time.
|
|
|
|
|
# This detects if we are building on a Mac
|
2015-09-07 13:38:11 +01:00
|
|
|
def ismac():
|
2023-10-18 23:02:14 +02:00
|
|
|
return sys.platform[:6] == "darwin"
|
|
|
|
|
|
2015-09-07 13:38:11 +01:00
|
|
|
|
|
|
|
|
if ismac():
|
2023-10-18 23:02:14 +02:00
|
|
|
compile_flags = [
|
|
|
|
|
"-O3",
|
|
|
|
|
]
|
2015-09-08 21:38:48 +01:00
|
|
|
link_args = []
|
2015-09-07 13:38:11 +01:00
|
|
|
else:
|
2023-10-18 23:02:14 +02:00
|
|
|
compile_flags = ["-fopenmp", "-O3"]
|
|
|
|
|
link_args = ["-lgomp"]
|
2015-04-27 14:21:46 +01:00
|
|
|
|
2018-07-24 15:43:29 +01:00
|
|
|
try:
|
|
|
|
|
# So that we don't need numpy installed to determine it's a dependency.
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
2023-10-18 23:02:14 +02:00
|
|
|
ext_mods = [
|
|
|
|
|
Extension(
|
|
|
|
|
name="GPy.kern.src.stationary_cython",
|
|
|
|
|
sources=[
|
|
|
|
|
"GPy/kern/src/stationary_cython.pyx",
|
|
|
|
|
"GPy/kern/src/stationary_utils.c",
|
|
|
|
|
],
|
|
|
|
|
include_dirs=[np.get_include(), "."],
|
|
|
|
|
extra_compile_args=compile_flags,
|
|
|
|
|
extra_link_args=link_args,
|
|
|
|
|
),
|
|
|
|
|
Extension(
|
|
|
|
|
name="GPy.util.choleskies_cython",
|
|
|
|
|
sources=["GPy/util/choleskies_cython.pyx"],
|
|
|
|
|
include_dirs=[np.get_include(), "."],
|
|
|
|
|
extra_link_args=link_args,
|
|
|
|
|
extra_compile_args=compile_flags,
|
|
|
|
|
),
|
|
|
|
|
Extension(
|
|
|
|
|
name="GPy.util.linalg_cython",
|
|
|
|
|
sources=["GPy/util/linalg_cython.pyx"],
|
|
|
|
|
include_dirs=[np.get_include(), "."],
|
|
|
|
|
extra_compile_args=compile_flags,
|
|
|
|
|
extra_link_args=link_args,
|
|
|
|
|
),
|
|
|
|
|
Extension(
|
|
|
|
|
name="GPy.kern.src.coregionalize_cython",
|
|
|
|
|
sources=["GPy/kern/src/coregionalize_cython.pyx"],
|
|
|
|
|
include_dirs=[np.get_include(), "."],
|
|
|
|
|
extra_compile_args=compile_flags,
|
|
|
|
|
extra_link_args=link_args,
|
|
|
|
|
),
|
|
|
|
|
Extension(
|
|
|
|
|
name="GPy.models.state_space_cython",
|
|
|
|
|
sources=["GPy/models/state_space_cython.pyx"],
|
|
|
|
|
include_dirs=[np.get_include(), "."],
|
|
|
|
|
extra_compile_args=compile_flags,
|
|
|
|
|
extra_link_args=link_args,
|
|
|
|
|
),
|
|
|
|
|
]
|
2018-07-24 15:43:29 +01:00
|
|
|
except ModuleNotFoundError:
|
|
|
|
|
ext_mods = []
|
|
|
|
|
|
2023-10-18 23:02:14 +02:00
|
|
|
setup(
|
|
|
|
|
version=__version__,
|
|
|
|
|
author=read_to_rst("AUTHORS.txt"),
|
|
|
|
|
ext_modules=ext_mods,
|
|
|
|
|
)
|
2015-10-10 13:32:32 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
# Check config files and settings:
|
2023-10-18 23:02:14 +02:00
|
|
|
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")
|
2015-10-10 13:32:32 +01:00
|
|
|
|
|
|
|
|
print("")
|
2016-04-08 11:38:46 +01:00
|
|
|
try:
|
|
|
|
|
if not os.path.exists(user_file):
|
|
|
|
|
# Does an old config exist?
|
2023-10-18 23:02:14 +02:00
|
|
|
old_user_file = os.path.join(home, ".gpy_user.cfg")
|
2016-04-08 11:38:46 +01:00
|
|
|
if os.path.exists(old_user_file):
|
|
|
|
|
# Move it to new location:
|
2023-10-18 23:02:14 +02:00
|
|
|
print(
|
|
|
|
|
"GPy: Found old config file, moving to new location {}".format(
|
|
|
|
|
user_file
|
|
|
|
|
)
|
|
|
|
|
)
|
2016-04-08 11:38:46 +01:00
|
|
|
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))
|
2023-10-18 23:02:14 +02:00
|
|
|
with open(user_file, "w") as f:
|
|
|
|
|
with open(local_file, "r") as l:
|
2016-04-08 11:38:46 +01:00
|
|
|
tmp = l.read()
|
|
|
|
|
f.write(tmp)
|
2015-10-10 13:32:32 +01:00
|
|
|
else:
|
2016-04-08 11:38:46 +01:00
|
|
|
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))
|