Skip to content

Commit 6f2f7d1

Browse files
committed
commit dlls; test on testpypi
1 parent a92dadb commit 6f2f7d1

File tree

2 files changed

+77
-8
lines changed

2 files changed

+77
-8
lines changed

.github/workflows/build-package.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,70 @@ jobs:
7474
pip install --upgrade pip
7575
pip install pytest scipy
7676
pytest -v
77+
78+
commit_shared_libs:
79+
needs: test
80+
runs-on: ubuntu-latest
81+
82+
steps:
83+
- name: checkout repo
84+
uses: actions/checkout@v4
85+
with:
86+
token: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: download deterministicGaussianSampling libs artifact
89+
uses: actions/download-artifact@v4
90+
with:
91+
name: deterministicGaussianSampling-libs
92+
path: external_libs
93+
94+
- name: extract and place shared libraries
95+
run: |
96+
set -e
97+
98+
# Linux libs
99+
if [ -f external_libs/linux.zip ]; then
100+
mkdir -p external_libs_unpacked/linux
101+
unzip -o external_libs/linux.zip -d external_libs_unpacked/linux
102+
103+
mkdir -p src/deterministic_gaussian_sampling/lib/linux/bin
104+
cp -r external_libs_unpacked/linux/lib/* \
105+
src/deterministic_gaussian_sampling/lib/linux/bin/
106+
fi
107+
108+
# Windows libs
109+
if [ -f external_libs/windows.zip ]; then
110+
mkdir -p external_libs_unpacked/windows
111+
unzip -o external_libs/windows.zip -d external_libs_unpacked/windows
112+
113+
mkdir -p src/deterministic_gaussian_sampling/lib/windows/bin
114+
cp -r external_libs_unpacked/windows/bin/* \
115+
src/deterministic_gaussian_sampling/lib/windows/bin/
116+
fi
117+
118+
- name: commit shared libraries
119+
run: |
120+
git config user.name "github-actions[bot]"
121+
git config user.email "github-actions[bot]@[email protected]"
122+
123+
git add src/deterministic_gaussian_sampling/lib
124+
125+
if git diff --cached --quiet; then
126+
echo "No changes to commit"
127+
else
128+
git commit -m "Update deterministicGaussianSampling shared libraries"
129+
git push
130+
fi
131+
132+
- name: install build tools
133+
run: |
134+
python -m pip install --upgrade pip
135+
pip install build
136+
137+
- name: build package
138+
run: python -m build
139+
140+
- name: Publish to TestPyPI
141+
uses: pypa/gh-action-pypi-publish@release/v1
142+
with:
143+
repository-url: https://test.pypi.org/legacy/

src/deterministic_gaussian_sampling/dll_handling/dynamic_dll_loading.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import platform
33
from pathlib import Path
44

5+
import importlib.resources as ir
56
import deterministic_gaussian_sampling.type_wrapper.ctypes_wrapper as ctypes_wrapper
67

78
def _setup_ctypes_dll(cdll: ctypes.CDLL) -> ctypes.CDLL:
@@ -113,18 +114,19 @@ def _setup_ctypes_dll(cdll: ctypes.CDLL) -> ctypes.CDLL:
113114
return cdll
114115

115116
def load_dll() -> ctypes.CDLL:
116-
package_root = Path(__file__).resolve().parent.parent
117-
118117
system = platform.system()
118+
119119
if system == "Windows":
120-
dll_rel = Path("lib") / "windows" / "bin" / "libapproxLCD.dll"
120+
subpath = Path("lib/windows/bin/libapproxLCD.dll")
121121
elif system == "Linux":
122-
dll_rel = Path("lib") / "linux" / "bin" / "libapproxLCD.so"
122+
subpath = Path("lib/linux/bin/libapproxLCD.so")
123123
elif system == "Darwin":
124-
dll_rel = Path("lib") / "macos" / "bin" / "libapproxLCD.dylib"
124+
subpath = Path("lib/macos/bin/libapproxLCD.dylib")
125125
else:
126126
raise RuntimeError(f"Unsupported OS: {system}")
127-
128-
dll_path = package_root / dll_rel
129127

130-
return _setup_ctypes_dll(ctypes.CDLL(str(dll_path)))
128+
# locate file inside wheel
129+
with ir.as_file(
130+
ir.files("deterministic_gaussian_sampling") / subpath
131+
) as dll_path:
132+
return _setup_ctypes_dll(ctypes.CDLL(str(dll_path)))

0 commit comments

Comments
 (0)