Skip to content

Commit 9c3c60d

Browse files
authored
Merge pull request #70 from saudzahirr/refactor/move_compiled_dynamic_obj_to_lib
move the shared dynamic libs to `lib`
2 parents 2c1bfa3 + 7c2a958 commit 9c3c60d

17 files changed

+54
-55
lines changed

.gitignore

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,15 @@ __pycache__/
33
*.py[cod]
44
*$py.class
55

6-
# Mac specific files
7-
.DS_Store
8-
9-
# Notepad++ backup file
10-
.bak
11-
12-
# C extensions
13-
*.so
14-
156
# Distribution / packaging
167
.Python
178
./build/
18-
.vscode
199
build/
2010
develop-eggs/
2111
dist/
2212
downloads/
2313
eggs/
2414
.eggs/
25-
lib/
2615
lib64/
2716
parts/
2817
sdist/
@@ -33,6 +22,21 @@ wheels/
3322
*.egg
3423
MANIFEST
3524

25+
# Compiled Object files
26+
*.slo
27+
*.lo
28+
*.o
29+
*.obj
30+
31+
# Compiled Dynamic libraries
32+
*.so
33+
*.dylib
34+
*.dll
35+
36+
# Exclude femzip shared libraries
37+
!**/lib/**/*.dll
38+
!**/lib/**/*.so
39+
3640
# Unit test / coverage reports
3741
htmlcov/
3842
.tox/
@@ -61,16 +65,14 @@ venv.bak/
6165
# mkdocs documentation
6266
/site
6367

64-
# Compiled Object files
65-
*.slo
66-
*.lo
67-
*.o
68-
*.obj
68+
# Mac specific files
69+
.DS_Store
6970

70-
# Compiled Dynamic libraries
71-
#*.so
72-
*.dylib
73-
*.dll
71+
# Notepad++ backup file
72+
.bak
73+
74+
# Vscode configurations
75+
.vscode
7476

7577
# Ignore generated changelog
7678
CHANGELOG.md

lasso/femzip/femzip_api.py

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
from pathlib import Path
34
import re
45
import stat
56
import sys
@@ -245,49 +246,45 @@ def api(self) -> CDLL:
245246

246247
if self._api is None:
247248

248-
bin_dirpath = (
249-
os.path.abspath(os.path.dirname(sys.executable))
250-
if hasattr(sys, "frozen")
251-
else os.path.dirname(os.path.abspath(__file__))
252-
)
249+
# Set the base path once
250+
base_path = Path(__file__).parent
253251

254-
# Flexlm Settings
255-
# prevent flexlm gui to pop up
252+
# Set environment variables for FlexLM
256253
os.environ["FLEXLM_BATCH"] = "1"
257-
# set a low timeout from originally 10 seconds
258254
if "FLEXLM_TIMEOUT" not in os.environ:
259255
os.environ["FLEXLM_TIMEOUT"] = "200000"
260256

261-
# windows
262-
if "win32" in sys.platform:
263-
257+
# Platform-specific configurations
258+
if sys.platform == "win32":
259+
bin_dirpath = base_path / "lib" / "windows"
264260
shared_lib_name = "api_extended.dll"
265-
self.load_dynamic_library(os.path.join(bin_dirpath, "libmmd.dll"))
266-
self.load_dynamic_library(os.path.join(bin_dirpath, "libifcoremd.dll"))
267-
self.load_dynamic_library(os.path.join(bin_dirpath, "libifportmd.dll"))
268-
self.load_dynamic_library(os.path.join(bin_dirpath, "libiomp5md.dll"))
269-
self.load_dynamic_library(
270-
os.path.join(bin_dirpath, "femzip_a_dyna_sidact_generic.dll")
271-
)
272-
self.load_dynamic_library(
273-
os.path.join(bin_dirpath, "libfemzip_post_licgenerator_ext_flexlm.dll")
274-
)
275-
# linux hopefully
261+
libs = [
262+
"libmmd.dll",
263+
"libifcoremd.dll",
264+
"libifportmd.dll",
265+
"libiomp5md.dll",
266+
"femzip_a_dyna_sidact_generic.dll",
267+
"libfemzip_post_licgenerator_ext_flexlm.dll",
268+
]
276269
else:
270+
bin_dirpath = base_path / "lib" / "linux"
277271
shared_lib_name = "api_extended.so"
278-
self.load_dynamic_library(os.path.join(bin_dirpath, "libiomp5.so"))
279-
self.load_dynamic_library(os.path.join(bin_dirpath, "libintlc.so.5"))
280-
self.load_dynamic_library(os.path.join(bin_dirpath, "libirng.so"))
281-
self.load_dynamic_library(os.path.join(bin_dirpath, "libimf.so"))
282-
self.load_dynamic_library(os.path.join(bin_dirpath, "libsvml.so"))
283-
self.load_dynamic_library(
284-
os.path.join(bin_dirpath, "libfemzip_a_dyna_sidact_generic.so")
285-
)
286-
self.load_dynamic_library(
287-
os.path.join(bin_dirpath, "libfemzip_post_licgenerator_ext_flexlm.so")
288-
)
289-
290-
filepath = os.path.join(bin_dirpath, shared_lib_name)
272+
libs = [
273+
"libiomp5.so",
274+
"libintlc.so.5",
275+
"libirng.so",
276+
"libimf.so",
277+
"libsvml.so",
278+
"libfemzip_a_dyna_sidact_generic.so",
279+
"libfemzip_post_licgenerator_ext_flexlm.so",
280+
]
281+
282+
# Load all the dynamic libraries
283+
for lib in libs:
284+
self.load_dynamic_library(bin_dirpath / lib)
285+
286+
# Load the main shared library
287+
filepath = bin_dirpath / shared_lib_name
291288
self._api = self.load_dynamic_library(filepath)
292289

293290
# license check
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)