Skip to content

Commit 148aee8

Browse files
authored
Fix python build with Windows (#648)
IB-8304 Signed-off-by: Raul Metsma <[email protected]>
1 parent 0faa960 commit 148aee8

File tree

5 files changed

+11
-26
lines changed

5 files changed

+11
-26
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ jobs:
2222
run: |
2323
brew update
2424
brew install --formula ninja swig doxygen boost
25-
brew unlink [email protected] || true
2625
brew unlink [email protected] || true
2726
brew unlink [email protected] || true
2827
brew unlink openssl@3 || true
@@ -136,8 +135,10 @@ jobs:
136135
include:
137136
- toolset: 143
138137
image: windows-2022
138+
vcvars: "C:\\Program Files\\Microsoft Visual Studio\\2022\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat"
139139
- toolset: 142
140140
image: windows-2019
141+
vcvars: "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Auxiliary\\Build\\vcvarsall.bat"
141142
- platform: x86
142143
setenv: amd64_x86
143144
- platform: x64
@@ -166,17 +167,13 @@ jobs:
166167
Invoke-WebRequest -UserAgent "Wget" "https://sourceforge.net/projects/swig/files/swigwin/swigwin-4.2.1/swigwin-4.2.1.zip/download" -OutFile swig.zip
167168
tar xf swig.zip
168169
- uses: actions/setup-python@v5
169-
if: matrix.platform == 'x86'
170+
if: matrix.platform != 'arm64'
170171
with:
171172
python-version: 3.12
172-
architecture: x86
173-
- name: Setup dev env
174-
uses: ilammy/msvc-dev-cmd@v1
175-
with:
176-
arch: ${{ matrix.setenv }}
173+
architecture: ${{ matrix.platform }}
177174
- name: Build
178175
run: |
179-
& .\build.ps1 `
176+
& "${{ matrix.vcvars }}" ${{ matrix.setenv }} "&&" pwsh build.ps1 `
180177
-swig ${{ github.workspace }}/swigwin-4.2.1/swig.exe `
181178
-doxygen "C:/Program files/doxygen/bin/doxygen.exe" `
182179
-boost

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ endif()
7777
find_package(SWIG)
7878
if(SWIG_FOUND)
7979
find_package(JNI)
80-
find_package(Python3 COMPONENTS Interpreter Development)
80+
find_package(Python3 COMPONENTS Development)
8181
if((WIN32 OR APPLE) AND CMAKE_VERSION VERSION_GREATER_EQUAL "3.24")
8282
find_package(Python3 COMPONENTS Development.SABIModule)
8383
endif()

build.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,11 @@ if($doxygen) {
4343
$cmakeext += "-DDOXYGEN_EXECUTABLE=$doxygen"
4444
$wixext += "-d", "docLocation=$(Get-Location)/$platform/share/doc/libdigidocpp"
4545
}
46-
if($env:VSCMD_ARG_HOST_ARCH -ne "arm64") {
46+
if($platform -eq "arm64" -and $env:VSCMD_ARG_HOST_ARCH -ne "arm64") {
4747
$cmakeext += "-DCMAKE_DISABLE_FIND_PACKAGE_Python3=yes"
4848
$wixext += "-d", "disablePython=1"
49-
if($platform -eq "arm64") {
50-
$boost = $false
51-
}
52-
}
49+
$boost = $false
50+
}
5351
if($boost) {
5452
$cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests"
5553
$target += "check"

libdigidocpp.wxs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,6 @@
105105
<Files Include="$(var.libdigidocpp)\include\**" />
106106
</ComponentGroup>
107107

108-
<?ifdef var.docLocation ?>
109-
<ComponentGroup Id="Documentation" Directory="INSTALLFOLDER" Subdirectory="documentation">
110-
<Files Include="$(var.docLocation)\**" />
111-
</ComponentGroup>
112-
<?endif?>
113-
114108
<Feature Id="InstallLibdigidocpp" Level="1" Title="Libdigidocpp" Display="expand" ConfigurableDirectory="INSTALLFOLDER">
115109
<ComponentGroupRef Id="Runtime" />
116110
<ComponentGroupRef Id="Dependencies" />
@@ -124,7 +118,7 @@
124118
</Feature>
125119
<?ifdef var.docLocation ?>
126120
<Feature Id="InstallDocumentation" Level="1" Title="Documentation">
127-
<ComponentGroupRef Id="Documentation" />
121+
<Files Include="$(var.docLocation)\**" Directory="INSTALLFOLDER" Subdirectory="documentation" />
128122
</Feature>
129123
<?endif?>
130124
</Feature>

src/CMakeLists.txt

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,11 @@ if(SWIG_FOUND)
207207
endif()
208208
#configure_file(setup.py.cmake setup.py)
209209
#install(CODE "execute_process(COMMAND python3 ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)")
210-
if(NOT Python3_SITELIB)
211-
execute_process(COMMAND /usr/bin/python3 -c
212-
"from distutils import sysconfig;print(sysconfig.get_python_lib(plat_specific=False,standard_lib=False))"
213-
OUTPUT_VARIABLE Python3_SITELIB OUTPUT_STRIP_TRAILING_WHITESPACE)
214-
endif()
215210
if(WIN32)
216211
set(Python3_SITELIB ${CMAKE_INSTALL_BINDIR})
217212
install(FILES $<TARGET_PDB_FILE:digidoc_python> DESTINATION ${Python3_SITELIB} OPTIONAL)
218213
else()
214+
find_package(Python3 COMPONENTS Interpreter) # for Python3_SITELIB
219215
set_target_properties(digidoc_python PROPERTIES SUFFIX .so)
220216
endif()
221217
set_target_properties(digidoc_python PROPERTIES

0 commit comments

Comments
 (0)