Skip to content

Commit

Permalink
Fix windows build
Browse files Browse the repository at this point in the history
  • Loading branch information
learnforpractice committed Jun 26, 2023
1 parent b68b17d commit 797506a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
11 changes: 11 additions & 0 deletions .github/workflows/python-app.yml
Expand Up @@ -65,6 +65,17 @@ jobs:
# # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Build libmixin.a
if: ${{ matrix.os == 'windows-2019' }}
working-directory: src/mixin
shell: cmd
run: |
choco install visualstudio2019buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"
go build -o mixin.dll -buildmode=c-shared
copy mixin.dll ../../pysrc/mixin.dll
gendef mixin.dll
cmd /c "`"C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat`" && lib /def:mixin.def /machine:x64 /out:mixin.lib"
- name: Build libmixin.a
if: ${{ matrix.os != 'windows-2019' }}
working-directory: src/mixin
run: |
go build -o libmixin.a -buildmode=c-archive
Expand Down
25 changes: 0 additions & 25 deletions setup.py
Expand Up @@ -28,31 +28,6 @@

dir_name = os.path.dirname(os.path.realpath(__file__))

root_path = os.path.join(dir_name, 'src/mixin')
def check_modification():
lib_name = os.path.join(root_path, 'libmixin.a')
if not os.path.exists(lib_name):
return True
modify_time = os.path.getmtime(lib_name)
for root, dirs, files in os.walk(root_path):
for f in files:
if f[-3:] == '.go':
f = os.path.join(root, f)
file_time = os.path.getmtime(f)
if modify_time < file_time:
return True
return False

r = check_modification()
if r:
print('mixin lib need to rebuild.')
os.system(f'touch {root_path}/main.go')

if platform.system() == 'Windows':
os.system('cd ./src/mixin &&go build -o mixin.dll -buildmode=c-shared && copy mixin.dll ../../pysrc/mixin.dll && gendef mixin.dll && lib /def:mixin.def /machine:x64 /out:mixin.lib')
else:
os.system('cd ./src/mixin;go build -o libmixin.a -buildmode=c-archive')

ext_modules = [
Extension(
'pymixin._mixin',
Expand Down

0 comments on commit 797506a

Please sign in to comment.