Skip to content

Commit

Permalink
Fixed python extension modules built for the wrong python version (#123)
Browse files Browse the repository at this point in the history
* Test

* Test

* Test

* Test

* Test toml old setuptools

* Test

* Test min cp3.7

* Test build cp37 and cp38

* Added 3.9, 3.10 and 3.8 builds

* Removed pp37 wheels

* Updated wheels
  • Loading branch information
r4z396 authored May 6, 2022
1 parent 00f5c55 commit f6ef7ef
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 10 deletions.
118 changes: 118 additions & 0 deletions .github/workflows/wheels-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
name: Python Wheel Builds (TEST)

on:
push:
branches:
- fix_python_wheels
env:
CIBW_SKIP: cp36-manylinux_x86_64 cp36-win_amd64 cp36-macosx_x86_64 pp37-win_amd64 pp37-macosx_x86_64 pp37-manylinux_x86_64
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_24_x86_64:latest
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: quay.io/pypa/manylinux_2_24_x86_64:latest
jobs:
build_sdist:
name: Build SDist
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true

- name: Build SDist
run: pipx run build --sdist --outdir wheelhouse

- name: Check metadata
run: pipx run twine check wheelhouse/*

- name: Upload sdist
uses: actions/upload-artifact@v2
with:
name: wheels
path: wheelhouse/*.tar.gz

wheels:
strategy:
fail-fast: false
matrix:
include:
- runs-on: ubuntu-latest
cibw-arch: manylinux_x86_64
- runs-on: macos-latest
cibw-arch: macosx_x86_64
- runs-on: windows-latest
cibw-arch: win_amd64

name: Wheels � ${{ matrix.cibw-arch }}
runs-on: ${{ matrix.runs-on }}

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: recursive

- name: Setup Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
architecture: ${{ matrix.python-arch }}

- name: Install conan
shell: bash
run: |
python3 -m pip install --upgrade pip setuptools
python3 -m pip install conan
- name: Setup CMake
uses: jwlawson/actions-setup-cmake@v1.9

- name: Install requirements
run: |
python -m pip install cibuildwheel twine
- name: Configure cibuildwheel
shell: bash
run: |
CMAKE_ARCH="${{ matrix.cibw-arch == 'win32' && '-A Win32' || '' }}"
CMAKE_OSX_ARCHITECTURES=${{ matrix.cibw-arch == 'macosx_x86_64' && 'x86_64' || matrix.cibw-arch == 'macosx_arm64' && 'arm64' || matrix.cibw-arch == 'macosx_universal2' && '"arm64;x86_64"' || '' }}
echo "CIBW_BUILD=*-${{ matrix.cibw-arch }}" >> $GITHUB_ENV
CIBW_ENVIRONMENT_COMMON="CMAKE_BUILD_PARALLEL_LEVEL=2"
echo "CIBW_ENVIRONMENT=$CIBW_ENVIRONMENT_COMMON" >> $GITHUB_ENV
echo "CIBW_ENVIRONMENT_LINUX=$CIBW_ENVIRONMENT_COMMON CFLAGS='-fPIC' CXXFLAGS='-fPIC'">> $GITHUB_ENV
echo "CIBW_ENVIRONMENT_MACOS=$CIBW_ENVIRONMENT_COMMON MACOSX_DEPLOYMENT_TARGET=10.15 CMAKE_OSX_ARCHITECTURES=\"$CMAKE_OSX_ARCHITECTURES\"" >> $GITHUB_ENV
CIBW_BEFORE_ALL_COMMON=""
echo "CIBW_BEFORE_ALL=$CIBW_BEFORE_ALL_COMMON" >> $GITHUB_ENV
echo "CIBW_BEFORE_ALL_MACOS=$CIBW_BEFORE_ALL_COMMON cmake -S . -B build_dependencies -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_STRATEGA_BINDINGS=ON $CMAKE_ARCH && cmake --build build_dependencies --config Release --target stratega -j 2" >> $GITHUB_ENV
echo "CIBW_BEFORE_ALL_WINDOWS=$CIBW_BEFORE_ALL_COMMON cmake -S . -B build_dependencies -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_STRATEGA_BINDINGS=ON $CMAKE_ARCH && cmake --build build_dependencies --config Release --target stratega -j 2" >> $GITHUB_ENV
echo "CIBW_BEFORE_ALL_LINUX=$CIBW_BEFORE_BUILD_COMMON pip install conan && apt-get update && apt-get -y install libxrandr-dev libxcursor-dev libudev-dev libopenal-dev libflac-dev libvorbis-dev libgl1-mesa-dev libegl1-mesa-dev libfreetype6-dev && cmake -S . -B build_dependencies -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=ON -DENABLE_STRATEGA_BINDINGS=ON $CMAKE_ARCH && cmake --build build_dependencies --target stratega -j 2" >> $GITHUB_ENV
echo "CIBW_BEFORE_BUILD_LINUX= pip install conan " >> $GITHUB_ENV
- name: Run cibuildwheel
run: |
cibuildwheel
- name: Check built wheels
run: |
twine check wheelhouse/*
- name: Upload built wheels
if: startsWith(github.ref, 'refs/heads/docs') != true
uses: actions/upload-artifact@v2
with:
name: wheels
path: wheelhouse/*.whl
if-no-files-found: error

pypi:
name: Upload to PyPI
needs: [build_sdist, wheels]
runs-on: ubuntu-20.04
# upload pypi wheels if commit is tagged with "v"
if: github.event_name == 'push'
steps:
- name: Collect sdist and wheels
uses: actions/download-artifact@v2
with:
name: wheels
path: wheelhouse
- uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PIPSTRATEGASECRETTEST }}
repository_url: https://test.pypi.org/legacy/
packages_dir: wheelhouse/
verbose: true
2 changes: 1 addition & 1 deletion .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- '*'
pull_request:
env:
CIBW_SKIP: cp36-macosx_x86_64 pp37-win_amd64 pp37-macosx_x86_64 pp37-manylinux_x86_64
CIBW_SKIP: cp36-manylinux_x86_64 cp36-win_amd64 cp36-macosx_x86_64 pp37-win_amd64 pp37-macosx_x86_64 pp37-manylinux_x86_64
CIBW_MANYLINUX_X86_64_IMAGE: quay.io/pypa/manylinux_2_24_x86_64:latest
CIBW_MANYLINUX_PYPY_X86_64_IMAGE: quay.io/pypa/manylinux_2_24_x86_64:latest
jobs:
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.18)

project(Stratega LANGUAGES CXX)

Expand Down
2 changes: 1 addition & 1 deletion deps/conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ zlib/1.2.12
opengl/system
sfml/2.5.1
gtest/1.11.0
pybind11/2.7.1
pybind11/2.6.1
recastnavigation/cci.20200511
yaml-cpp/0.7.0
imgui/1.84.2
Expand Down
2 changes: 1 addition & 1 deletion deps/conanfile_linux.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[requires]
zlib/1.2.12
gtest/1.11.0
pybind11/2.7.1
pybind11/2.6.1
recastnavigation/cci.20200511
yaml-cpp/0.7.0
imgui/1.84.2
Expand Down
10 changes: 10 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[build-system]
requires = [
"setuptools>=61",
"setuptools_scm>=6.2",
"wheel",
"cmake>=3.18",
"pybind11~=2.6.1",
"ninja; sys_platform != 'win32'",
]
build-backend = "setuptools.build_meta"
7 changes: 3 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def build_extension(self, ext):
# EXAMPLE_VERSION_INFO shows you how to pass a value into the C++ code
# from Python.
cmake_args = [
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={}".format(extdir),
"-DPYTHON_EXECUTABLE={}".format(sys.executable),
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=" + extdir,
"-DPython_EXECUTABLE={}".format(sys.executable),
"-DCMAKE_BUILD_TYPE={}".format(cfg), # not used on MSVC, but no harm
]
build_args = []
Expand Down Expand Up @@ -126,7 +126,7 @@ def build_extension(self, ext):

setup(
name='Stratega',
version='0.1.0',
version='0.1.2',
author='Diego Perez-Liebana, Alexander Dockhorn, Jorge Hurtado Grueso, Dominik Jeurissen',
description='Stratega python bindings',
long_description=long_description,
Expand Down Expand Up @@ -160,7 +160,6 @@ def build_extension(self, ext):
"Operating System :: Microsoft :: Windows",
"Programming Language :: C++",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
Expand Down
5 changes: 3 additions & 2 deletions src/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ set(BINDING_SOURCE_FILES
)

list(TRANSFORM BINDING_SOURCE_FILES PREPEND "${SUBPROJ_PYBINDING_SRC_DIR}/")

find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
#find_package(Python COMPONENTS Interpreter Development.Module REQUIRED)
find_package(Python COMPONENTS Interpreter Development.Module)
#find_package(Python REQUIRED COMPONENTS Interpreter Development.Module)
#set(PYBIND11_FINDPYTHON TRUE)
if(DEFINED ${pybind11_SEARCH_PATH})
find_package(pybind11 CONFIG PATHS ${pybind11_SEARCH_PATH} REQUIRED)
Expand Down

0 comments on commit f6ef7ef

Please sign in to comment.