Skip to content

Commit cd83040

Browse files
committed
actions: search for pylon install on windows
1 parent bacbdf8 commit cd83040

File tree

2 files changed

+82
-8
lines changed

2 files changed

+82
-8
lines changed

.github/workflows/main.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,71 @@ jobs:
184184
$process = Start-Process Basler-pylon.exe -Wait -ArgumentList '/quiet /install=GigE_Runtime;USB_Runtime;Camera_Link_Runtime;GenTL_Consumer_Support;CamEmu_Support;SDKs;DataProcessing_SDK;DataProcessing_vTools;DataProcessing_AI' -PassThru
185185
Write-Host "Process finished with return code:" $process.ExitCode
186186
187+
- name: Set PYLON_DEV_DIR environment variable
188+
run: |
189+
# Find the pylon installation directory - check multiple possible locations
190+
$possiblePaths = @(
191+
"C:\Program Files\Basler",
192+
"D:\Program Files\Basler",
193+
"C:\Program Files (x86)\Basler",
194+
"D:\Program Files (x86)\Basler"
195+
)
196+
197+
$pylonDir = $null
198+
foreach ($basePath in $possiblePaths) {
199+
if (Test-Path $basePath) {
200+
Write-Host "Checking for pylon in: $basePath"
201+
$pylonDirs = Get-ChildItem -Path $basePath -Directory -Filter "pylon*" -ErrorAction SilentlyContinue | Sort-Object Name -Descending
202+
if ($pylonDirs.Count -gt 0) {
203+
$pylonDirName = $pylonDirs[0].Name
204+
$candidateDir = Join-Path $basePath $pylonDirName "Development"
205+
Write-Host "Found pylon candidate at: $candidateDir (from directory: $pylonDirName)"
206+
207+
# Verify this is a valid pylon SDK installation
208+
if (Test-Path "$candidateDir\include\pylon\PylonIncludes.h") {
209+
$pylonDir = $candidateDir
210+
Write-Host "Valid pylon SDK found at: $pylonDir"
211+
break
212+
} else {
213+
Write-Host "Invalid pylon SDK structure at: $candidateDir"
214+
# Let's also check what's actually in the directory for debugging
215+
if (Test-Path $candidateDir) {
216+
Write-Host "Directory exists but missing PylonIncludes.h. Contents:"
217+
Get-ChildItem -Path $candidateDir -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " - $($_.Name)" }
218+
} else {
219+
Write-Host "Directory does not exist: $candidateDir"
220+
}
221+
}
222+
}
223+
}
224+
}
225+
226+
if ($pylonDir) {
227+
# Set environment variable for current session
228+
$env:PYLON_DEV_DIR = $pylonDir
229+
230+
# Set environment variable for subsequent steps
231+
echo "PYLON_DEV_DIR=$pylonDir" >> $env:GITHUB_ENV
232+
233+
Write-Host "PYLON_DEV_DIR set to: $pylonDir"
234+
235+
# Show some additional info about the installation
236+
$pylonVersion = Split-Path (Split-Path $pylonDir -Parent) -Leaf
237+
Write-Host "Pylon version directory: $pylonVersion"
238+
} else {
239+
Write-Host "Error: No valid pylon installation found in any of the checked locations:"
240+
foreach ($path in $possiblePaths) {
241+
Write-Host " - $path"
242+
if (Test-Path $path) {
243+
Write-Host " Exists, contains:"
244+
Get-ChildItem -Path $path -Directory -ErrorAction SilentlyContinue | ForEach-Object { Write-Host " - $($_.Name)" }
245+
} else {
246+
Write-Host " Does not exist"
247+
}
248+
}
249+
exit 1
250+
}
251+
187252
- name: Build wheels
188253
uses: pypa/cibuildwheel@v2.21.3
189254

CMakeLists.txt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,21 @@ endif()
5959

6060
message(STATUS "Building for platform: ${PYPYLON_PLATFORM} ${PYPYLON_ARCH}")
6161

62+
# Add local cmake directory to module path for our finders
63+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
64+
6265
# Use the same approach as official pylon samples
6366
# for Unix system. All other OS PYLON_ROOT will be empty
6467
list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_ROOT})
6568
# for Windows system. All other OS PYLON_DEV_DIR will be empty
6669
list(APPEND CMAKE_PREFIX_PATH $ENV{PYLON_DEV_DIR})
6770

71+
# For Windows, set pylon_DIR directly to where the CMake config files are located
72+
if(WIN32 AND DEFINED ENV{PYLON_DEV_DIR})
73+
set(pylon_DIR "$ENV{PYLON_DEV_DIR}/CMake/pylon")
74+
message(STATUS "Setting pylon_DIR to: ${pylon_DIR}")
75+
endif()
76+
6877
# Find pylon using the official CMake configuration
6978
find_package(pylon REQUIRED)
7079

@@ -87,9 +96,6 @@ else()
8796
endif()
8897
endif()
8998

90-
# Add local cmake directory to module path for our finders
91-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
92-
9399
# Check for data processing support using local finder
94100
if(PYPYLON_INCLUDE_DATA_PROCESSING)
95101
find_package(pylonDataProcessing QUIET)
@@ -310,11 +316,6 @@ else()
310316
message(WARNING "SKBUILD_METADATA_DIR not defined")
311317
endif()
312318

313-
# Copy runtime dependencies
314-
# Pass pylon version to runtime dependencies and include
315-
set(PYLON_VERSION_FOR_RUNTIME ${pylon_VERSION})
316-
include(cmake/CopyRuntimeDeps.cmake)
317-
318319
# Set version for the package
319320
if(SKBUILD)
320321
# setuptools_scm handles version detection automatically
@@ -326,4 +327,12 @@ if(SKBUILD)
326327
endif()
327328
endif()
328329

330+
# Set PYLON_BIN_DIR for Windows to the correct runtime DLL directory
331+
if(WIN32 AND DEFINED ENV{PYLON_DEV_DIR})
332+
file(TO_CMAKE_PATH "$ENV{PYLON_DEV_DIR}/../Runtime/x64" PYLON_BIN_DIR)
333+
message(STATUS "Setting PYLON_BIN_DIR to: ${PYLON_BIN_DIR}")
334+
endif()
335+
336+
include(cmake/CopyRuntimeDeps.cmake)
337+
329338
message(STATUS "CMake configuration complete with version: ${PYPYLON_VERSION_STRING}")

0 commit comments

Comments
 (0)