-
Notifications
You must be signed in to change notification settings - Fork 72
Update build process. #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Andykl
wants to merge
10
commits into
renpy:master
Choose a base branch
from
Andykl:uv-build
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b3dafe7
`long` no longer exists.
Andykl 647e922
Make windeps actual submodule
Andykl 3da6b67
Migrate to `pyproject.toml`.
Andykl 99421ee
Migrate to scikit-build-core and CMakeLists.
Andykl c3f61dc
Fixes.
Andykl 0c1fbfb
Add headers into wheel files.
Andykl 4f3129f
Fix headers location.
Andykl 307b62f
Even more fixes.
Andykl 25d814b
Drop static transforms, it will be done differently.
Andykl 07228ec
No need to pass CC thought build system.
Andykl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
[submodule "pygame_sdl2_windeps"] | ||
path = pygame_sdl2_windeps | ||
url = https://github.com/renpy/pygame_sdl2_windeps.git | ||
branch = master |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
cmake_minimum_required(VERSION 3.21) | ||
project(${SKBUILD_PROJECT_NAME} LANGUAGES C) | ||
|
||
# Find required packages | ||
find_package(Python 3.12 EXACT REQUIRED | ||
COMPONENTS Interpreter Development.Module Development.Embed) | ||
find_package(PkgConfig REQUIRED) | ||
include(UseCython) | ||
|
||
# Find SDL2 and related libraries | ||
pkg_check_modules(SDL2 REQUIRED sdl2) | ||
pkg_check_modules(SDL2_IMAGE REQUIRED SDL2_image) | ||
pkg_check_modules(SDL2_TTF REQUIRED SDL2_ttf) | ||
pkg_check_modules(SDL2_MIXER REQUIRED SDL2_mixer) | ||
|
||
# Find additional libraries | ||
find_library(JPEG_LIBRARY jpeg REQUIRED) | ||
find_library(PNG_LIBRARY png REQUIRED) | ||
|
||
# Global settings | ||
set(CMAKE_C_STANDARD 99) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
|
||
# Include directories | ||
include_directories( | ||
${CMAKE_CURRENT_SOURCE_DIR} | ||
${CMAKE_CURRENT_SOURCE_DIR}/src | ||
${CMAKE_CURRENT_SOURCE_DIR}/include | ||
${SDL2_INCLUDE_DIRS} | ||
) | ||
|
||
set(CYTHON_ARGS | ||
-X embedsignature=True | ||
-I${CMAKE_CURRENT_SOURCE_DIR}/include) | ||
|
||
# Function to create Cython extension | ||
function(add_cython_extension name) | ||
set(options) | ||
set(oneValueArgs) | ||
set(multiValueArgs SOURCES LIBRARIES) | ||
cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) | ||
|
||
# Convert module name to path | ||
string(REPLACE "." "/" module_path ${name}) | ||
set(pyx_file ${CMAKE_CURRENT_SOURCE_DIR}/src/${module_path}.pyx) | ||
|
||
cython_transpile(${pyx_file} OUTPUT_VARIABLE c_file) | ||
|
||
# Create Python extension | ||
python_add_library(${name} MODULE ${c_file} ${ARG_SOURCES}) | ||
|
||
# Extract the base filename for the extension | ||
get_filename_component(base_filename ${module_path} NAME) | ||
|
||
# Set properties for Python 3.12 | ||
set_target_properties(${name} PROPERTIES | ||
PREFIX "" | ||
OUTPUT_NAME ${base_filename} | ||
) | ||
|
||
# Link libraries | ||
target_link_libraries(${name} PRIVATE | ||
${SDL2_LIBRARIES} | ||
${ARG_LIBRARIES} | ||
) | ||
|
||
# Add compile flags | ||
target_compile_options(${name} PRIVATE | ||
${SDL2_CFLAGS_OTHER} | ||
${EXTRA_CFLAGS} | ||
) | ||
|
||
# Install the extension | ||
string(REPLACE "." "/" install_subpath ${name}) | ||
get_filename_component(install_dir ${install_subpath} DIRECTORY) | ||
install(TARGETS ${name} DESTINATION ${install_dir}) | ||
|
||
endfunction() | ||
|
||
# Add all Cython extensions | ||
add_cython_extension(pygame_sdl2.error) | ||
add_cython_extension(pygame_sdl2.color) | ||
add_cython_extension(pygame_sdl2.controller) | ||
add_cython_extension(pygame_sdl2.rect) | ||
add_cython_extension(pygame_sdl2.rwobject) | ||
add_cython_extension(pygame_sdl2.surface | ||
SOURCES src/alphablit.c | ||
) | ||
add_cython_extension(pygame_sdl2.display) | ||
add_cython_extension(pygame_sdl2.event) | ||
add_cython_extension(pygame_sdl2.locals) | ||
add_cython_extension(pygame_sdl2.key) | ||
add_cython_extension(pygame_sdl2.mouse) | ||
add_cython_extension(pygame_sdl2.joystick) | ||
add_cython_extension(pygame_sdl2.power) | ||
add_cython_extension(pygame_sdl2.pygame_time) | ||
add_cython_extension(pygame_sdl2.image | ||
SOURCES src/write_jpeg.c src/write_png.c | ||
LIBRARIES ${SDL2_IMAGE_LIBRARIES} ${JPEG_LIBRARY} ${PNG_LIBRARY} | ||
) | ||
add_cython_extension(pygame_sdl2.transform | ||
SOURCES src/SDL2_rotozoom.c | ||
) | ||
add_cython_extension(pygame_sdl2.gfxdraw | ||
SOURCES src/SDL_gfxPrimitives.c | ||
) | ||
add_cython_extension(pygame_sdl2.draw) | ||
add_cython_extension(pygame_sdl2.font | ||
LIBRARIES ${SDL2_TTF_LIBRARIES} | ||
) | ||
add_cython_extension(pygame_sdl2.mixer | ||
LIBRARIES ${SDL2_MIXER_LIBRARIES} | ||
) | ||
add_cython_extension(pygame_sdl2.mixer_music | ||
LIBRARIES ${SDL2_MIXER_LIBRARIES} | ||
) | ||
add_cython_extension(pygame_sdl2.scrap) | ||
add_cython_extension(pygame_sdl2.render | ||
LIBRARIES ${SDL2_IMAGE_LIBRARIES} | ||
) | ||
|
||
# Install Python modules | ||
install( | ||
DIRECTORY src/pygame_sdl2/ | ||
DESTINATION pygame_sdl2 | ||
FILES_MATCHING PATTERN "*.py" | ||
) | ||
|
||
# Install data files | ||
install( | ||
FILES | ||
src/pygame_sdl2/DejaVuSans.ttf | ||
src/pygame_sdl2/DejaVuSans.txt | ||
DESTINATION pygame_sdl2 | ||
) | ||
|
||
# Install headers | ||
install( | ||
FILES | ||
src/pygame_sdl2/pygame_sdl2.h | ||
${CMAKE_CURRENT_BINARY_DIR}/src/pygame_sdl2/rwobject_api.h | ||
${CMAKE_CURRENT_BINARY_DIR}/src/pygame_sdl2/surface_api.h | ||
${CMAKE_CURRENT_BINARY_DIR}/src/pygame_sdl2/display_api.h | ||
DESTINATION include/pygame_sdl2 | ||
) | ||
|
||
# Install dlls | ||
if (WIN32) | ||
install( | ||
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/pygame_sdl2_windeps/lib/x64/ | ||
DESTINATION pygame_sdl2 | ||
FILES_MATCHING PATTERN "*.dll" | ||
) | ||
endif() |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[project] | ||
name = "pygame_sdl2" | ||
version = "2.1.0" | ||
readme = "README.rst" | ||
requires-python = "==3.12.*" | ||
dependencies = [] | ||
|
||
[build-system] | ||
requires = ["scikit-build-core>=0.11", "cython>=3.1.0", "cython-cmake"] | ||
build-backend = "scikit_build_core.build" | ||
|
||
[tool.scikit-build] | ||
build-dir = "build" |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why we're using Python 3.12, only, rather than letting the build system supply the version?