Skip to content

Commit 8fc7f0d

Browse files
committed
Update setup.py
1 parent dd26f36 commit 8fc7f0d

1 file changed

Lines changed: 29 additions & 44 deletions

File tree

setup.py

Lines changed: 29 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -372,54 +372,36 @@ def run(self):
372372
)
373373
print(f"Copied SuperLU DLL: {dll_file} to {dest_path}")
374374

375-
# Handle Linux and macOS - ensure extension modules are in their proper locations
375+
# Handle Linux and macOS - ensure extension modules have the right permissions
376376
elif platform.system() in ('Linux', 'Darwin'):
377-
import shutil
378-
379-
# Define the target directories
380-
target_superlu_dir = os.path.join(package_dir, "sparse_superlu")
381-
target_umfpack_dir = os.path.join(package_dir, "sparse_umfpack")
382-
383-
# Ensure target directories exist
384-
os.makedirs(target_superlu_dir, exist_ok=True)
385-
os.makedirs(target_umfpack_dir, exist_ok=True)
386-
387-
# Check if extensions were built
388-
if os.path.exists(ext_path_superlu):
389-
# Get just the filename from the path
390-
ext_superlu_filename = os.path.basename(ext_path_superlu)
391-
target_path = os.path.join(target_superlu_dir, ext_superlu_filename)
392-
393-
# Copy the extension file to the target directory
394-
print(f"Copying SuperLU extension from {ext_path_superlu} to {target_path}")
395-
shutil.copy(ext_path_superlu, target_path)
396-
397-
# Set executable permissions
377+
# The extensions are already in the right place, we just need to ensure they have
378+
# the right permissions
379+
try:
398380
import stat
399-
os.chmod(target_path, os.stat(target_path).st_mode | stat.S_IEXEC)
400-
print(f"Set executable permissions on {target_path}")
401-
else:
402-
print(f"WARNING: SuperLU extension not found at {ext_path_superlu}")
403381

404-
if os.path.exists(ext_path_umfpack):
405-
# Get just the filename from the path
406-
ext_umfpack_filename = os.path.basename(ext_path_umfpack)
407-
target_path = os.path.join(target_umfpack_dir, ext_umfpack_filename)
382+
# Set executable permissions for SuperLU extension
383+
if os.path.exists(ext_path_superlu):
384+
print(f"Setting executable permissions on SuperLU extension: {ext_path_superlu}")
385+
os.chmod(ext_path_superlu, os.stat(ext_path_superlu).st_mode | stat.S_IEXEC)
386+
else:
387+
print(f"WARNING: SuperLU extension not found at {ext_path_superlu}")
408388

409-
# Copy the extension file to the target directory
410-
print(f"Copying UMFPACK extension from {ext_path_umfpack} to {target_path}")
411-
shutil.copy(ext_path_umfpack, target_path)
389+
# Set executable permissions for UMFPACK extension
390+
if os.path.exists(ext_path_umfpack):
391+
print(f"Setting executable permissions on UMFPACK extension: {ext_path_umfpack}")
392+
os.chmod(ext_path_umfpack, os.stat(ext_path_umfpack).st_mode | stat.S_IEXEC)
393+
else:
394+
print(f"WARNING: UMFPACK extension not found at {ext_path_umfpack}")
412395

413-
# Set executable permissions
414-
import stat
415-
os.chmod(target_path, os.stat(target_path).st_mode | stat.S_IEXEC)
416-
print(f"Set executable permissions on {target_path}")
417-
else:
418-
print(f"WARNING: UMFPACK extension not found at {ext_path_umfpack}")
396+
# Verify the extensions exist in their directories
397+
superlu_dir = os.path.dirname(ext_path_superlu)
398+
umfpack_dir = os.path.dirname(ext_path_umfpack)
419399

420-
# List contents of directories to verify
421-
print(f"Contents of {target_superlu_dir}: {os.listdir(target_superlu_dir)}")
422-
print(f"Contents of {target_umfpack_dir}: {os.listdir(target_umfpack_dir)}")
400+
print(f"Contents of SuperLU directory: {os.listdir(superlu_dir)}")
401+
print(f"Contents of UMFPACK directory: {os.listdir(umfpack_dir)}")
402+
403+
except Exception as e:
404+
print(f"Error setting permissions on extensions: {e}")
423405

424406

425407
# Define platform-specific package data
@@ -431,6 +413,7 @@ def run(self):
431413
package_data['sparse_numba'] = [
432414
'vendor/superlu/bin/*.dll',
433415
'vendor/openblas/bin/*.dll',
416+
'**/*.pyd', # For Windows
434417
'sparse_superlu/*.py',
435418
'sparse_superlu/*.pyd',
436419
'sparse_superlu/test/*.py',
@@ -440,6 +423,7 @@ def run(self):
440423
]
441424
elif IS_LINUX:
442425
package_data['sparse_numba'] = [
426+
'**/*.so', # Include all .so files
443427
'sparse_superlu/*.py',
444428
'sparse_superlu/*.so',
445429
'sparse_superlu/test/*.py',
@@ -449,11 +433,12 @@ def run(self):
449433
]
450434
elif IS_MACOS:
451435
package_data['sparse_numba'] = [
436+
'**/*.so', # Include all .so files
452437
'sparse_superlu/*.py',
453-
'sparse_superlu/*.dylib',
438+
'sparse_superlu/*.so',
454439
'sparse_superlu/test/*.py',
455440
'sparse_umfpack/*.py',
456-
'sparse_umfpack/*.dylib',
441+
'sparse_umfpack/*.so',
457442
'sparse_umfpack/test/*.py'
458443
]
459444

0 commit comments

Comments
 (0)