From 6123c63bc3f33aba2433578614f6ba52db13b984 Mon Sep 17 00:00:00 2001 From: Marek Wydmuch Date: Mon, 9 Oct 2023 03:26:42 +0200 Subject: [PATCH] Update manual cibuildwheel test --- CMakeLists.txt | 38 +++++++++++++------ pyproject.toml | 6 --- setup.py | 2 +- tests/test_cibuildwheel/README.md | 9 ++++- tests/test_cibuildwheel/apt-based.Dockerfile | 4 +- .../test_cibuildwheel/conda-based.Dockerfile | 2 + tests/test_cibuildwheel/dnf-based.Dockerfile | 4 +- .../install_and_test_wheel.sh | 4 +- .../test_cibuildwheel_linux.sh | 10 ++--- 9 files changed, 49 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 306c19dac..64a36b3ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,31 @@ if(POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif() +if(LINUX) + set(PYEXT_SUFFIX + ".so" + CACHE STRING "Suffix for Python extension modules") + set(DYNLIB_SUFFIX + ".so" + CACHE STRING "Suffix for dynamic libraries") +elseif(APPLE) + set(PYEXT_SUFFIX + ".so" + CACHE STRING "Suffix for Python extension modules") + set(DYNLIB_SUFFIX + ".dylib" + CACHE STRING "Suffix for dynamic libraries") +elseif(WIN32) + set(PYEXT_SUFFIX + ".pyd" + CACHE STRING "Suffix for Python extension modules" FORCE) + set(DYNLIB_SUFFIX + ".dll" + CACHE STRING "Suffix for dynamic libraries") +else() + message(FATAL_ERROR "Unsupported platform") +endif() + find_package(Git QUIET) file(READ "${CMAKE_SOURCE_DIR}/retro/VERSION" PROJECT_VERSION) @@ -103,16 +128,6 @@ else() WORKING_DIRECTORY "${LUA_INCLUDE_DIRS}") endif() -if(NOT WIN32) - set(PYEXT_SUFFIX - ".so" - CACHE STRING "Suffix for Python extension modules") -else() - set(PYEXT_SUFFIX - ".pyd" - CACHE STRING "Suffix for Python extension modules" FORCE) -endif() - if(CMAKE_C_COMPILER_ID STREQUAL "GNU") set(STATIC_LDFLAGS "-static-libstdc++ -Wl,--exclude-libs,ALL") endif() @@ -184,7 +199,8 @@ function(add_core platform core_name) ${CMAKE_COMMAND} -E env CFLAGS=${core_cflags} CXXFLAGS=${core_cxxflags} LDFLAGS=${core_ldflags} $(MAKE) -f ${makefile} CC="${CMAKE_C_COMPILER}" CXX="${CMAKE_CXX_COMPILER}" fpic=${core_fpic_flags} ${libretro_platform} - COMMAND ${CMAKE_COMMAND} -E copy "${core_name}_libretro*" "${TARGET_PATH}" + COMMAND ${CMAKE_COMMAND} -E copy "${core_name}_libretro${DYNLIB_SUFFIX}" + "${TARGET_PATH}" WORKING_DIRECTORY "cores/${platform}/${subdir}" DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/retro/cores/${core_name}-version") unset(core_ldflags) diff --git a/pyproject.toml b/pyproject.toml index 1f465c912..293d88e1b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,20 +8,14 @@ build = "cp{38,39,310,311}-*" [tool.cibuildwheel.linux] # Only manylinux is supported (no musl) build = "cp{38,39,310,311}-manylinux*" -repair-wheel-command = "auditwheel -v show {wheel} && auditwheel repair -w {dest_dir} {wheel}" -build-verbosity = 3 # For manylinux_2_28 we need to install the following dependencies using yum: before-all = "yum install -y cmake git pkgconf-pkg-config zlib-devel libzip-devel bzip2-devel" -#before-all = "yum install -y cmake git zlib-devel libzip-devel bzip2-devel" -#before-all = "yum install -y cmake git zlib-devel libzip-devel" # Only build for x86_64 and aarch64 are officially supported archs = "x86_64 aarch64" manylinux-x86_64-image = "manylinux_2_28" manylinux-aarch64-image = "manylinux_2_28" -#manylinux-x86_64-image = "manylinux2014" -#manylinux-aarch64-image = "manylinux2014" [tool.cibuildwheel.macos] before-all = "brew install pkg-config capnp lua@5.1 qt5" diff --git a/setup.py b/setup.py index c1ef36ef8..cb4d7ffbe 100644 --- a/setup.py +++ b/setup.py @@ -88,7 +88,7 @@ def run(self): version=open(VERSION_PATH).read().strip(), license="MIT", install_requires=["gymnasium>=0.27.1", "pyglet>=1.3.2,==1.*"], - python_requires=">=3.6.0,<3.11", + python_requires=">=3.8.0,<3.11", ext_modules=[Extension("retro._retro", ["CMakeLists.txt", "src/*.cpp"])], cmdclass={"build_ext": CMakeBuild}, packages=[ diff --git a/tests/test_cibuildwheel/README.md b/tests/test_cibuildwheel/README.md index 943d1e562..862781be8 100644 --- a/tests/test_cibuildwheel/README.md +++ b/tests/test_cibuildwheel/README.md @@ -1,3 +1,10 @@ # Test cibuildwheel -This is a test of cibuildwheel, run `test_cibuildwheel.sh` to build the wheels locally, and test them on different Linux distros. +This is a test of cibuildwheel, run `test_cibuildwheel.sh` to build the wheels locally, and test them on different Linux distros. Requires cibuildwheel and docker to be installed. + +## Usage + +Run manually: +```bash +./test_cibuildwheel.sh +``` diff --git a/tests/test_cibuildwheel/apt-based.Dockerfile b/tests/test_cibuildwheel/apt-based.Dockerfile index ae8d391db..f9f9dbe99 100644 --- a/tests/test_cibuildwheel/apt-based.Dockerfile +++ b/tests/test_cibuildwheel/apt-based.Dockerfile @@ -5,8 +5,8 @@ ENV TZ=Europe/London WORKDIR /stable-retro -# Install Python and pip -RUN apt update && apt install -y python3-dev python3-pip +# Install Python and pip, OpenGL, and Xvfb +RUN apt update && apt install -y python3-dev python3-pip python3-opengl freeglut3-dev xvfb COPY tests tests COPY wheelhouse wheelhouse diff --git a/tests/test_cibuildwheel/conda-based.Dockerfile b/tests/test_cibuildwheel/conda-based.Dockerfile index d531a3cc6..0da5736f8 100644 --- a/tests/test_cibuildwheel/conda-based.Dockerfile +++ b/tests/test_cibuildwheel/conda-based.Dockerfile @@ -2,6 +2,8 @@ FROM continuumio/miniconda3:latest WORKDIR /stable-retro +RUN apt update && apt install -y freeglut3-dev xvfb + COPY tests tests COPY wheelhouse wheelhouse CMD ["bash", "./tests/test_cibuildwheel/install_and_test_wheel.sh"] diff --git a/tests/test_cibuildwheel/dnf-based.Dockerfile b/tests/test_cibuildwheel/dnf-based.Dockerfile index c3e381e5f..597fae340 100644 --- a/tests/test_cibuildwheel/dnf-based.Dockerfile +++ b/tests/test_cibuildwheel/dnf-based.Dockerfile @@ -2,8 +2,8 @@ FROM fedora:latest WORKDIR /stable-retro -# Install Python and pip -RUN dnf update -y && dnf clean all && dnf install -y python3-devel python3-pip +# Install Python and pip, OpenGL, and Xvfb +RUN dnf update -y && dnf clean all && dnf install -y python3-devel python3-pip freeglut-devel xorg-x11-server-Xvfb COPY tests tests COPY wheelhouse wheelhouse diff --git a/tests/test_cibuildwheel/install_and_test_wheel.sh b/tests/test_cibuildwheel/install_and_test_wheel.sh index 1de3bb921..d5e6815db 100755 --- a/tests/test_cibuildwheel/install_and_test_wheel.sh +++ b/tests/test_cibuildwheel/install_and_test_wheel.sh @@ -25,5 +25,5 @@ python3 -m pip install ${PYTHON_WHEEL} # Test import python3 -c "import retro" -# Run tests -pytest +# Run tests with xvfb and pytest +xvfb-run -s '-screen 0 1024x768x24' pytest diff --git a/tests/test_cibuildwheel/test_cibuildwheel_linux.sh b/tests/test_cibuildwheel/test_cibuildwheel_linux.sh index 482829bed..071419bbd 100755 --- a/tests/test_cibuildwheel/test_cibuildwheel_linux.sh +++ b/tests/test_cibuildwheel/test_cibuildwheel_linux.sh @@ -13,14 +13,14 @@ IMAGE_PREFIX="stable-retro_wheels" # Array in format " " DOCKERFILES_TO_BUILD_AND_RUN=( - "almalinux:9 dnf-based.Dockerfile" # Python 3.9 - "fedora:36 dnf-based.Dockerfile" # Python 3.10 - "fedora:37 dnf-based.Dockerfile" # Python 3.11 - "rockylinux:9 dnf-based.Dockerfile" # Python 3.9 "debian:11.6 apt-based.Dockerfile ENV LANG C.UTF-8" # Python 3.9 "ubuntu:20.04 apt-based.Dockerfile" # Python 3.8 "ubuntu:22.04 apt-based.Dockerfile" # Python 3.10 - "continuumio/miniconda3:latest conda-based.Dockerfile" # Python 3.10 + #"continuumio/miniconda3:latest conda-based.Dockerfile" # Python 3.11 - not supported at the moment + #"almalinux:9 dnf-based.Dockerfile" # Python 3.9 - test doesn't work becouse of pyglet requirement for X server + #"rockylinux:9 dnf-based.Dockerfile" # Python 3.9 - as above + #"fedora:36 dnf-based.Dockerfile" # Python 3.10 - as above + #"fedora:37 dnf-based.Dockerfile" # Python 3.11 - not supported at the moment ) # Clean local directory to avoid problems