From e10730ef40e42937e27935cfb83c3dc5f78f2af1 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Fri, 8 Mar 2024 08:39:07 +0100 Subject: [PATCH] Add some heuristics to find out the Windows build directory Adding the build directory to the module search path eases development by now. --- src/swigtest.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/swigtest.py b/src/swigtest.py index 73f3ea42..8f3bf474 100644 --- a/src/swigtest.py +++ b/src/swigtest.py @@ -14,10 +14,22 @@ import sys import os import pathlib -sysname = os.uname()[0].lower() -builddir = f'build_{sysname}/src' +builddir = None +if os.name == 'posix': + # Linux, *BSD, MacOS + sysname = os.uname()[0].lower() + builddir = f'build_{sysname}/src' +elif os.name == 'nt': + # Windows + for candidate in ['build_msvc/src', 'build_msys64/src']: + if os.path.exists(candidate): + builddir = candidate + break -sys.path.append(builddir) +if builddir == None: + print("Cannot determine build directory, module loading might fail.", file=sys.stderr) +else: + sys.path.append(builddir) import swig_avrdude as ad