shedskin / shedskin

Shed Skin is a restricted-Python-to-C++ compiler. Read the introduction below to learn about the restrictions.
https://shedskin.github.io/
Other
819 stars 108 forks source link

Issue on Windows calling shedskin Python script from Ninja #456

Open brechtsanders opened 6 months ago

brechtsanders commented 6 months ago

I'm on Windows using MinGW-w64 GCC from the MSYS2 shell, and my Python is not in my PATH.

When I run:

echo "print('Hello world')" > hello.py
$PYDIR/python.exe $MINGWPREFIX/bin/shedskin build --generator Ninja hello.py

I get:

←[1G*** SHED SKIN Python-to-C++ Compiler 0.9.8 ***
←[1GCopyright 2005-2023 Mark Dufour and contributors; License GNU GPL version 3
(See LICENSE)
←[1G
-- The CXX compiler identification is GNU 13.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: D:/Prog/winlibs-gcc13.2.0-posix-msvcrt-11.0.1/mingw64/bin/c++.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
Project: hello_project
Build type: Debug

CMake Error at D:/Prog/winlibs-gcc13.2.0-posix-msvcrt-11.0.1/custombuilt64/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Python (missing: Python_EXECUTABLE Python_LIBRARIES
  Python_INCLUDE_DIRS Interpreter Development Development.Module
  Development.Embed)
Call Stack (most recent call first):
  D:/Prog/winlibs-gcc13.2.0-posix-msvcrt-11.0.1/custombuilt64/share/cmake-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  D:/Prog/winlibs-gcc13.2.0-posix-msvcrt-11.0.1/custombuilt64/share/cmake-3.28/Modules/FindPython.cmake:616 (find_package_handle_standard_args)
  CMakeLists.txt:41 (find_package)

-- Configuring incomplete, errors occurred!
Traceback (most recent call last):
  File "D:\Prog\winlibs-gcc13.2.0-posix-msvcrt-11.0.1\custombuilt64\bin\shedskin", line 4, in <module>
    Shedskin.commandline()
  File "D:\Prog\winlibs-gcc13.2.0-posix-msvcrt-11.0.1\custombuilt64\python\Lib\site-packages\shedskin\__init__.py", line 368, in commandline
    ss.build()
  File "D:\Prog\winlibs-gcc13.2.0-posix-msvcrt-11.0.1\custombuilt64\python\Lib\site-packages\shedskin\__init__.py", line 167, in build
    builder.build()
  File "D:\Prog\winlibs-gcc13.2.0-posix-msvcrt-11.0.1\custombuilt64\python\Lib\site-packages\shedskin\cmake.py", line 611, in build
    self.process(run_tests=False)
  File "D:\Prog\winlibs-gcc13.2.0-posix-msvcrt-11.0.1\custombuilt64\python\Lib\site-packages\shedskin\cmake.py", line 722, in process
    self.cmake_config(cfg_options)
  File "D:\Prog\winlibs-gcc13.2.0-posix-msvcrt-11.0.1\custombuilt64\python\Lib\site-packages\shedskin\cmake.py", line 584, in cmake_config
    assert os.system(cfg_cmd) == 0
AssertionError

So first of all it looks like -DPython_EXECUTABLE=<path_to_python>" is missing from thecmakecommand. Secondly, callingshedskinfrom the generatedbuild.ninjafile won't work as the shebang (!#) won't work on Windows. Insteadpythonshould be called withshedskin` as the first argument followed by any other arguments.

srepmub commented 6 months ago

thanks for reporting.

to be honest I haven't even tested shedskin with MinGW since the switch to cmake, so there may be other problems by now as well (from improving MSVC support). I did try to add MinGW to CI at some point, but couldn't get it to work at all (we now automatically test with MSVC, linux, OSX and the latest 3 python versions). any help from actual MinGW users welcome of course!

I will see if I can create a similar setup as you describe and test some other things as well. and create an issue for 0.9.9 to try again to include MinGW in CI.

brechtsanders commented 6 months ago

I release my own build of MinGW-w64 for native Windows at https://winlibs.com/ and have some work in progress on building my own package manager and build system.

FYI: The way I currently build shedskin under MSYS2 shell is described here: https://github.com/brechtsanders/winlibs_recipes/blob/main/recipes/shedskin.winlib

As for including MinGW-w64 in CI using Github Actions I made a minimal example here: https://github.com/brechtsanders/ci-test/blob/master/.github/workflows/ci-test.yml The example installs dependencies for each of platform (MinGW-w64, MacOS, Linux) and then builds using CMake+Ninja. Maybe it can help you setting up a MinGW-w64 build CI.

abberi commented 4 months ago

Getting mingw to work will probably help getting cross compilation to work too. (Important to target embedded use.)