Python issue when setting up Windows build environment

Run into a problem trying to build from source with Visual Studio. I may have committed a faux pas by asking for help in the mailing list before posting in the forum! But I’ll start the same post here too and post any solution if I get one before someone here works it out.

Firstly, I’m unfamiliar with Visual Studio (not used it since VS 6.0) and the various tools that go along with modern development using VS. So the chances are, there’s a problem here of my own making.

Anyway, I have followed the build process step-by-step as laid out in “Building using Visual Studio (2019, 2022)”, but have been tripped up by the Python package.

The first error is
“error: building wxpython:x64-windows failed with: BUILD_FAILED” in the CMake output window within Visual Studio. A little before this, the line “See logs for more information:” points me to the “D:\External_Gitlab_Projects\vcpkg\buildtrees\wxpython\get-pip-x64-windows-err.log” file. This logfile ends with:

"
File “C:\Users\PolyV\AppData\Local\Temp\tmp9hhvjdrc\pip.zip\pip_internal\locations_distutils.py”, line 9, in
ModuleNotFoundError: No module named ‘distutils’
"
One “solution” that I found suggested somewhere was was uninstall all python distributions from my machine and try again - this didn’t work. Everything else I’ve found related to these error messages has failed to provide me with any information I can use.

Is there anything obvious I might be doing wrong?

Hmm vcpkg upstream did update to 3.12 in one part last week.

Revert your vcpkg copy back a week (maybe two weeks) and see if that fixes it.

Ah - so it may be that I’ve just decided to look into developing at the wrong time! A similar suggestion was made on the mailing list, but I was a bit hazy on what I was being instructed to do, and whether I could do it correctly. I’ll see what I can figure out over the next few days if I get a chance… Busy couple of weeks, so I might not be able to look into this again for a wee bit.

So - I couldn’t resist a fiddle while I was drinking my coffee and preparing to dive into report writing!

I’m not great with GIT - I find it pretty confusing at the best of times, typically using the minimum of features to track my own projects, so I was unsure how to roll back to earlier vcpkg versions. I also use TortoiseGIT because my command line skills got rusty a long time ago!

Anyway - I deleted vcpkg and kicad folders to be sure I’m on a clean slate again (3rd time I’ve resorted to this now). I then cloned vcpkg again and in TortoiseGIT showed the log, and then right clicked on the last entry for 30/09/2024 and selected “Reset Master to this”. I think this has rolled me back to the end of last month?

I’m just about to set Visual Studio going to fetch and compile all the dependencies from scratch again… so I’ll report back some time later!

Ok - far quicker than expected, I have the same error. I feel like I’ve done something very wrong this time!

" ModuleNotFoundError: No module named ‘distutils’ "

I have to get on with my “real” work now though, so I’ll try and find time to continue solving the mystery later.

I have the same issue. It seems that “distutils” was removed from python 3.12

I have identified this as the problem from my googling too - but don’t know how to implement a fix that will work with the procedure to set-up a KiCAD build environment and not have any unwanted side effects that’ll bite me in the bum later (or immediately, as the case may be!)

So I think I did everything correctly… Still no joy:

CMD:

git clone https://github.com/microsoft/vcpkg.git

then in TortoiseGit: show log, right-click last entry for Sept '24, “reset master to this”.

CMD:

.\vcpkg\bootstrap-vcpkg.bat

Clone KiCAD source via TortoiseGit (using my unedited, up-to-date fork: “Forked from KiCad / KiCad Source Code / kicad”)

Copy & edit CMakeSettings.json(.sample) to point to vcpkg correctly

Open folder in VStudio…CMake output starts with a couple of depreciation warnings, followed by “Running vcpkg install”, then
“Fetching registry information from https://github.com/microsoft/vcpkg (HEAD)…”, then
“A suitable version of cmake was not found (required v3.30.1).”, then
“Downloading https://github.com/Kitware/CMake/releases/download/v3.30.1/cmake-3.30.1-windows-i386.zip”…
etc.

After a fairly short time, I get “error: building wxpython:x64-windows failed with: BUILD_FAILED”
and in D:\External_Gitlab_Projects\vcpkg\buildtrees\wxpython\get-pip-x64-windows-err.log
“ModuleNotFoundError: No module named ‘distutils’”

@marekr - I saw your mailing list post: “I pinned vcpkg-get-python-packages in the kicad repo to the older version, might work” so tried again with the up to date vcpkg. I’m not sure if I’m using the right KiCAD repo to benefit from your pin though? ( [KiCad / KiCad Source Code / kicad] ).

Anyway, same result - problems with missing distutils. I see the following in the CMake output:

[CMake] -- Downloading https://www.python.org/ftp/python/3.12.7/python-3.12.7-embed-amd64.zip -> python-3.12.7-embed-amd64.zip...

Well, make sure you are actually cloning vcpkg from september.

scripts/cmake/vcpkg_find_acquire_program(PYTHON3).cmake

was updated on 10/18, if you open it in the vcpkg repo, it must not have any 3.12 references.

Since you have it loading 3.12.7, you are not checking out a older version correctly.

It should have set(program_version 3.11.8) at the top lol

My post referencing 3.12.7 was using the up to date vcpkg to see if your pinning had worked. However, now you’ve told me where to look, I can verify that my method of trying to revert to an earlier version of vcpkg (preceding post) is incorrect: “in TortoiseGit: show log, right-click last entry for Sept '24, “reset master to this”.”

Clearly my git-fu is inferior - I’ll try and figure out how to revert properly.

Thanks : )

You have to do a “hard” reset and not the default of “mixed”

image

You know - while I was fumbling about earlier, I tried that. But because it didn’t indicate changes to any files, I assumed it hadn’t done what I wanted it to! I can now verify that the Python version has changed to “program_version 3.11.8”.

I’ll see what happens now : )

Yay - that got me past the wxPython troubles. Now I have a different problem, but that’s not really appropriate to discuss in this thread. Thanks for the help : )

I had the same issue and used TortoiseGit to change the vcpkg to 30 Sep 2024 and it is now compiling.