From 78880fdc9246ba85d2ffe2783ee022d1c77b9270 Mon Sep 17 00:00:00 2001 From: Ben Meister <161079167+Ben-Meister@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:19:16 -0400 Subject: [PATCH 1/7] Enable option to run workflows manually --- .github/workflows/ci-linux.yml | 2 +- .github/workflows/ci-macos.yml | 1 + .github/workflows/ci-windows.yml | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index d4c229b..90ebbdb 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -3,7 +3,7 @@ on: push: branches: [main] pull_request: - + workflow_dispatch: jobs: build: runs-on: ubuntu-latest diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index ea0220d..ba98dfc 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -3,6 +3,7 @@ on: push: branches: [main] pull_request: + workflow_dispatch: jobs: build: runs-on: macos-latest diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 7b4df9d..e15b0b9 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -3,6 +3,7 @@ on: push: branches: [main] pull_request: + workflow_dispatch: jobs: build: runs-on: ubuntu-latest From 2a612577c7611ad89718de637facfc93af6a3e28 Mon Sep 17 00:00:00 2001 From: Ben Meister <161079167+Ben-Meister@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:48:21 -0400 Subject: [PATCH 2/7] Fix libconcord DLL name on Windows, and add the package path to the DLL path search list --- libconcord/bindings/python/libconcord.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libconcord/bindings/python/libconcord.py b/libconcord/bindings/python/libconcord.py index e54644e..3259180 100644 --- a/libconcord/bindings/python/libconcord.py +++ b/libconcord/bindings/python/libconcord.py @@ -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: From 013005ba10203a59db2fab428f6add3f204b5d81 Mon Sep 17 00:00:00 2001 From: Ben Meister <161079167+Ben-Meister@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:53:07 -0400 Subject: [PATCH 3/7] Add script and configs to build Win32 wheel --- concordance/win/make_wheel.py | 35 +++++++++++++++++++++ concordance/win/pyproject.toml.win32-wheel | 3 ++ concordance/win/setup.py.win32-wheel | 36 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100755 concordance/win/make_wheel.py create mode 100644 concordance/win/pyproject.toml.win32-wheel create mode 100644 concordance/win/setup.py.win32-wheel diff --git a/concordance/win/make_wheel.py b/concordance/win/make_wheel.py new file mode 100755 index 0000000..a4ddac5 --- /dev/null +++ b/concordance/win/make_wheel.py @@ -0,0 +1,35 @@ +#!/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__)) + '/../.libs/concordance.exe', + '--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__)) + '/../.libs/concordance.exe', 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__)) + '/setup.py.win32-wheel', tempdir + '/setup.py') + shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + '/pyproject.toml.win32-wheel', tempdir + '/pyproject.toml') + + curdir = os.getcwd() + os.chdir(tempdir) + + subprocess.run([ 'python3', '-m', 'build', ]) + for file in glob.glob('dist/*.whl'): + print("Found wheel: " + file) + shutil.copy2(file, os.path.dirname(os.path.abspath(__file__))) + os.chdir(curdir) diff --git a/concordance/win/pyproject.toml.win32-wheel b/concordance/win/pyproject.toml.win32-wheel new file mode 100644 index 0000000..fed528d --- /dev/null +++ b/concordance/win/pyproject.toml.win32-wheel @@ -0,0 +1,3 @@ +[build-system] +requires = ["setuptools"] +build-backend = "setuptools.build_meta" diff --git a/concordance/win/setup.py.win32-wheel b/concordance/win/setup.py.win32-wheel new file mode 100644 index 0000000..6c9c339 --- /dev/null +++ b/concordance/win/setup.py.win32-wheel @@ -0,0 +1,36 @@ +#!/usr/bin/env python +# +# vim:tw=80:ai:tabstop=4:softtabstop=4:shiftwidth=4:expandtab +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +from setuptools import setup + +setup( + name='libconcord', + version='1.5', + packages=['libconcord'], + zip_safe=False, + package_data={ + '': ['*.dll', '*.exe'] + }, + options={ + "bdist_wheel": { + "plat_name": "win32", + }, + }, +) + From bd23aa63c7cf3e84f24e8bc5f2b0828aeb851e91 Mon Sep 17 00:00:00 2001 From: Ben Meister <161079167+Ben-Meister@users.noreply.github.com> Date: Sun, 14 Apr 2024 13:58:32 -0400 Subject: [PATCH 4/7] Build Python wheel in CI --- .github/workflows/ci-windows.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index e15b0b9..153450f 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -36,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@v3 + with: + name: windows-wheel + path: concordance/win/*.whl test: needs: build runs-on: windows-latest From 67753cad2f20def3171bccba71558f52f31c9173 Mon Sep 17 00:00:00 2001 From: Ben Meister <161079167+Ben-Meister@users.noreply.github.com> Date: Mon, 15 Apr 2024 16:49:33 -0400 Subject: [PATCH 5/7] Test Python wheel on Windows --- .github/workflows/ci-windows.yml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 153450f..72f2353 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -52,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-Sleep -Seconds 5 cd "C:\Program Files (x86)\Concordance" .\concordance.exe --version + - uses: actions/download-artifact@v3 + 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)' + From 0ed3274fe717cbce29bbfa4721cd98b6856e5cb6 Mon Sep 17 00:00:00 2001 From: Ben Meister <161079167+Ben-Meister@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:45:14 -0400 Subject: [PATCH 6/7] Use one set of config files to produce all Python packages/wheels --- concordance/win/make_wheel.py | 7 +++-- concordance/win/pyproject.toml.win32-wheel | 3 -- concordance/win/setup.py.win32-wheel | 36 ---------------------- libconcord/bindings/python/setup.py | 32 ++++++++++++++++--- 4 files changed, 31 insertions(+), 47 deletions(-) delete mode 100644 concordance/win/pyproject.toml.win32-wheel delete mode 100644 concordance/win/setup.py.win32-wheel diff --git a/concordance/win/make_wheel.py b/concordance/win/make_wheel.py index a4ddac5..34d481d 100755 --- a/concordance/win/make_wheel.py +++ b/concordance/win/make_wheel.py @@ -22,13 +22,14 @@ shutil.copy2(dll, subdir) shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + '/../.libs/concordance.exe', 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__)) + '/setup.py.win32-wheel', tempdir + '/setup.py') - shutil.copy2(os.path.dirname(os.path.abspath(__file__)) + '/pyproject.toml.win32-wheel', tempdir + '/pyproject.toml') + 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) - subprocess.run([ 'python3', '-m', 'build', ]) + 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__))) diff --git a/concordance/win/pyproject.toml.win32-wheel b/concordance/win/pyproject.toml.win32-wheel deleted file mode 100644 index fed528d..0000000 --- a/concordance/win/pyproject.toml.win32-wheel +++ /dev/null @@ -1,3 +0,0 @@ -[build-system] -requires = ["setuptools"] -build-backend = "setuptools.build_meta" diff --git a/concordance/win/setup.py.win32-wheel b/concordance/win/setup.py.win32-wheel deleted file mode 100644 index 6c9c339..0000000 --- a/concordance/win/setup.py.win32-wheel +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python -# -# vim:tw=80:ai:tabstop=4:softtabstop=4:shiftwidth=4:expandtab -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -from setuptools import setup - -setup( - name='libconcord', - version='1.5', - packages=['libconcord'], - zip_safe=False, - package_data={ - '': ['*.dll', '*.exe'] - }, - options={ - "bdist_wheel": { - "plat_name": "win32", - }, - }, -) - diff --git a/libconcord/bindings/python/setup.py b/libconcord/bindings/python/setup.py index 9ded24d..1777272 100644 --- a/libconcord/bindings/python/setup.py +++ b/libconcord/bindings/python/setup.py @@ -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', '*.exe'] + }, + options={ + "bdist_wheel": { + "plat_name": "win32", + }, + }, + ) +else: + #Default Option Set + setup( + name=common_name, + version=common_version, + py_modules=['libconcord'], + ) From a4ae76ca007fd631316fae72a86429d90b9350a5 Mon Sep 17 00:00:00 2001 From: Ben Meister <161079167+Ben-Meister@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:08:12 -0400 Subject: [PATCH 7/7] On Windows, wait for installer to finish before attempting to start Concordance --- .github/workflows/ci-windows.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 72f2353..ccec392 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -54,7 +54,7 @@ jobs: name: windows-installer - 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