Skip to content

Update black, pyupgrade, and flake8 versions #369

Update black, pyupgrade, and flake8 versions

Update black, pyupgrade, and flake8 versions #369

name: Build and test Python wheels for Windows and make PyPI release
on:
workflow_dispatch:
push:
paths:
- '.github/workflows/build-and-test-windows-wheels.yml'
- 'include/**'
- 'scripts/**'
- 'src/**'
- 'CMakeLists.txt'
- 'setup.py'
- 'pyproject.toml'
branches: [main]
pull_request:
paths:
- '.github/workflows/build-and-test-windows-wheels.yml'
- 'include/**'
- 'scripts/**'
- 'src/**'
- 'tests/**'
- 'CMakeLists.txt'
- 'setup.py'
- 'pyproject.toml'
branches: [main]
release:
types: [published]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
# Set paths to dependencies here
BOOST_DIR: ${{ github.workspace }}\deps\boost
DXSDK_DIR: ${{ github.workspace }}\deps\DXSDK
OPENALDIR: ${{ github.workspace }}\deps\openal-soft
# Point to the correct generator and dependencies
VIZDOOM_WIN_DEPS_ROOT: ${{ github.workspace }}\deps
VIZDOOM_BUILD_GENERATOR_NAME: Visual Studio 17 2022
jobs:
build_and_test_wheels:
name: Build wheels on ${{ matrix.os }} for Python ${{ matrix.python-version }}
strategy:
matrix:
os: [windows-2022]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
fail-fast: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
# Gather all dependencies
- name: Set up Python ${{ matrix.python-version }} environment
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Python environment report
run: python -c "import sys; print(sys.version)"
- name: Get deps repo
uses: actions/checkout@v4
with:
repository: mwydmuch/ViZDoomWinDepBin
path: ${{ github.workspace }}\deps
- name: Install boost
uses: MarkusJx/install-boost@v2
id: install-boost
with:
# REQUIRED: Specify the required boost version
# A list of supported versions can be found here:
# https://github.com/MarkusJx/prebuilt-boost/blob/main/versions-manifest.json
boost_version: 1.82.0
# OPTIONAL: Specify a custom install location
boost_install_dir: ${{ github.workspace }}\deps
# OPTIONAL: Specify a platform version
platform_version: 2022
# OPTIONAL: Specify a toolset
toolset: msvc
# NOTE: If a boost version matching all requirements cannot be found,
# this build step will fail
- name: Download DXSDK
id: download-dxsdk
working-directory: ${{ github.workspace }}/deps
run: |
curl -L https://download.microsoft.com/download/a/e/7/ae743f1f-632b-4809-87a9-aa1bb3458e31/DXSDK_Jun10.exe -o _DX2010_.exe
7z x _DX2010_.exe DXSDK/Include -o_DX2010_
7z x _DX2010_.exe DXSDK/Lib -o_DX2010_
mv _DX2010_/DXSDK .
rm -fR _DX*_ _DX*_.exe
shell: bash
- name: Report working directory structure (cmd)
run: |
dir .
dir deps
- name: Report working directory structure (bash)
shell: bash
run: |
ls -la .
ls -la deps
- name: Report env (bash)
shell: bash
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
run: |
echo $BUILD_TYPE
echo $BOOST_DIR
echo $BOOST_ROOT
echo $DXSDK_DIR
echo $VIZDOOM_BUILD_GENERATOR_NAME
echo $VIZDOOM_WIN_DEPS_ROOT
# Build
- name: Python environment report
run: python -c "import sys; print(sys.version)"
- name: CMake report
run: cmake --version
- name: Build
run: |
python -m pip install --upgrade pip
python -m pip install --upgrade numpy
python -m pip install --upgrade setuptools wheel twine
python setup.py bdist_wheel
- name: Report built wheels
shell: bash
run: |
ls -l ./dist/*.whl
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: artifact-${{ matrix.os }}-${{ matrix.python-version }}
path: ./dist/*.whl
test_wheels:
name: Test wheels on ${{ matrix.os }} with Python ${{ matrix.python-version }}
needs: [build_and_test_wheels]
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-2022]
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13', '3.14']
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python ${{ matrix.python-version }} environment
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Download artificat
uses: actions/download-artifact@v4
with:
name: artifact-${{ matrix.os }}-${{ matrix.python-version }}
path: dist
- name: Report dist directory
shell: bash
run: ls -l dist
- name: Report environment
shell: bash
run: |
echo ${{ matrix.os }}
echo ${{ runner.os }}
uname -p
python -c "import sys; print(sys.version)"
- name: Install wheel
shell: bash
run: |
python -m pip install $(ls dist/vizdoom-*.whl)[test]
- name: Import check
run: python -c "import vizdoom"
- name: Init with console check
run: python -c "import vizdoom; g = vizdoom.DoomGame(); g.set_window_visible(False); g.set_console_enabled(True); g.set_sound_enabled(True); g.init()"
- name: Run test
run: python -m pytest tests -s --ignore=tests/test_gymnasium_wrapper.py # Skip gymnasium wrapper tests as they are tested in a separate workflow and take a long time to run
upload_pypi:
name: Upload to PyPI
needs: [build_and_test_wheels, test_wheels]
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/vizdoom
permissions:
id-token: write
if: github.event_name == 'release' && github.event.action == 'published'
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
pattern: artifact-*
merge-multiple: true
path: dist
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1