more python fixes.

This commit is contained in:
Vítor Santos Costa 2012-10-23 10:18:24 +01:00
parent 0caac30c11
commit d2da55463f
2 changed files with 20 additions and 9 deletions

View File

@ -61,14 +61,26 @@ def _findYap():
:raises ImportError: If we cannot guess the name of the library
"""
# Now begins the guesswork
platform = sys.platform[:3]
# use YAPLIBDIR first
path=os.getenv('YAPLIBDIR')
if path is not None:
if platform == 'lin':
name = 'libYap.so'
elif platform == 'dar':
name = 'libYap.dylib'
path = os.path.join(path, name)
if os.path.exists(path):
return path
# No matter what the platform is, the first try should alway be
# find_library.
path = find_library('Yap') # or find_library('swipl') or find_library('pl')
if path is not None:
return path
# Now begins the guesswork
platform = sys.platform[:3]
if platform == 'win': # In Windows, we have the default installer path and
# the registry to look
@ -140,12 +152,6 @@ def _findYap():
if os.path.exists(path):
return path
# unix in general
path=os.getenv('YAPLIBDIR')
path = os.path.join(path, name)
if os.path.exists(path):
return path
# Last resource: see if executable is on the path
try: # try to get library path from swipl executable.
cmd = Popen(['yap', '-dump-runtime-variables'], stdout=PIPE)
@ -196,6 +202,7 @@ c_void_p = POINTER(c_void)
# Load the library
path = _findYap()
_fixWindowsPath(path)
print path
_lib = CDLL(path)
# PySWIP constants

View File

@ -46,7 +46,11 @@ python_command(Cmd) :-
start_python :-
use_foreign_library(foreign(python)),
init_python.
init_python,
python_command('import sys'),
unix(getcwd(Dir)),
atom_concat(['sys.path.append(\"',Dir,'\")'], Command),
python_command(Command).
% done