Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
#17682: More generic shared library file extension
Browse files Browse the repository at this point in the history
  • Loading branch information
sgouezel committed Apr 22, 2015
1 parent 9b1e098 commit e27535b
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
7 changes: 2 additions & 5 deletions src/sage/misc/cython.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,11 +543,8 @@ def cython(filename, verbose=False, compile_message=False,

if create_local_so_file:
# Copy from lib directory into local directory
libext = 'so'
UNAME = os.uname()[0].lower()
if UNAME[:6] == 'cygwin':
libext = 'dll'
cmd = 'cp %s/%s.%s %s'%(build_dir, name, libext, os.path.abspath(os.curdir))
from sage.misc.sageinspect import generic_so_extension
cmd = 'cp %s/%s%s %s'%(build_dir, name, generic_so_extension, os.path.abspath(os.curdir))
if os.system(cmd):
raise RuntimeError("Error making local copy of shared object library for {}".format(filename))

Expand Down
10 changes: 8 additions & 2 deletions src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,15 @@ def foo(unsigned int x=1, a=')"', b={not (2+1==3):'bar'}, *args, **kwds): return
import os
import tokenize
import types
import sys
EMBEDDED_MODE = False
from sage.env import SAGE_SRC

if sys.platform == 'cygwin':
generic_so_extension = os.path.extsep + 'dll'
else:
generic_so_extension = os.path.extsep + 'so'

def isclassinstance(obj):
r"""
Checks if argument is instance of non built-in class
Expand Down Expand Up @@ -1175,8 +1181,8 @@ def sage_getfile(obj):

# No go? fall back to inspect.
sourcefile = inspect.getabsfile(obj)
if sourcefile.endswith(os.path.extsep+'so'):
return sourcefile[:-3]+os.path.extsep+'pyx'
if sourcefile.endswith(generic_so_extension):
return sourcefile[:-len(generic_so_extension)]+os.path.extsep+'pyx'
return sourcefile

def sage_getargspec(obj):
Expand Down
11 changes: 4 additions & 7 deletions src/sage_setup/clean.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,14 @@ def _find_stale_files(site_packages, python_packages, python_modules, ext_module
extension modules::
sage: stale_iter = _find_stale_files(SAGE_LIB, python_packages, python_modules, [])
sage: from sage.misc.sageinspect import generic_so_extension
sage: for f in stale_iter:
....: if f.endswith('.so'): continue
....: if f.endswith(generic_so_extension): continue
....: print('Found stale file: ' + f)
"""
PYMOD_EXTS = (os.path.extsep + 'py', os.path.extsep + 'pyc')
import sys
if sys.platform == 'cygwin':
LIBEXT = 'dll'
else:
LIBEXT = 'so'
CEXTMOD_EXTS = (os.path.extsep + LIBEXT,)
from sage.misc.sageinspect import generic_so_extension
CEXTMOD_EXTS = (generic_so_extension,)
INIT_FILES= map(lambda x: '__init__' + x, PYMOD_EXTS)

module_files = installed_files_by_module(site_packages, ['sage', 'sage_setup'])
Expand Down
6 changes: 4 additions & 2 deletions src/sage_setup/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def installed_files_by_module(site_packages, modules=('sage',)):
sage: from site import getsitepackages
sage: site_packages = getsitepackages()[0]
sage: files_by_module = installed_files_by_module(site_packages)
sage: files_by_module['sage.structure.sage_object']
{'sage/structure/sage_object.so'}
sage: from sage.misc.sageinspect import generic_so_extension
sage: files_by_module['sage.structure.sage_object'] == \
....: {'sage/structure/sage_object' + generic_so_extension}
True
sage: sorted(files_by_module['sage.structure'])
['sage/structure/__init__.py', 'sage/structure/__init__.pyc']
Expand Down

0 comments on commit e27535b

Please sign in to comment.