Skip to content

Commit 7a6d4a7

Browse files
authored
Merge pull request #2831 from pygame-community/ankith26-remove-cython
Remove cython gen files, generate in meson build
2 parents a68f741 + fe3d546 commit 7a6d4a7

File tree

15 files changed

+30
-124365
lines changed

15 files changed

+30
-124365
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ env:
4040
INSTALL_CMD: |
4141
apt-get update --fix-missing
4242
apt-get upgrade -y
43-
apt-get install build-essential meson -y
43+
apt-get install build-essential meson cython3 -y
4444
apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev -y
4545
apt-get install libfreetype6-dev libportmidi-dev fontconfig -y
4646
apt-get install python3-dev python3-pip python3-wheel python3-sphinx -y

.github/workflows/build-emsdk.yml

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,33 +40,12 @@ jobs:
4040
SDK_ARCHIVE: python3.11-wasm-sdk-Ubuntu-22.04.tar.lz4
4141
SDKROOT: /opt/python-wasm-sdk
4242

43-
# use the most recent cython from github, but pin on a commit for CI
44-
# stability. This is also needed to benefit from caching cython installs
45-
LATEST_CYTHON_COMMIT: 2f3a781dcca092ce95fbfef2736b12b0d1ab50dd # cython 3.0.0
46-
47-
WHEELHOUSE_CYTHON: /tmp/wheelhouse/cython
48-
4943
steps:
5044
- uses: actions/[email protected]
5145

52-
- name: Cache Cython
53-
id: cache-cython
54-
uses: actions/[email protected]
55-
with:
56-
path: ${{ env.WHEELHOUSE_CYTHON }}
57-
key: wasm-ubuntu-cython-${{ env.LATEST_CYTHON_COMMIT }}-path-${{ env.WHEELHOUSE_CYTHON }}
58-
59-
# This builds the cython wheel and stores it in cache too
60-
- name: Download and build cython on cache miss
61-
if: steps.cache-cython.outputs.cache-hit != 'true'
62-
run: |
63-
mkdir -p $WHEELHOUSE_CYTHON
64-
pip wheel --wheel-dir $WHEELHOUSE_CYTHON git+https://github.com/cython/cython.git@$LATEST_CYTHON_COMMIT
65-
66-
- name: Install latest cython and regen
46+
- name: Regen with latest cython (using system python3)
6747
run: |
68-
pip install --no-index --find-links $WHEELHOUSE_CYTHON --pre cython
69-
touch $(find | grep pxd$)
48+
pip3 install cython==3.0.10
7049
python3 setup.py cython_only
7150
7251
- name: Install python-wasm-sdk

.github/workflows/build-on-msys2.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ jobs:
6161
mingw-w64-${{ matrix.env }}-python-pip
6262
mingw-w64-${{ matrix.env }}-python-sphinx
6363
mingw-w64-${{ matrix.env }}-meson-python
64+
mingw-w64-${{ matrix.env }}-cython
6465
6566
# mingw-w64-${{ matrix.env }}-SDL2
6667
# mingw-w64-${{ matrix.env }}-SDL2_image

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ dist
4444
*.so
4545
__pycache__
4646
_headers/*
47+
48+
# cython generated files
49+
src_c/_sdl2/*.c
50+
!/src_c/_sdl2/touch.c
51+
src_c/pypm.c

meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
project(
22
'pygame_ce',
3-
'c', # Project type. We only need a C compiler
3+
['c', 'cython'], # Project type. We need a C compiler and cython
44
version: run_command(
55
[find_program('python3', 'python'), 'buildconfig/get_version.py'],
66
check: true,

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ classifiers = [
4848
hook-dirs = 'pygame.__pyinstaller:get_hook_dirs'
4949

5050
[build-system]
51-
requires = ["meson-python", "ninja"] # add cython here when needed
51+
requires = ["meson-python", "ninja", "cython"]
5252
build-backend = 'mesonpy'
5353

5454
[tool.meson-python.args]

setup.py

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,15 @@ def consume_arg(name):
191191
cflags += '-mfpu=neon'
192192
os.environ['CFLAGS'] = cflags
193193

194-
compile_cython = False
195-
cython_only = False
196-
if consume_arg('cython'):
197-
compile_cython = True
194+
no_compilation = bool({'docs', 'sdist', 'stubcheck'}.intersection(sys.argv))
195+
196+
compile_cython = not no_compilation
198197

198+
# does nothing now, but consume the arg anyways for compatibilty
199+
consume_arg('cython')
200+
201+
cython_only = False
199202
if consume_arg('cython_only'):
200-
compile_cython = True
201203
cython_only = True
202204

203205
if compile_cython:
@@ -243,22 +245,13 @@ def consume_arg(name):
243245

244246
# update outdated .c files
245247
if os.path.isfile(c_file):
246-
c_timestamp = os.path.getmtime(c_file)
247-
if c_timestamp < deps.timestamp(pyx_file):
248-
dep_timestamp, dep = deps.timestamp(pyx_file), pyx_file
249-
priority = 0
250-
else:
251-
dep_timestamp, dep = deps.newest_dependency(pyx_file)
252-
priority = 2 - (dep in deps.immediate_dependencies(pyx_file))
253-
if dep_timestamp > c_timestamp:
254-
outdated = True
255-
else:
256-
outdated = False
248+
outdated = False
249+
priority = 0
257250
else:
258251
outdated = True
259252
priority = 0
260253
if outdated:
261-
print(f'Compiling {pyx_file} because it changed.')
254+
print(f'Compiling {pyx_file} because the generated C file is missing.')
262255
queue.append((priority, {'pyx_file': pyx_file, 'c_file': c_file, 'fingerprint': None, 'quiet': False,
263256
'options': c_options, 'full_module_name': ext.name,
264257
'embedded_metadata': pyx_meta.get(ext.name)}))
@@ -275,7 +268,6 @@ def consume_arg(name):
275268
if cython_only:
276269
sys.exit(0)
277270

278-
no_compilation = 'docs' in sys.argv
279271
AUTO_CONFIG = not os.path.isfile('Setup') and not no_compilation
280272
if consume_arg('-auto'):
281273
AUTO_CONFIG = True

0 commit comments

Comments
 (0)