| 
									
										
										
										
											2016-08-25 01:26:11 -05: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 10:09:21 -05: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 01:26:11 -05: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 01:26:11 -05: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 01:26:11 -05: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__)) | 
					
						
							| 
									
										
										
										
											2018-03-02 21:18:24 +00:00
										 |  |  | packages = ['yap_kernel','yap_ipython'] | 
					
						
							| 
									
										
										
										
											2017-05-27 22:54:00 +01:00
										 |  |  | # pkg_root = pjoin(here, name) | 
					
						
							| 
									
										
										
										
											2017-05-08 18:49:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-12 15:11:59 +00:00
										 |  |  | for d, _, _ in os.walk(pjoin(here, 'yap_kernel')): | 
					
						
							|  |  |  |     if os.path.exists(pjoin(d, '__init__.py')): | 
					
						
							|  |  |  |         packages.append(d[len(here)+1:].replace(os.path.sep, '.')) | 
					
						
							|  |  |  | for d, _, _ in os.walk(pjoin(here, 'yap_ipython')): | 
					
						
							|  |  |  |     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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-18 14:47:27 +00:00
										 |  |  | sys.path.insert(0, here) | 
					
						
							| 
									
										
										
										
											2018-03-12 15:11:59 +00:00
										 |  |  | sys.path.insert(0, pjoin(here,'..','swig')) | 
					
						
							| 
									
										
										
										
											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 10:09:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-29 15:24:32 +00:00
										 |  |  | version_ns = {} | 
					
						
							|  |  |  | with open(pjoin(here, 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
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-29 15:24:32 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-25 01:26:11 -05: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, | 
					
						
							| 
									
										
										
										
											2018-01-29 15:24:32 +00:00
										 |  |  |     #package_dir = {'':here}, | 
					
						
							| 
									
										
										
										
											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', | 
					
						
							| 
									
										
										
										
											2018-01-29 15:24:32 +00:00
										 |  |  |     author_email    = 'yap-dev@scipy.org', | 
					
						
							| 
									
										
										
										
											2017-05-08 18:49:00 +01:00
										 |  |  |     url             = 'http://ipython.org', | 
					
						
							| 
									
										
										
										
											2016-08-25 01:26:11 -05: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 01:26:11 -05: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 10:09:21 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-25 01:26:11 -05: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
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-18 14:47:27 +00:00
										 |  |  |     argv = make_yap_kernel_cmd(executable=sys.executable) | 
					
						
							| 
									
										
										
										
											2018-01-29 15:24:32 +00:00
										 |  |  |     dest = os.path.join(here, 'yap_kernel', 'resources') | 
					
						
							| 
									
										
										
										
											2017-09-23 02:17:55 +01:00
										 |  |  |     try: | 
					
						
							|  |  |  |         write_kernel_spec(dest, overrides={'argv': argv}) | 
					
						
							|  |  |  |     except: | 
					
						
							|  |  |  |         pass | 
					
						
							|  |  |  |     # shutil.copy('${CMAKE_SOURCE_DIR}/misc/editors/prolog.js',dest) | 
					
						
							| 
									
										
										
										
											2018-01-18 14:47:27 +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-29 15:24:32 +00:00
										 |  |  | #    try: | 
					
						
							|  |  |  | #        shutil.copy( pjoin( custom_loc, "custom.js") , pjoin( custom_loc, "custom.js.orig")) | 
					
						
							|  |  |  | #        shutil.copy( pjoin( "resources", "custom.js") , pjoin( custom_loc, "custom.js")) | 
					
						
							|  |  |  | #        if not os.path.exists(mode_loc): | 
					
						
							|  |  |  | #            os.makedirs(mode_loc) | 
					
						
							|  |  |  | #        shutil.copy( pjoin( "resources","prolog.js") , mode_loc) | 
					
						
							|  |  |  | #    except: | 
					
						
							|  |  |  | #        pass | 
					
						
							| 
									
										
										
										
											2017-05-08 18:49:00 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-25 01:26:11 -05: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 10:09:21 -05:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-25 01:26:11 -05:00
										 |  |  | if 'setuptools' in sys.modules: | 
					
						
							|  |  |  |     setup_args.update(setuptools_args) | 
					
						
							| 
									
										
										
										
											2016-08-07 09:46:43 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-08-25 01:26:11 -05:00
										 |  |  | if __name__ == '__main__': | 
					
						
							| 
									
										
										
										
											2017-09-23 02:17:55 +01:00
										 |  |  |     setup(**setup_args) |