Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions .github/patch_fisher_py.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,25 @@ def patch_fisher_py():
with open(init_file, 'r') as f:
content = f.read()

# Add import System.Reflection if needed
if "from System.Reflection import Assembly" not in content:
content = content.replace("from System import Environment", "from System import Environment\nfrom System.Reflection import Assembly")
# Add import sys if needed
if "import sys" not in content:
content = "import sys\n" + content

# Replace clr.AddReference(os.path.join(dll_path, '...'))
# with Assembly.LoadFrom(os.path.realpath(os.path.join(dll_path, '...')))
# Ensure sys.path.append(dll_path) is added
if "sys.path.append(os.path.realpath(dll_path))" not in content:
content = content.replace("clr.AddReference('mscorlib')", "clr.AddReference('mscorlib')\nsys.path.append(os.path.realpath(dll_path))")

# Replace clr.AddReference(os.path.join(dll_path, 'AssemblyName.dll'))
# with clr.AddReference('AssemblyName')
content = re.sub(
r"clr\.AddReference\((?:os\.path\.join\()?dll_path,\s*'([^']+)\.dll'(?:\))?\)",
r"clr.AddReference('\1')",
content
)
# Also clean up any lingering Assembly.LoadFrom from previous patches just in case
content = re.sub(
r"clr\.AddReference\((os\.path\.join\(dll_path, '[^']+'\))\)",
r"Assembly.LoadFrom(os.path.realpath(\1))",
r"Assembly\.LoadFrom\(os\.path\.realpath\(os\.path\.join\(dll_path,\s*'([^']+)\.dll'\)\)\)",
r"clr.AddReference('\1')",
content
)

Expand Down
12 changes: 9 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
branches: [ main, development ]

jobs:
test:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.11'

- name: Install Rust
uses: dtolnay/rust-toolchain@stable
Expand All @@ -63,6 +63,9 @@ jobs:
pip install maturin pytest numpy
pip install fisher-py

- name: Decompress test data
run: gunzip -d -k test_data/*.gz

- name: Build and test
run: |
source .venv/bin/activate
Expand All @@ -72,7 +75,10 @@ jobs:
cp ${{ env.DYLIB_PATH }} native_fisher_py/python/native_fisher_py/

# Install the package
pip install ./native_fisher_py
cp README.md native_fisher_py/
cd native_fisher_py
maturin develop
cd ..

# Parity tests will automatically fall back to ground_truth.json if fisher-py fails
python -m pytest tests
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ coverage.xml
venv/
pip-log.txt
pip-delete-this-directory.txt
Pipfile
Pipfile.lock
.python-version

# Rust
target/
Expand All @@ -68,3 +71,7 @@ publish_output*.txt
_build/
/tmp/
venv3.11/pyvenv.cfg
/scratch

# Downloadable test data
test_data/*.raw
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,14 @@ cd ../..
# Copy the built library into the python package directory
# This allows maturin to include it in the wheel
cp $DYLIB_PATH native_fisher_py/python/native_fisher_py/
cp vendor/RawFileReader/Libs/NetCore/Net8/Assemblies/*.dll native_fisher_py/python/native_fisher_py/

# 2. Build Python Package
cd native_fisher_py
export THERMO_NATIVE_LIB=$(pwd)/python/native_fisher_py/$LIB_NAME

# Check for maturin
cp ../README.md README.md
if command -v maturin >/dev/null 2>&1; then
maturin develop
elif command -v pipenv >/dev/null 2>&1 && pipenv run maturin --version >/dev/null 2>&1; then
Expand Down
Loading
Loading