Skip to content

Commit 495b66d

Browse files
authored
Merge pull request #8 from z3rone-org/development
v0.4.1
2 parents 453f6db + a583bca commit 495b66d

45 files changed

Lines changed: 5688 additions & 1216 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.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: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ jobs:
3030
with:
3131
submodules: recursive
3232

33-
- name: Set version from tag
33+
- name: Verify version matches tag
3434
if: startsWith(github.ref, 'refs/tags/v')
3535
shell: bash
3636
run: |
3737
TAG_VERSION="${GITHUB_REF#refs/tags/v}"
38-
echo "Updating version in Cargo.toml to $TAG_VERSION"
39-
if [[ "${{ runner.os }}" == "macOS" ]]; then
40-
sed -i '' 's/^version = ".*"/version = "'$TAG_VERSION'"/' native_fisher_py/Cargo.toml
41-
else
42-
sed -i 's/^version = ".*"/version = "'$TAG_VERSION'"/' native_fisher_py/Cargo.toml
38+
# Extract version from Cargo.toml
39+
CARGO_VERSION=$(grep -m1 '^version =' native_fisher_py/Cargo.toml | cut -d '"' -f 2)
40+
echo "Tag version: $TAG_VERSION"
41+
echo "Cargo version: $CARGO_VERSION"
42+
if [[ "$TAG_VERSION" != "$CARGO_VERSION" ]]; then
43+
echo "Error: Tag version ($TAG_VERSION) does not match Cargo.toml version ($CARGO_VERSION)"
44+
exit 1
4345
fi
4446
4547
- name: Install NativeAOT Dependencies (Linux)
@@ -75,6 +77,9 @@ jobs:
7577
with:
7678
python-version: '3.9'
7779

80+
- name: Copy README
81+
run: cp README.md native_fisher_py/
82+
7883
- name: Build wheels
7984
uses: PyO3/maturin-action@v1
8085
with:

README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,22 @@ maturin develop
9090
This project is powered by the [**Thermo Fisher Scientific RawFileReader**](https://github.com/thermofisherlsms/RawFileReader) (copyright © 2016-2026 Thermo Fisher Scientific, Inc.). All rights reserved.
9191

9292
The `native-fisher-py` package includes the official RawFileReader libraries, which remain the property of Thermo Fisher Scientific. By using this software, you agree to the terms specified in their [license](https://github.com/thermofisherlsms/RawFileReader/blob/main/License.doc).
93+
94+
## Releasing a New Version
95+
Releases are fully automated via GitHub Actions (`release.yml`), but the workflow **requires** that the git tag strictly matches the version in `native_fisher_py/Cargo.toml`.
96+
97+
To trigger a new release and publish to PyPI:
98+
99+
1. Update the version in `native_fisher_py/Cargo.toml`.
100+
2. Commit the version bump.
101+
3. Create and push a matching git tag:
102+
103+
```bash
104+
git tag vX.Y.Z
105+
git push origin vX.Y.Z
106+
```
107+
108+
The GitHub Action will automatically:
109+
1. Verify that the git tag version matches the `Cargo.toml` version (failing otherwise).
110+
2. Build the native wheels across all platforms (macOS, Linux, Windows).
111+
3. Publish the final artifacts to PyPI.

native/.editorconfig

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
root = true
2+
3+
[*.cs]
4+
# Disable preserving single-line blocks and statements
5+
csharp_preserve_single_line_blocks = false
6+
csharp_preserve_single_line_statements = false
7+
8+
# Newline settings for braces
9+
csharp_new_line_before_open_brace = all
10+
csharp_new_line_before_catch = true
11+
csharp_new_line_before_else = true
12+
csharp_new_line_before_finally = true
13+
14+
# General formatting
15+
insert_final_newline = true
16+
indent_style = space
17+
indent_size = 4

0 commit comments

Comments
 (0)