Skip to content

Commit d51c420

Browse files
authored
Merge pull request #6 from z3rone-org/fix/macos-tests
Fix macos tests and implement isolation window and collision energy
2 parents dd2a441 + 832c506 commit d51c420

27 files changed

Lines changed: 1868 additions & 617 deletions

File tree

.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[flake8]
2+
max-line-length = 160
3+
extend-ignore = E203, W503, E501, E722, F403, F405, E741, F811, F401

.github/patch_fisher_py.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import re
32
import site
43
import sys
54

@@ -8,14 +7,11 @@ def get_fisher_py_path():
87
path = os.path.join(site_pkg, 'fisher_py')
98
if os.path.exists(path):
109
return path
11-
12-
# Also check virtual environments where site.getsitepackages() might be missing
1310
for p in sys.path:
1411
path = os.path.join(p, 'fisher_py')
1512
if os.path.exists(path):
1613
return path
17-
18-
raise RuntimeError("fisher_py not found in sys.path or site-packages")
14+
raise RuntimeError("fisher_py not found")
1915

2016
def patch_fisher_py():
2117
try:
@@ -25,34 +21,38 @@ def patch_fisher_py():
2521
with open(init_file, 'r') as f:
2622
content = f.read()
2723

28-
# Add import sys if needed
29-
if "import sys" not in content:
30-
content = "import sys\n" + content
31-
32-
# Ensure sys.path.append(dll_path) is added
33-
if "sys.path.append(os.path.realpath(dll_path))" not in content:
34-
content = content.replace("clr.AddReference('mscorlib')", "clr.AddReference('mscorlib')\nsys.path.append(os.path.realpath(dll_path))")
24+
if "from System.Reflection import Assembly" not in content:
25+
content = content.replace("from System import Environment", "from System import Environment\nfrom System.Reflection import Assembly")
26+
27+
import re
28+
29+
# Add helper function at the top of the file after imports
30+
helper = """
31+
def _safe_load_assembly(path):
32+
try:
33+
Assembly.LoadFrom(path)
34+
except Exception:
35+
pass
36+
"""
37+
if "_safe_load_assembly" not in content:
38+
content = content.replace("import os", "import os\n" + helper, 1)
39+
40+
def replacer(match):
41+
original = match.group(1)
42+
return f"_safe_load_assembly(os.path.realpath({original}))"
3543

36-
# Replace clr.AddReference(os.path.join(dll_path, 'AssemblyName.dll'))
37-
# with clr.AddReference('AssemblyName')
38-
content = re.sub(
39-
r"clr\.AddReference\((?:os\.path\.join\()?dll_path,\s*'([^']+)\.dll'(?:\))?\)",
40-
r"clr.AddReference('\1')",
41-
content
42-
)
43-
# Also clean up any lingering Assembly.LoadFrom from previous patches just in case
4444
content = re.sub(
45-
r"Assembly\.LoadFrom\(os\.path\.realpath\(os\.path\.join\(dll_path,\s*'([^']+)\.dll'\)\)\)",
46-
r"clr.AddReference('\1')",
45+
r"clr\.AddReference\((os\.path\.join\(dll_path,\s*'[^']+'\))\)",
46+
replacer,
4747
content
4848
)
49-
49+
5050
with open(init_file, 'w') as f:
5151
f.write(content)
5252

5353
print(f"Successfully patched {init_file}")
5454
except Exception as e:
55-
print(f"Failed to patch fisher_py: {e}")
55+
print(f"Failed to patch: {e}")
5656
sys.exit(1)
5757

5858
if __name__ == '__main__':

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ jobs:
7575
with:
7676
python-version: '3.9'
7777

78+
- name: Copy README
79+
run: cp README.md native_fisher_py/
80+
7881
- name: Build wheels
7982
uses: PyO3/maturin-action@v1
8083
with:

0 commit comments

Comments
 (0)