Msvc/vcpkg changes

I ended up succesfully doing so. Just follow the MSVC build docs and prepare for a lot of time as packages are installed. And i mean a LOT.

Be sure to have no python path in the CMake commands (-Dxxxxxx).

1 Like

Ensure your kicad is at the latest head and not behind by a day or two.

Delete the cmake cache and reconfigure. This is different from a plain reconfigure. You can do this manually by just deleting the build/x64-Release or build/x64-Debug folder.

1 Like

All repos are up to date.

No python paths anywhere, either. I got rid of the old CMakeSettings.json and used the template for a new one to get rid of any cruft.

Visual Studio suggested ā€œdelete cache and reconfigureā€ by itself, but even deleting the build (sub)folders manually and letting VS (re)configure afterwards didnā€™t change anything, repeated cache deletion and reconfigure runs are still failing with the same error.

Starting from scratch and following the official instructions didnā€™t help, vcpkg install is still failing for wxpython when running ensurepip with the system-wide python install (which is included in PATH because other tools need to run it).

Thatā€™s the issue. Donā€™t include python on system PATH, provide it to whatever tools need it on case by case basis.
Python just doesnā€™t handle this situation well.

It shouldnā€™t matter if python is on PATH or notā€¦as I fixed it or it should be fixed now as of 3 days ago. I canā€™t reproduce any more conflicts

I believe the issue is wxpython not building, not kicad build failing. Did you patch wxpython in any way too?

wxpython is majorly under my control, i.e. I wrote a custom build process in cmake because the official wxpython build uses the deprecated and always broken python build tools

So yes, it should only be picking up the vcpkg python. Infact, vcpkg itself patches FindPython inside itā€™s environment to pickup the vcpkg python when Development is specified as the find component which it is.

1 Like

Can you give me some pointers for debugging? I havenā€™t seen much detail in the logs on how it found the wrong python installation.

vcpkg\buildtrees\wxpython\config-x64-windows-out.log has the correct one:

-- Found Python3: C:/Users/.../vcpkg/installed/x64-windows/tools/python3/python.exe (found version "3.9.10") found components: Interpreter Development Development.Module Development.Embed

vcpkg\buildtrees\wxpython\stdout-x64-windows.log is the one place with the system-wide path:

-- Found Python3: C:/Program Files/Python310/python.exe (found version "3.10.4") found components: Interpreter 
CMake Error at scripts/cmake/vcpkg_execute_build_process.cmake:158 (message):
    Command failed: "C:/Program Files/Python310/python.exe" -m ensurepip

Any other path in this file is inside the vcpkg tree.

1 Like

I see the problem

good news: cmake doesnā€™t find the system python.

bad news: cmake doesnā€™t find the vcpkg python either.

same as above: config is fine, stdout not:

CMake Error at C:/Program Files/CMake/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Python3 (missing: Python3_INCLUDE_DIRS Python3_LIBRARIES
  Development Development.Module Development.Embed) (found version "3.10.4")

Yea Iā€™ll fix it

Ok now itā€™s fixed

3 Likes

looks good so far, wxpython is building now. both my old setup and the one started from scratch are working again, at least for building kicad.
Thanks!

Running kicad from Visual Studio is still (partly) broken because of some python related issues (starting pcbnew fails due to some pybind errors for the old setup - which broke a while ago, possibly by installing python). Iā€™ll have to investigate that later.

Use the updated launch.vs.json provided in the instructions and then launch the non-install targets for debug.

Otherwise you should have zero pybind errors.
I have none, I have reproduced the setup on multiple machines and nobody else is reporting it.

Iā€™m getting an error starting pcbnew as well. pcbnew runs ok though after you ā€œcontinueā€ in the debugger. Btw, this is the non-install build.

The file is ā€œeval.hā€

yes, I copied the sample launch.vs.json verbatim and launched the non-install targets, but I got the same error.

Turns out, PYTHONPATH references a nonexisting folder: ā€¦kicad\build\install\x64-Debug\pcbnew (and kicad\scripting, which does exist, obviously)

Changing the launch configuration from

"PYTHONPATH": "${cmake.installRoot}\\pcbnew;${projectDir}\\scripting",

to

"PYTHONPATH": "${cmake.buildRoot}\\pcbnew;${projectDir}\\scripting",

does help.

btw: the same error occurred with the new setup built from scratch by following the instructions exactly.

3 Likes

Confirmed, works. Thx.

@marekr FYI, new errors after your recent commits:

Starting pcbnew:

kicad_2WrMvfUlE4

after ā€œcancelā€:

kicad_XSMUB8vYQB

Keeps coming back on ā€œokā€, app has to be stopped in debugger.

Starting eeschema:

kicad_2WrMvfUlE4

after ā€œcancelā€: