Skip to content
2 changes: 1 addition & 1 deletion .github/workflows/ci-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
push:
branches: [main]
pull_request:

workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: macos-latest
Expand Down
26 changes: 24 additions & 2 deletions .github/workflows/ci-windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches: [main]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -35,6 +36,14 @@ jobs:
with:
name: windows-installer
path: concordance/win/concordance-installer.exe
- name: Build Python wheel
run: |
pip install build
MINGW_SYSROOT_BIN="/usr/i686-w64-mingw32/sys-root/mingw/bin" concordance/win/make_wheel.py
- uses: actions/upload-artifact@v4
with:
name: windows-wheel
path: concordance/win/*.whl
test:
needs: build
runs-on: windows-latest
Expand All @@ -43,9 +52,22 @@ jobs:
id: download
with:
name: windows-installer
- name: Install and test
- name: Install and test installer
run: |
${{steps.download.outputs.download-path}}\concordance-installer.exe /S
Start-Process -FilePath ${{steps.download.outputs.download-path}}\concordance-installer.exe -ArgumentList "/S" -NoNewWindow -Wait
Start-Sleep -Seconds 5
cd "C:\Program Files (x86)\Concordance"
.\concordance.exe --version
- uses: actions/download-artifact@v4
id: downloadwheel
with:
name: windows-wheel
- uses: actions/setup-python@v5
with:
python-version: '3.12'
architecture: 'x86'
- name: Install and test wheel
run: |
pip install (gci ${{steps.downloadwheel.outputs.download-path}}\*.whl).FullName
python3 -c 'import libconcord; print(libconcord)'

36 changes: 36 additions & 0 deletions concordance/win/make_wheel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/python3

import os
import shutil
import subprocess
import tempfile
import glob

cp = subprocess.run([
'mingw-ldd',
os.path.dirname(os.path.abspath(__file__)) + '/../../libconcord/.libs/libconcord-6.dll',
'--dll-lookup-dirs',
os.environ['MINGW_SYSROOT_BIN'],
os.path.dirname(os.path.abspath(__file__)) + '/../../libconcord/.libs',
], capture_output=True, check=True, text=True)
with tempfile.TemporaryDirectory() as tempdir:
subdir = os.path.join(tempdir,'libconcord')
os.mkdir(subdir)
for line in cp.stdout.splitlines():
dll = line.split('=>')[1].strip()
if dll != 'not found':
shutil.copy2(dll, subdir)
shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + '/../../libconcord/.libs/libconcord-6.dll', subdir)
shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + '/../../libconcord/bindings/python/libconcord.py', subdir + '/__init__.py')
shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + '/../../libconcord/bindings/python/setup.py', tempdir)
shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + '/../../libconcord/bindings/python/pyproject.toml', tempdir)

curdir = os.getcwd()
os.chdir(tempdir)

os.environ["WIN32WHEEL"]="1"
subprocess.run([ 'python3', '-m', 'build', '-w' ])
for file in glob.glob('dist/*.whl'):
print("Found wheel: " + file)
shutil.copy2(file, os.path.dirname(os.path.abspath(__file__)))
os.chdir(curdir)
3 changes: 2 additions & 1 deletion libconcord/bindings/python/libconcord.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
# Load the DLL

if platform.system() == 'Windows':
_dll = cdll.LoadLibrary('libconcord.dll')
with os.add_dll_directory(os.path.dirname(__file__)):
_dll = cdll.LoadLibrary('libconcord-%i.dll' % ABI_VERSION)
elif platform.system() == 'Darwin':
_dll = cdll.LoadLibrary('libconcord.%i.dylib' % ABI_VERSION)
else:
Expand Down
32 changes: 27 additions & 5 deletions libconcord/bindings/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,32 @@
#

from setuptools import setup
import os

setup(
name='libconcord',
version='1.5',
py_modules=['libconcord'],
)
common_name='libconcord'
common_version='1.5'

if os.environ.get("WIN32WHEEL", None) == "1":
#Win32 Wheel Option Set
setup(
name=common_name,
version=common_version,
packages=['libconcord'],
zip_safe=False,
package_data={
'': ['*.dll']
},
options={
"bdist_wheel": {
"plat_name": "win32",
},
},
)
else:
#Default Option Set
setup(
name=common_name,
version=common_version,
py_modules=['libconcord'],
)