This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
yap-6.3/packages/python/swig/setup.py.in

181 lines
5.9 KiB
Python
Raw Normal View History

#!/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
2017-09-06 01:09:46 +01:00
import setuptools
from setuptools import setup
from setuptools.extension import Extension
from codecs import open
from os import path, makedirs, walk
from shutil import copytree, rmtree, copy2, move
2017-10-04 09:18:17 +01:00
import sysconfig
from glob import glob
from pathlib import Path
import platform
import os.path
# the name of the package
name = 'YAP4PY'
# -----------------------------------------------------------------------------
# Minimal Python version sanity check
# -----------------------------------------------------------------------------
import sys
v = sys.version_info
if v[:2] < (2, 7) or (v[0] >= 3 and v[:2] < (3, 3)):
error = "ERROR: %s requires Python version 2.7 or 3.3 or above." % name
print(error, file=sys.stderr)
sys.exit(1)
PY3 = (sys.version_info[0] >= 3)
# -----------------------------------------------------------------------------
# get on with it
# -----------------------------------------------------------------------------
from codecs import open
from os import path, makedirs, walk
from shutil import copytree, rmtree, copy2, move
from glob import glob
from pathlib import Path
import platform
2017-10-04 09:18:17 +01:00
from os.path import dirname, join,abspath
import os
import shutil
from distutils.core import setup
2017-10-04 09:18:17 +01:00
here = abspath(dirname(__file__))
libpydir = abspath(dirname(os.path.dirname('stdlib')))
libpyauxdir = abspath(os.path.dirname('stdlib'))
#pkg_root = join(here, name)
2017-09-06 01:09:46 +01:00
sys.path.insert(0, "${CMAKE_CURRENT_SOURCE_DIR}")
my_extra_link_args = []
if platform.system() == 'Windows':
local_libs = []
win_libs = ['wsock32','ws2_32']
my_extra_link_args = ['-Wl,-export-all-symbols']
else:
# if platform.system() == 'Darwin':
2017-10-04 09:18:17 +01:00
my_extra_link_args = ['-Wl,-rpath', '-Wl,'+libpydir,'-Wl,-rpath', '-Wl,'+libpyauxdir, ]
win_libs = []
2017-10-04 09:18:17 +01:00
local_libs = ['Py4YAP']
# or dll in glob('yap/dlls/*'):
# move( dll ,'lib' )
2017-10-04 09:18:17 +01:00
native_sources = ["yap.i",'yapi.cpp']
2017-09-06 01:09:46 +01:00
2017-10-04 09:18:17 +01:00
for i in '${PYTHON_SOURCES}'.split(";"):
2017-09-06 01:09:46 +01:00
copy2(i, 'yap4py')
for i in '${pl_library}'.split(";") + '${pl_swi_library}'.split(";") :
copy2(i, 'yap4py/prolog')
for i in '${pl_os_library}'.split(";") :
copy2(i, 'yap4py/prolog/os')
for i in '${pl_boot_library}'.split(";") :
copy2(i, 'yap4py/prolog/pl')
my_libs0 = '${YAP_DLLS}'.split(";")+['${CMAKE_BINARY_DIR}/startup.yss']
my_libs = []
for i in my_libs0:
my_libs = glob(i) + my_libs
for i in my_libs:
copy2(i, 'yap4py')
2017-10-04 09:18:17 +01:00
my_includes = ['${CMAKE_SOURCE_DIR}/CXX', '${CMAKE_SOURCE_DIR}/include',
'${CMAKE_SOURCE_DIR}/H', '${CMAKE_SOURCE_DIR}/H/generated',
'${CMAKE_SOURCE_DIR}/os', '${CMAKE_SOURCE_DIR}/OPTYap',
'${CMAKE_SOURCE_DIR}/utf8proc',
'${CMAKE_SOURCE_DIR}/packages/python',
'${CMAKE_BINARY_DIR}']
for i in my_includes:
includes = glob(i+"/*.??h")
for j in includes:
copy2(j, 'yap4py/include')
here = path.abspath(path.dirname(__file__))
2017-09-06 01:09:46 +01:00
#gmp_dir = path.abspath(path.dirname("${GMP_LIBRARIES}"))
#python_libdir = path.abspath(path.dirname("${PYTHON_LIBRARIES}")
# Get the long description from the README file
extensions = [Extension('_yap', native_sources,
define_macros=[('MAJOR_VERSION', '1'),
('MINOR_VERSION', '0'),
('_YAP_NOT_INSTALLED_', '1'),
('YAP_PYTHON', '1'),
('_GNU_SOURCE', '1')],
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}', '${gmp_dir}', '${python_libdir}'],
swig_opts=['-modern', '-c++', '-py3',
2017-10-04 09:18:17 +01:00
'-DX_API', '-Iyap4py/include' ],
library_dirs=['../../..', '../../../CXX', 'yap4py/include', '..', "${bindir}"],
extra_link_args=my_extra_link_args,
libraries=['Yap','gmp']+win_libs+local_libs,
2017-10-04 09:18:17 +01:00
include_dirs=['yap4py/include']
)]
2017-10-04 09:18:17 +01:00
packages = setuptools.find_packages('${CMAKE_CURRENT_SOURCE_DIR}')
package_data = {
2017-09-06 01:09:46 +01:00
'yap4py/prolog': 'prolog/*.*',
'': '*.*'
}
version_ns = {'__version__': '6.3.5', 'minor-version': '6', 'minor-version': '3', 'patch': '5'}
setup_args = dict(
name=name,
version=version_ns['__version__'],
2017-10-04 09:18:17 +01:00
scripts=glob(join('scripts', '*')),
packages=packages,
2017-09-06 01:09:46 +01:00
py_modules=['yap','yap4py'],
package_data=package_data,
include_package_data=True,
2017-10-04 09:18:17 +01:00
# requirements=[
# 'm2w64-gmp',
# 'm2-msys2-keyring',
# 'm2-msys2-launcher-git',
# 'm2-msys2-runtime',
# ],
description="YAP in Python",
author='YAP Development Team',
2017-10-04 09:18:17 +01:00
author_email='vsc@dcc.fc.up.pt',
url='http://www.dcc.fc.up/~vsc/yap',
license='BSD',
ext_modules=extensions,
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',
'Programming Language :: Python',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
],
)
if 'develop' in sys.argv or any(a.startswith('bdist') for a in sys.argv):
import setuptools
setuptools_args = {}
install_requires = setuptools_args['install_requires'] = [
]
extras_require = setuptools_args['extras_require'] = {
'test:python_version=="2.7"': ['mock'],
'test': ['nose_warnings_filters', 'nose-timer'],
}
if 'setuptools' in sys.modules:
setup_args.update(setuptools_args)
if __name__ == '__main__':
setup(**setup_args)