This commit is contained in:
Vitor Santos Costa
2017-06-12 18:00:47 +01:00
parent c2f6d968c3
commit 0d96197ddf
47 changed files with 3580 additions and 3581 deletions

View File

@@ -7,7 +7,10 @@ set (PYTHON_HEADERS python.h)
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
add_library (YAPPython SHARED ${PYTHON_SOURCES})
add_library (YAPPython0 OBJECT ${PYTHON_SOURCES})
if (WIN32)
add_library (YAPPython SHARED pyload.c )
endif()
# arithmetic hassle.
set_property(TARGET YAPPython PROPERTY CXX_STANDARD 11)

View File

@@ -1,5 +1,5 @@
#include "python.h"
#include "py4yap.h"
static foreign_t array_to_python_list(term_t addr, term_t type, term_t szt,
term_t py) {

View File

@@ -1,6 +1,6 @@
#include "python.h"
#include "py4yap.h"
extern PyObject *py_Local, *py_Global;

View File

@@ -1,5 +1,5 @@
#include "python.h"
#include "py4yap.h"
static foreign_t repr_term(PyObject *pVal, term_t t) {
term_t to = PL_new_term_ref(), t1 = PL_new_term_ref();

View File

@@ -23,6 +23,12 @@
#define EXTRA_MESSSAGES 1
#ifndef PYTHON_H
#define X_API
#define I_API
#define O_API
#define PYTHON_H 1
PyObject *find_obj(PyObject *ob, term_t lhs, bool eval);

View File

@@ -1,4 +1,4 @@
#include "python.h"
#include "py4yap.h"
/**
*
@@ -700,6 +700,7 @@ static PyObject *structseq_repr(PyObject *iobj) {
}
#endif
PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
PyObject *o;
#if PY_MAJOR_VERSION >= 3
@@ -722,7 +723,7 @@ PyObject *term_to_nametuple(const char *s, arity_t arity, PyObject *tuple) {
return NULL;
typp->tp_flags &= ~Py_TPFLAGS_HEAPTYPE;
// typp->tp_str = structseq_str;
// typp->tp_repr = structseq_repr;
typp->tp_repr = structseq_repr;
// typp = PyStructSequence_NewType(desc);
// don't do this: we cannot add a type as an atribute.
//PyModule_AddObject(py_Main, s, (PyObject *)typp);

27
packages/python/pyload.c Normal file
View File

@@ -0,0 +1,27 @@
#include "py4yap.h"
X_API bool init_python(void) {
return true;
}
#ifdef _WIN32
#include <windows.h>
int WINAPI win_python(HANDLE, DWORD, LPVOID);
int WINAPI win_python(HANDLE hinst, DWORD reason, LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return 1;
}
#endif

View File

@@ -1,5 +1,5 @@
#include "python.h"
#include "py4yap.h"
PyObject *py_Main;

View File

@@ -1,6 +1,5 @@
#include "python.h"
#include <YapStreams.h>
#include "py4yap.h"
#include <VFS.h>
atom_t ATOM_true, ATOM_false, ATOM_colon, ATOM_dot, ATOM_none, ATOM_t,
@@ -207,29 +206,3 @@ X_API bool do_init_python(void) {
return true;
}
X_API bool init_python(void) {
if (python_in_python)
return true;
return do_init_python();
}
#ifdef _WIN32
#include <windows.h>
int WINAPI win_python(HANDLE, DWORD, LPVOID);
int WINAPI win_python(HANDLE hinst, DWORD reason, LPVOID reserved) {
switch (reason) {
case DLL_PROCESS_ATTACH:
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
return 1;
}
#endif

View File

@@ -1,7 +1,7 @@
# This is a CMake example for Python
INCLUDE(NewUseSWIG)
#INCLUDE(NewUseSWIG)
include(FindPythonModule)
@@ -23,22 +23,6 @@ SET_SOURCE_FILES_PROPERTIES(../../swig/yap.i PROPERTIES SWIG_FLAGS "-O;-py3")
SET_SOURCE_FILES_PROPERTIES(../../swiyap.i PROPERTIES SWIG_MODULE_NAME yap)
#SET_SOURCE_FILES_PROPERTIES(../../swi/yap.i PROPERTIES OUTPUT_NAME yap)
SWIG_ADD_LIBRARY(Py2YAP LANGUAGE python SHARED SOURCES ../../swig/yap.i )
if (WIN32)
SWIG_LINK_LIBRARIES(Py2YAP YAPPython libYap ${PYTHON_LIBRARIES} )
else()
SWIG_LINK_LIBRARIES( Py2YAP libYap YAP++ YAPPython ${PYTHON_LIBRARIES} )
endif()
set_target_properties ( ${SWIG_MODULE_Py2YAP_REAL_NAME}
PROPERTIES
NO_SONAME ON
CXXFLAGS "-include cmath "
OUTPUT_NAME _yap
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
DEPENDS YAPPython YAPPython YAP++
)
SET( CMAKE_CXX_FLAGS " -include cmath ${CMAKE_CXX_FLAGS} " )
# inform we are compiling YAP
# s used in MSYS
@@ -65,9 +49,12 @@ endif()
set (PL ${pl_library} ${PROLOG_SOURCES} )
add_custom_target( YAP4PY_SETUP
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
COMMAND ${CMAKE_COMMAND} -E copy ${dlls} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
add_custom_target( YAP4PY_SETUP
COMMAND ${CMAKE_COMMAND} -E touch ${CMAKE_CURRENT_BINARY_DIR}/yap.py
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/packages/swig/yap.i ${CMAKE_CURRENT_BINARY_DIR}/yap.i
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py
COMMAND ${CMAKE_COMMAND} -E copy ${dlls} ${CMAKE_BINARY_DIR}/libYap${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_BINARY_DIR}/${YAP_STARTUP} ${PYTHON_SOURCES} ${CMAKE_CURRENT_BINARY_DIR}/yap4py
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
COMMAND ${CMAKE_COMMAND} -E copy ${PL} ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog
COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/yap4py/prolog/pl

View File

@@ -1,3 +0,0 @@
// make Python happy...

View File

@@ -6,7 +6,7 @@
from __future__ import print_function
from setuptools import setup
from setuptools.extension import Extension
from setuptools.extension import Extension
from codecs import open
from os import path, makedirs, walk
from shutil import copytree, rmtree, copy2, move
@@ -18,23 +18,23 @@ 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)):
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
@@ -53,85 +53,86 @@ pkg_root = pjoin(here, name)
my_extra_link_args = []
if platform.system() == 'Darwin':
my_extra_link_args = ['-Wl,-rpath','-Wl,${_ABS_PYTHON_MODULE_PATH}']
so = 'dylib'
#or dll in glob('yap/dlls/*'):
my_extra_link_args = ['-Wl,-rpath', '-Wl,${_ABS_PYTHON_MODULE_PATH}']
# or dll in glob('yap/dlls/*'):
# move( dll ,'lib' )
elif platform.system() == 'Windows':
my_extra_link_args = ['-Wl,-export-all-symbols','-Wl,-enable-auto-import','-Wl,-enable-runtime-pseudo-relocs']
cplus = ['']
bpy2yap = ['${CMAKE_SOURCE_DIR}/packages/python/python.c',
'${CMAKE_SOURCE_DIR}/packages/python/pl2py.c',
'${CMAKE_SOURCE_DIR}/packages/python/pybips.c',
'${CMAKE_SOURCE_DIR}/packages/python/py2pl.c',
'${CMAKE_SOURCE_DIR}/packages/python/pl2pl.c',
'${CMAKE_SOURCE_DIR}/packages/python/pypreds.c'
]
cplus=['${RELATIVE_SOURCE}CXX/yapi.cpp']
py2yap=['${RELATIVE_SOURCE}packages/python/python.c',
'${RELATIVE_SOURCE}packages/python/pl2py.c',
'${RELATIVE_SOURCE}packages/python/pybips.c',
'${RELATIVE_SOURCE}packages/python/py2pl.c',
'${RELATIVE_SOURCE}packages/python/pl2pl.c',
'${RELATIVE_SOURCE}packages/python/pypreds.c'
]
native_sources = ['yapPYTHON_wrap.cxx']+py2yap+cplus
native_sources = ['yap.i']
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
extensions=[Extension('_yap', native_sources,
define_macros = [('MAJOR_VERSION', '1'),
extensions = [Extension('_yap', native_sources,
define_macros=[('MAJOR_VERSION', '1'),
('MINOR_VERSION', '0'),
('_YAP_NOT_INSTALLED_', '1'),
('_GNU_SOURCE', '1'),
('YAP_PYTHON', '1')],
runtime_library_dirs=['yap4py','${libdir}','${bindir}'],
swig_opts=['-modern', '-c++', '-py3','-I${RELATIVE_SOURCE}/CXX'],
library_dirs=['../../..','../../../CXX','../../packages/python',"${dlls}","${bindir}", '.'],
extra_link_args=my_extra_link_args,
extra_compile_args=['-std=c++11','-g3','-O0'],
libraries=['Yap','${GMP_LIBRARIES}'],
include_dirs=['../../..',
'${GMP_INCLUDE_DIRS}',
'${RELATIVE_SOURCE}H',
'${RELATIVE_SOURCE}H/generated',
'${RELATIVE_SOURCE}OPTYap',
'${RELATIVE_SOURCE}os',
'${RELATIVE_SOURCE}include',
'${RELATIVE_SOURCE}CXX', '.']
)]
runtime_library_dirs=['yap4py', '${libdir}', '${bindir}'],
swig_opts=['-modern', '-c++', '-py3', '-I${CMAKE_SOURCE_DIR}/CXX', '-I${CMAKE_SOURCE_DIR}/include',
'-I${CMAKE_SOURCE_DIR}/H', '-I${CMAKE_SOURCE_DIR}/H/generated',
'-I${CMAKE_SOURCE_DIR}/os', '-I${CMAKE_SOURCE_DIR}/OPTYap', '-I../../..'],
library_dirs=['../../..', '../../../CXX', '../../packages/python', "${dlls}", "${bindir}", '.'],
extra_link_args=my_extra_link_args,
libraries=['Yap', '${GMP_LIBRARIES}'],
include_dirs=['../../..',
'${GMP_INCLUDE_DIRS}',
'${CMAKE_SOURCE_DIR}/H',
'${CMAKE_SOURCE_DIR}/H/generated',
'${CMAKE_SOURCE_DIR}/OPTYap',
'${CMAKE_SOURCE_DIR}/os',
'${CMAKE_SOURCE_DIR}/include',
'${CMAKE_SOURCE_DIR}/CXX', '.']
)]
packages = ['yap4py']
def visit(d0, pls):
for (r,ds,fs) in walk('.'):
for (r, ds, fs) in walk('.'):
for f in fs:
f0,ext = os.path.splitext(f)
f0, ext = os.path.splitext(f)
if (ext == 'yap' or ext == 'pl' or ext == 'so' or ext == 'dll' or ext == 'yss'):
pls += [os.path.join(r, f)]
for i in ds:
pls = visit(os.path.join(d0, i), pls)
return pls
package_data = {
'': visit('.',[])
'': visit('.', [])
}
version_ns = {'__version__':'6.3.5','minor-version':'6','minor-version':'3','patch':'5'}
version_ns = {'__version__': '6.3.5', 'minor-version': '6', 'minor-version': '3', 'patch': '5'}
setup_args = dict(
name = name,
version = version_ns['__version__'],
scripts = glob(pjoin('scripts', '*')),
packages = packages,
py_modules = ['yap'],
package_data = package_data,
include_package_data = True,
description = "YAP in Python",
author = 'YAP Development Team',
author_email = 'ipython-dev@scipy.org',
url = 'http://ipython.org',
license = 'BSD',
ext_modules = extensions,
platforms = "Linux, Mac OS X, Windows",
keywords = ['Interactive', 'Interpreter', 'Shell', 'Web'],
classifiers = [
name=name,
version=version_ns['__version__'],
scripts=glob(pjoin('scripts', '*')),
packages=packages,
py_modules=['yap'],
package_data=package_data,
include_package_data=True,
description="YAP in Python",
author='YAP Development Team',
author_email='ipython-dev@scipy.org',
url='http://ipython.org',
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',

View File

@@ -1,10 +0,0 @@
Metadata-Version: 1.0
Name: yapex
Version: 0.1
Summary: UNKNOWN
Home-page: UNKNOWN
Author: UNKNOWN
Author-email: UNKNOWN
License: UNKNOWN
Description: UNKNOWN
Platform: UNKNOWN

View File

@@ -1,11 +0,0 @@
setup.py
/Users/vsc/Yap/yap-6.3/packages/python/yapex.py
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/PKG-INFO
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/SOURCES.txt
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/dependency_links.txt
/Users/vsc/Yap/yap-6.3/packages/python/yapex.egg-info/top_level.txt
/Users/vsc/github/yap-6.3/packages/python/yapex.py
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/PKG-INFO
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/SOURCES.txt
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/dependency_links.txt
/Users/vsc/github/yap-6.3/packages/python/yapex.egg-info/top_level.txt

View File

@@ -1 +0,0 @@
yapex