Skip to content

Commit

Permalink
fix(python): pin sdist to a specific commit
Browse files Browse the repository at this point in the history
  • Loading branch information
craftablescience committed Nov 5, 2024
1 parent b0bdec9 commit 97e58f8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
15 changes: 7 additions & 8 deletions .github/workflows/wheels.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
name: Build Wheels
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
inputs:
version:
type: string
required: true
default: YYYY.MM.DDdevN
description: 'The package version'
release:
type: boolean
required: true
default: false
description: 'Push a release to PyPI'
release:
types: [published]

jobs:
build_sdist:
Expand All @@ -29,7 +28,7 @@ jobs:

- name: Configure CMake
working-directory: '${{github.workspace}}'
run: cmake -G "Unix Makefiles" -B build -DCMAKE_BUILD_TYPE=Release -DSOURCEPP_BUILD_PYTHON_WRAPPERS=ON
run: cmake -G "Unix Makefiles" -B build -DCMAKE_BUILD_TYPE=Release -DSOURCEPP_BUILD_PYTHON_WRAPPERS=ON -DSOURCEPP_PYTHON_VERSION="${{inputs.version}}"

- name: Build SDist
run: |
Expand All @@ -47,7 +46,7 @@ jobs:

upload_release:
name: Upload a Release
if: (github.event_name == 'release' && github.event.action == 'published') || (github.event_name == 'workflow_dispatch' && inputs.release)
if: inputs.release
needs: [build_sdist]
runs-on: ubuntu-latest
environment:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ wheelhouse/
*.typed
*.whl

lang/python/CMakeLists.txt
lang/python/pyproject.toml
lang/python/src/sourcepp/__init__.py

Expand Down
17 changes: 15 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ endif()
# Python bindings, part 1
if(SOURCEPP_BUILD_PYTHON_WRAPPERS)
set(SOURCEPP_PYTHON_NAME "${PROJECT_NAME}_python")
set(SOURCEPP_PYTHON_VERSION "2024.11.5dev2")
if(NOT SOURCEPP_PYTHON_VERSION)
set(SOURCEPP_PYTHON_VERSION "0.0.1dev1")
message(WARNING "SOURCEPP_PYTHON_VERSION is not defined, do not release this build publicly! Defaulting it to ${SOURCEPP_PYTHON_VERSION}...")
endif()
find_package(Python REQUIRED
COMPONENTS Interpreter Development.Module
OPTIONAL_COMPONENTS Development.SABIModule)
Expand All @@ -114,7 +117,17 @@ if(SOURCEPP_BUILD_PYTHON_WRAPPERS)
set(${SOURCEPP_PYTHON_NAME}_SOURCES "")
set(${SOURCEPP_PYTHON_NAME}_DEFINES "")

# Set the version here
# Set the version and git commit hash here
find_package(Git REQUIRED)
execute_process(COMMAND ${GIT_EXECUTABLE} log -1 --format=%H
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
OUTPUT_VARIABLE SOURCEPP_GIT_TAG
RESULT_VARIABLE SOURCEPP_GIT_TAG_ERROR
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT SOURCEPP_GIT_TAG)
message(FATAL_ERROR "Failed to retrieve git commit SHA: ${SOURCEPP_GIT_TAG_ERROR}")
endif()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lang/python/cfg/CMakeLists.txt" "${CMAKE_CURRENT_SOURCE_DIR}/lang/python/CMakeLists.txt" @ONLY)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lang/python/cfg/pyproject.toml" "${CMAKE_CURRENT_SOURCE_DIR}/lang/python/pyproject.toml")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/lang/python/cfg/__init__.py" "${CMAKE_CURRENT_SOURCE_DIR}/lang/python/src/sourcepp/__init__.py")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ include(FetchContent)
FetchContent_Declare(
sourcepp
GIT_REPOSITORY "https://github.com/craftablescience/sourcepp.git"
GIT_TAG "origin/main")
GIT_TAG "@SOURCEPP_GIT_TAG@")
set(SOURCEPP_BUILD_PYTHON_WRAPPERS ON CACHE INTERNAL "" FORCE)
set(SOURCEPP_PYTHON_VERSION "@SOURCEPP_PYTHON_VERSION@")
FetchContent_MakeAvailable(sourcepp)

0 comments on commit 97e58f8

Please sign in to comment.