Skip to content

Commit

Permalink
Update manual cibuildwheel test
Browse files Browse the repository at this point in the history
  • Loading branch information
mwydmuch committed Oct 9, 2023
1 parent b01edd9 commit 6123c63
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 30 deletions.
38 changes: 27 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 [email protected] qt5"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
9 changes: 8 additions & 1 deletion tests/test_cibuildwheel/README.md
Original file line number Diff line number Diff line change
@@ -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
```
4 changes: 2 additions & 2 deletions tests/test_cibuildwheel/apt-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions tests/test_cibuildwheel/conda-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
4 changes: 2 additions & 2 deletions tests/test_cibuildwheel/dnf-based.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/test_cibuildwheel/install_and_test_wheel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 5 additions & 5 deletions tests/test_cibuildwheel/test_cibuildwheel_linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ IMAGE_PREFIX="stable-retro_wheels"

# Array in format "<base docker image> <base dockerfile to use> <additional commands to add to the dockerfile after FROM statement>"
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
Expand Down

0 comments on commit 6123c63

Please sign in to comment.