Skip to content

Commit ab601a0

Browse files
committed
fix sdist source inclusion, enable pypi test builld
1 parent 31ea7a5 commit ab601a0

3 files changed

Lines changed: 25 additions & 6 deletions

File tree

.github/workflows/pypi.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ on:
66
- published
77
### Uncomment the "push:" together with the "repository-url:" field of action pypa/gh-action-pypi-publish
88
### to make a test release. Building this is rather expensive so do not merge this uncommented!
9-
#push:
9+
push:
1010
### @Reviewer: MAKE SURE THE LINE ABOVE IS COMMENTED OUT BEFORE MERGE! ###
1111

1212
jobs:
@@ -73,4 +73,4 @@ jobs:
7373
with:
7474
skip-existing: true
7575
### To test uploads to TestPyPI in a PR, uncomment the following, as well as the "push:" line at the top:
76-
#repository-url: https://test.pypi.org/legacy/
76+
repository-url: https://test.pypi.org/legacy/

pycode/memilio-simulation/CMakeLists.txt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
cmake_minimum_required(VERSION 3.14)
22
project(memilio-python)
33

4+
# copy cpp files for building sdist's, then exit immediately
5+
# Note: ${SKBUILD_STATE} is "wheel" while building from an sdist
6+
if(SKBUILD_STATE STREQUAL "sdist")
7+
message(STATUS "Copying current C++ source tree for distribution")
8+
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/../../cpp DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}
9+
PATTERN "build" EXCLUDE
10+
PATTERN ".cache" EXCLUDE)
11+
return()
12+
endif()
13+
414
set(CMAKE_CXX_STANDARD "20")
515
set(CMAKE_CXX_STANDARD_REQUIRED "20")
616

@@ -55,7 +65,14 @@ else()
5565
endif()
5666

5767
# add in C++ library
58-
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../../cpp ${CMAKE_CURRENT_BINARY_DIR}/cpp EXCLUDE_FROM_ALL)
68+
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/cpp)
69+
# this is a sdist build, hence we use a copy C++ source tree, so that it is not out-of-tree wrt. pyproject.toml
70+
message(WARNING "Using ${CMAKE_CURRENT_SOURCE_DIR}/cpp as C++ source tree. This is intentional for sdist builds.")
71+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cpp ${CMAKE_CURRENT_BINARY_DIR}/cpp EXCLUDE_FROM_ALL)
72+
else()
73+
# normal include using the main project tree
74+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}../../cpp ${CMAKE_CURRENT_BINARY_DIR}/cpp EXCLUDE_FROM_ALL)
75+
endif()
5976

6077
# a list of all "LINKED_LIBRARIES" that are given to add_pymio_module. will contain duplicates
6178
# used for wheel installation

pycode/memilio-simulation/pyproject.toml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ build-backend = "scikit_build_core.build"
99

1010
[project]
1111
name = "memilio-simulation"
12-
dynamic = ["version"]
12+
dynamic = ["version"]
1313
description = "Part of MEmilio project, Python bindings to the C++ libraries that contain the models and simulations."
1414
readme = "README.md"
1515
requires-python = ">=3.8"
16-
license = "Apache-2.0"
16+
license = "Apache-2.0"
1717
authors = [{ name = "MEmilio Team" }]
1818
maintainers = [
1919
{ email = "martin.kuehn@dlr.de" }
@@ -56,10 +56,12 @@ cmake.version = ">=3.13"
5656
cmake.args = ["-DMEMILIO_BUILD_SHARED_LIBS:BOOL=ON"]
5757
wheel.packages = ["memilio"]
5858
wheel.install-dir = "memilio/simulation"
59+
sdist.cmake = true
60+
sdist.exclude = ["dist"]
5961
build-dir = "../build/memilio-simulation"
6062
metadata.version.provider = "scikit_build_core.metadata.setuptools_scm"
6163

62-
[tool.setuptools_scm]
64+
[tool.setuptools_scm]
6365
local_scheme = "no-local-version"
6466
# point scm to the git project root
6567
root = "../.."

0 commit comments

Comments
 (0)