Skip to content

Commit

Permalink
Add script and configs to build Win32 wheel
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Meister committed Apr 16, 2024
1 parent 2a61257 commit 013005b
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
35 changes: 35 additions & 0 deletions concordance/win/make_wheel.py
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 3 additions & 0 deletions concordance/win/pyproject.toml.win32-wheel
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"
36 changes: 36 additions & 0 deletions concordance/win/setup.py.win32-wheel
Original file line number Diff line number Diff line change
@@ -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",
},
},
)

0 comments on commit 013005b

Please sign in to comment.