Skip to content

Commit b8120fb

Browse files
authored
Merge pull request #2557 from pygame-community/ankith26-build-meson
Add meson build system [phase 1]
2 parents f93b543 + 527ad69 commit b8120fb

File tree

21 files changed

+1226
-34
lines changed

21 files changed

+1226
-34
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828

2929
environment:
3030
# these environment variables will be passed to the docker container
31-
- CIBW_ENVIRONMENT: PIP_CONFIG_FILE=buildconfig/pip_config.ini PORTMIDI_INC_PORTTIME=1 SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
31+
- CIBW_ENVIRONMENT: SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
3232
- CIBW_BUILD: "cp3{8,9,10,11,12}-* pp3{8,9,10}-*"
3333
- CIBW_ARCHS: aarch64
3434
- CIBW_SKIP: '*-musllinux_*'

.github/workflows/build-debian-multiarch.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ jobs:
8282
8383
# Build a wheel, install it for running unit tests
8484
run: |
85-
export PIP_CONFIG_FILE=buildconfig/pip_config.ini
8685
echo "\nBuilding pygame wheel\n"
8786
python3 setup.py docs
8887
pip3 wheel . --wheel-dir /artifacts -vvv

.github/workflows/build-macos.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ jobs:
120120
# load pip config from this file. Define this in 'CIBW_ENVIRONMENT'
121121
# because this should not affect cibuildwheel machinery
122122
# also define environment variables needed for testing
123-
CIBW_ENVIRONMENT: PIP_CONFIG_FILE=buildconfig/pip_config.ini SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
123+
CIBW_ENVIRONMENT: SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
124124

125125
# Explicitly tell CIBW what the wheel arch deployment target should be
126126
# There seems to be no better way to set this than this env
@@ -147,7 +147,7 @@ jobs:
147147
bash ./install_mac_deps.sh
148148
149149
CIBW_BEFORE_BUILD: |
150-
pip install requests numpy Sphinx"<7.2.0"
150+
pip install numpy Sphinx"<7.2.0"
151151
python setup.py docs
152152
cp -r ${{ github.workspace }}/pygame_mac_deps_${{ matrix.macarch }} ${{ github.workspace }}/pygame_mac_deps
153153

.github/workflows/build-manylinux.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
# load pip config from this file. Define this in 'CIBW_ENVIRONMENT'
5353
# because this should not affect cibuildwheel machinery
5454
# also define environment variables needed for testing
55-
CIBW_ENVIRONMENT: PIP_CONFIG_FILE=buildconfig/pip_config.ini PORTMIDI_INC_PORTTIME=1 SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
55+
CIBW_ENVIRONMENT: SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
5656

5757
CIBW_BUILD: "cp3{8,9,10,11,12}-* pp3{8,9,10}-*"
5858
CIBW_ARCHS: ${{ matrix.arch }}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Tests that pygame can compile on MSYS2
2+
name: MSYS2
3+
4+
# Run CI only on changes to main branch, or any PR to main. Do not run CI on
5+
# any other branch. Also, skip any non-source changes from running on CI
6+
on:
7+
push:
8+
branches: main
9+
paths-ignore:
10+
- 'docs/**'
11+
- 'examples/**'
12+
- '.gitignore'
13+
- '*.rst'
14+
- '*.md'
15+
- '.github/workflows/*.yml'
16+
# re-include current file to not be excluded
17+
- '!.github/workflows/build-on-msys2.yml'
18+
19+
pull_request:
20+
branches: main
21+
paths-ignore:
22+
- 'docs/**'
23+
- 'examples/**'
24+
- '.gitignore'
25+
- '*.rst'
26+
- '*.md'
27+
- '.github/workflows/*.yml'
28+
# re-include current file to not be excluded
29+
- '!.github/workflows/build-on-msys2.yml'
30+
31+
concurrency:
32+
group: ${{ github.workflow }}-${{ github.ref }}-msys2
33+
cancel-in-progress: true
34+
35+
jobs:
36+
msys2:
37+
runs-on: windows-latest
38+
defaults:
39+
run:
40+
shell: msys2 {0}
41+
strategy:
42+
matrix:
43+
include:
44+
- { sys: mingw64, env: x86_64 }
45+
- { sys: mingw32, env: i686 }
46+
- { sys: ucrt64, env: ucrt-x86_64 }
47+
- { sys: clang32, env: clang-i686 }
48+
- { sys: clang64, env: clang-x86_64 }
49+
# - { sys: clangarm64, env: clang-aarch64 }
50+
51+
steps:
52+
- uses: actions/checkout@v3
53+
- uses: msys2/setup-msys2@v2
54+
with:
55+
msystem: ${{ matrix.sys }}
56+
update: true
57+
install: >-
58+
mingw-w64-${{ matrix.env }}-gcc
59+
mingw-w64-${{ matrix.env }}-pkg-config
60+
mingw-w64-${{ matrix.env }}-python
61+
mingw-w64-${{ matrix.env }}-python-pip
62+
mingw-w64-${{ matrix.env }}-python-sphinx
63+
mingw-w64-${{ matrix.env }}-meson-python
64+
65+
# mingw-w64-${{ matrix.env }}-SDL2
66+
# mingw-w64-${{ matrix.env }}-SDL2_image
67+
# mingw-w64-${{ matrix.env }}-SDL2_mixer
68+
# mingw-w64-${{ matrix.env }}-SDL2_ttf
69+
# mingw-w64-${{ matrix.env }}-freetype
70+
# mingw-w64-${{ matrix.env }}-portmidi
71+
72+
- name: Building pygame wheel
73+
run: |
74+
python3 setup.py docs
75+
pip3 wheel . --wheel-dir /artifacts -vvv --no-build-isolation
76+
77+
- name: Installing wheel
78+
run: pip3 install --no-index --pre --find-links /artifacts pygame-ce
79+
80+
- name: Run tests
81+
env:
82+
SDL_VIDEODRIVER: "dummy"
83+
SDL_AUDIODRIVER: "disk"
84+
run: python3 -m pygame.tests -v --exclude opengl,music,timing --time_out 300

.github/workflows/build-ubuntu-sdist.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,6 @@ jobs:
6464
pip3 install sphinx"<7.2.0" numpy>=1.21.0
6565
6666
- name: Make sdist and install it
67-
env:
68-
PIP_CONFIG_FILE: "buildconfig/pip_config.ini"
6967
run: |
7068
python3 setup.py docs
7169
python3 setup.py sdist

.github/workflows/build-windows.yml

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,19 +127,13 @@ jobs:
127127
# load pip config from this file. Define this in 'CIBW_ENVIRONMENT'
128128
# because this should not affect cibuildwheel machinery
129129
# also define environment variables needed for testing
130-
CIBW_ENVIRONMENT: PIP_CONFIG_FILE=buildconfig/pip_config.ini SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
130+
CIBW_ENVIRONMENT: SDL_VIDEODRIVER=dummy SDL_AUDIODRIVER=disk
131131

132132
CIBW_BUILD: ${{ matrix.pyversions }}
133133
CIBW_ARCHS: ${{ matrix.winarch }}
134134

135-
# Not sure if we can use this later. I had to move the docs into the steps section for it
136-
# to be included in the wheel
137-
# CIBW_BEFORE_BUILD: |
138-
# call "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64
139-
# set DISTUTILS_USE_SDK=1
140-
# set MSSdk=1
141-
# pip install setuptools wheel requests numpy Sphinx
142-
# python setup.py docs
135+
CIBW_BEFORE_BUILD: pip install numpy Sphinx"<7.2.0" && python setup.py docs
136+
143137
CIBW_TEST_COMMAND: python -m pygame.tests -v --exclude opengl,timing --time_out 300
144138

145139
# Increase pip debugging output
@@ -151,15 +145,9 @@ jobs:
151145
- uses: TheMrMilchmann/setup-msvc-dev@v3 # this lets us use the developer command prompt on windows
152146
with:
153147
arch: ${{ matrix.msvc-dev-arch }}
148+
154149
- name: Build and test wheels
155-
shell: cmd
156-
run: |
157-
set DISTUTILS_USE_SDK=1
158-
set MSSdk=1
159-
python -m pip install setuptools wheel requests numpy Sphinx"<7.2.0"
160-
python setup.py docs
161-
python -m pip --disable-pip-version-check install cibuildwheel==2.16.4
162-
python -m cibuildwheel --output-dir wheelhouse
150+
uses: pypa/[email protected]
163151

164152
- uses: actions/upload-artifact@v4
165153
with:

buildconfig/get_version.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
"""
2+
A simple script that reads the pyproject.toml at the root of the project, and
3+
prints the project version specified in it.
4+
"""
5+
6+
import sys
7+
import pathlib
8+
9+
base_dir = pathlib.Path(__file__).parents[1]
10+
config_file = base_dir / "pyproject.toml"
11+
config_text = config_file.read_text()
12+
13+
if sys.version_info >= (3, 11):
14+
# more elegant and robust solution
15+
import tomllib
16+
17+
conf = tomllib.loads(config_text)
18+
version = conf["project"]["version"]
19+
20+
else:
21+
# hacky solution, because we don't have tomllib in stdlib on older python
22+
# versions
23+
import re
24+
import ast
25+
26+
finds = re.findall(r"^version\s*=(.*)", config_text, flags=re.MULTILINE)
27+
if len(finds) != 1:
28+
raise RuntimeError(f"Could not find precise version from {config_file}")
29+
30+
version = ast.literal_eval(finds[0].strip())
31+
32+
print(version)

buildconfig/pip_config.ini

Lines changed: 0 additions & 10 deletions
This file was deleted.

buildconfig/stubs/meson.build

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
install_subdir(
2+
'pygame',
3+
exclude_files: '.flake8',
4+
install_dir: pg_dir,
5+
strip_directory: true,
6+
install_tag: 'pg-tag',
7+
)

0 commit comments

Comments
 (0)