2016-08-25 07:26:11 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# coding: utf-8
|
|
|
|
|
|
|
|
# Copyright (c) IPython Development Team.
|
|
|
|
# Distributed under the terms of the Modified BSD License.
|
|
|
|
|
|
|
|
from __future__ import print_function
|
|
|
|
|
|
|
|
# the name of the package
|
|
|
|
name = 'yap_kernel'
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# Minimal Python version sanity check
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
2016-07-31 16:09:21 +01:00
|
|
|
import sys
|
2017-08-21 12:36:48 +01:00
|
|
|
import sysconfig
|
2017-05-27 22:54:00 +01:00
|
|
|
import setuptools
|
2016-08-25 07:26:11 +01:00
|
|
|
|
|
|
|
v = sys.version_info
|
|
|
|
if v[:2] < (2,7) or (v[0] >= 3 and v[:2] < (3,3)):
|
2017-05-27 22:54:00 +01:00
|
|
|
error = "ERROR: %s requires Python version 3.3 or above." % name
|
2016-08-25 07:26:11 +01:00
|
|
|
print(error, file=sys.stderr)
|
|
|
|
sys.exit(1)
|
|
|
|
|
|
|
|
PY3 = (sys.version_info[0] >= 3)
|
|
|
|
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# get on with it
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
from glob import glob
|
2017-05-08 18:49:00 +01:00
|
|
|
import os
|
|
|
|
import shutil
|
2016-08-25 07:26:11 +01:00
|
|
|
|
|
|
|
from distutils.core import setup
|
|
|
|
|
2017-05-08 18:49:00 +01:00
|
|
|
pjoin = os.path.join
|
2017-05-27 22:54:00 +01:00
|
|
|
here = os.path.abspath(os.path.dirname(__file__))
|
|
|
|
# pkg_root = pjoin(here, name)
|
2017-05-08 18:49:00 +01:00
|
|
|
|
2017-05-27 22:54:00 +01:00
|
|
|
packages = setuptools.find_packages('${CMAKE_CURRENT_SOURCE_DIR}')
|
|
|
|
# for d, _, _ in os.walk(pjoin(here, name)):
|
|
|
|
# if os.path.exists(pjoin(d, '__init__.py')):
|
|
|
|
# packages.append(d[len(here)+1:].replace(os.path.sep, '.'))
|
2017-05-08 18:49:00 +01:00
|
|
|
|
2017-08-21 12:36:48 +01:00
|
|
|
sys.path.insert(0, "${CMAKE_CURRENT_SOURCE_DIR}")
|
2017-05-08 18:49:00 +01:00
|
|
|
package_data = {
|
2017-08-21 12:36:48 +01:00
|
|
|
'yap_ipython': ['prolog/*.*'],
|
|
|
|
'yap_kernel': ['resources/*.*']
|
2017-05-08 18:49:00 +01:00
|
|
|
}
|
2016-07-31 16:09:21 +01:00
|
|
|
|
2017-05-27 22:54:00 +01:00
|
|
|
|
2016-08-25 07:26:11 +01:00
|
|
|
version_ns = {}
|
2017-05-27 22:54:00 +01:00
|
|
|
with open(pjoin('${CMAKE_CURRENT_SOURCE_DIR}', name, '_version.py')) as f:
|
2017-05-08 18:49:00 +01:00
|
|
|
exec(f.read(), {}, version_ns)
|
|
|
|
|
|
|
|
|
2017-05-27 22:54:00 +01:00
|
|
|
|
|
|
|
|
2016-08-25 07:26:11 +01:00
|
|
|
setup_args = dict(
|
2017-05-08 18:49:00 +01:00
|
|
|
name = name,
|
|
|
|
version = version_ns['__version__'],
|
|
|
|
scripts = glob(pjoin('scripts', '*')),
|
|
|
|
packages = packages,
|
2017-05-14 11:27:44 +01:00
|
|
|
py_modules = ['yap_kernel_launcher'],
|
2017-05-08 18:49:00 +01:00
|
|
|
package_data = package_data,
|
2017-08-21 12:36:48 +01:00
|
|
|
package_dir = {'':"${CMAKE_CURRENT_SOURCE_DIR}"},
|
2017-05-14 11:27:44 +01:00
|
|
|
description = "YAP Kernel for Jupyter",
|
2017-08-21 12:36:48 +01:00
|
|
|
author = 'YAP Development Team',
|
2017-05-27 22:54:00 +01:00
|
|
|
author_email = 'YAP-dev@scipy.org',
|
2017-05-08 18:49:00 +01:00
|
|
|
url = 'http://ipython.org',
|
2016-08-25 07:26:11 +01:00
|
|
|
license = 'BSD',
|
|
|
|
platforms = "Linux, Mac OS X, Windows",
|
|
|
|
keywords = ['Interactive', 'Interpreter', 'Shell', 'Web'],
|
|
|
|
classifiers = [
|
|
|
|
'Intended Audience :: Developers',
|
|
|
|
'Intended Audience :: System Administrators',
|
|
|
|
'Intended Audience :: Science/Research',
|
|
|
|
'License :: OSI Approved :: BSD License',
|
2017-05-27 22:54:00 +01:00
|
|
|
'Programming Language :: Prolog',
|
2017-05-08 18:49:00 +01:00
|
|
|
'Programming Language :: Python',
|
2016-08-25 07:26:11 +01:00
|
|
|
'Programming Language :: Python :: 3',
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
if 'develop' in sys.argv or any(a.startswith('bdist') for a in sys.argv):
|
|
|
|
import setuptools
|
2016-07-31 16:09:21 +01:00
|
|
|
|
2016-08-25 07:26:11 +01:00
|
|
|
setuptools_args = {}
|
|
|
|
install_requires = setuptools_args['install_requires'] = [
|
|
|
|
]
|
|
|
|
|
2017-05-08 18:49:00 +01:00
|
|
|
if any(a.startswith(('bdist', 'build', 'install')) for a in sys.argv):
|
2017-05-14 11:27:44 +01:00
|
|
|
from yap_kernel.kernelspec import write_kernel_spec, make_yap_kernel_cmd, KERNEL_NAME
|
2017-05-08 18:49:00 +01:00
|
|
|
|
2017-08-21 12:36:48 +01:00
|
|
|
|
2017-05-14 11:27:44 +01:00
|
|
|
argv = make_yap_kernel_cmd(executable='python')
|
2017-08-21 12:36:48 +01:00
|
|
|
dest = os.path.join(here, 'resources')
|
2017-09-23 02:17:55 +01:00
|
|
|
try:
|
2017-05-08 18:49:00 +01:00
|
|
|
shutil.rmtree(dest)
|
2017-09-23 02:17:55 +01:00
|
|
|
os.makedirs( dest )
|
2018-01-05 16:57:38 +00:00
|
|
|
shutil.copy2('${CMAKE_SOURCE_DIR}/docs/icons/yap_32x32x32.png',pjoin(dest,"logo_32x32.png"))
|
|
|
|
shutil.copy2('${CMAKE_SOURCE_DIR}/docs/icons/yap_64x64x32.png',pjoin(dest,"logo_64x64.png"))
|
2017-09-23 02:17:55 +01:00
|
|
|
write_kernel_spec(dest, overrides={'argv': argv})
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
# shutil.copy('${CMAKE_CURRENT_SOURCE_DIR}/kernel.js',dest)
|
|
|
|
# shutil.copy('${CMAKE_SOURCE_DIR}/misc/editors/prolog.js',dest)
|
2018-01-05 16:57:38 +00:00
|
|
|
setup_args['data_files'] = [(pjoin('share', 'jupyter', 'kernels', KERNEL_NAME), glob(pjoin(dest, '*')))]
|
2017-08-21 12:36:48 +01:00
|
|
|
mode_loc = pjoin( sysconfig.get_path('platlib'), 'notebook', 'static', 'components', 'codemirror', 'mode', 'prolog')
|
2017-09-06 16:13:34 +01:00
|
|
|
custom_loc = pjoin( sysconfig.get_path('platlib'), 'notebook', 'static', 'custom')
|
2018-01-05 16:57:38 +00:00
|
|
|
# try:
|
|
|
|
# shutil.copy( pjoin( custom_loc, "custom.js") , pjoin( custom_loc, "custom.js.orig"))
|
|
|
|
# shutil.copy( "${CMAKE_CURRENT_SOURCE_DIR}/custom.js" , pjoin( custom_loc, "custom.js"))
|
|
|
|
# if not os.path.exists(mode_loc):
|
|
|
|
# os.makedirs(mode_loc)
|
|
|
|
# shutil.copy( "${CMAKE_SOURCE_DIR}/misc/editors/prolog.js" , mode_loc)
|
|
|
|
# except:
|
|
|
|
# pass
|
2017-05-08 18:49:00 +01:00
|
|
|
|
2016-08-25 07:26:11 +01:00
|
|
|
extras_require = setuptools_args['extras_require'] = {
|
2017-05-08 18:49:00 +01:00
|
|
|
'test:python_version=="2.7"': ['mock'],
|
|
|
|
'test': ['nose_warnings_filters', 'nose-timer'],
|
2016-07-31 16:09:21 +01:00
|
|
|
}
|
|
|
|
|
2016-08-25 07:26:11 +01:00
|
|
|
if 'setuptools' in sys.modules:
|
|
|
|
setup_args.update(setuptools_args)
|
2016-08-07 15:46:43 +01:00
|
|
|
|
2016-08-25 07:26:11 +01:00
|
|
|
if __name__ == '__main__':
|
2017-09-23 02:17:55 +01:00
|
|
|
setup(**setup_args)
|