Skip to content

Commit 81529bc

Browse files
authored
Merge pull request #318 from thisisthepy/feat/one-published-version
Build: one published version for library, KSP and plugin (#70)
2 parents 34c4957 + 6be768c commit 81529bc

6 files changed

Lines changed: 79 additions & 24 deletions

File tree

‎build.gradle.kts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,23 @@ plugins {
1111
alias(libs.plugins.ksp).apply(false)
1212
}
1313

14+
// One published version for every artifact (#70): "$pythonVersion-$libraryVersionSuffix", the same
15+
// value python-multiplatform and the included Gradle-plugin build derive from gradle.properties.
16+
val publishedVersion = "${property("pythonVersion")}-${property("libraryVersionSuffix")}"
17+
1418
allprojects {
1519
group = "io.github.thisisthepy"
16-
version = "3.13.0" // Official Python release version
20+
version = publishedVersion
21+
}
22+
23+
// Fails the build when any project in this build publishes under another version; the plugin build
24+
// checks its own the same way (python-multiplatform-gradle-plugin/build.gradle.kts).
25+
gradle.projectsEvaluated {
26+
val wrong = rootProject.allprojects.filter { it.version.toString() != publishedVersion }
27+
check(wrong.isEmpty()) {
28+
"published versions disagree (#70): expected $publishedVersion, got " +
29+
wrong.joinToString { "${it.path}=${it.version}" }
30+
}
1731
}
1832

1933
// ROADMAP §15a/§15e item 3: `python-multiplatform-gradle-plugin` is a separate included build

‎docs/roadmap/ROADMAP.md‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,13 +304,10 @@ Old §15a, §15b, §15d, §15f, §15g, §15h are closed; §15e item 4 is closed
304304
configured (`signing { }` is commented out in `python-multiplatform/build.gradle.kts`), and
305305
`repo1.maven.org/maven2/io/github/thisisthepy/python-multiplatform/` returns 404 (2026-10-03).
306306
Every consumer verification so far used `mavenLocal()`. 10.1 depends on this or on a release asset.
307-
- **15.2 The KSP processor and plugin versions are hand-copied literals, open.** Root
308-
`build.gradle.kts` `allprojects { version = "3.13.0" }` (inherited by `python-multiplatform-ksp`) and
309-
`python-multiplatform-gradle-plugin/build.gradle.kts` `version = "3.13.0"` agree only by hand, while
310-
the library publishes `3.14.7-alpha01` from `gradle.properties`. The plugin bakes
311-
`DEFAULT_PROCESSOR_COORDINATES` from its own version, so the two literals drifting would reproduce
312-
the "processor coordinate that exists nowhere" defect with no configuration-time error. A check, or
313-
one source for both, is what is left.
307+
- **15.2 The library, KSP processor and plugin publish under one version, done (#70).** Each build
308+
derives it from `gradle.properties` (`$pythonVersion-$libraryVersionSuffix`, a `-P` override included);
309+
the root build fails when a project's version differs, and `PublishedVersionTest` pins the processor
310+
and wasm-runtime coordinates the plugin bakes to that version.
314311
- **15.3 `stagePythonHome` has run only on `macos-aarch64`, partial.** Linux-x86_64, macOS-x86_64 and
315312
Windows-x86_64 are pinned as string assertions in `PythonHomeStagingTest`; Windows' `Lib/`+`DLLs/`
316313
layout and `linux-aarch64` (no `libpython` in `desktopJar`, relies on `manager.loadFromSidecar`) have

‎gradle.properties‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ pythonVersion=3.15.0
3131
pythonFreeThreaded=false
3232
pythonBuildStandaloneRelease=20261013
3333
pythonAppleSupportBuild=b11
34+
# Every published artifact (library, KSP processor, Gradle plugin) is versioned
35+
# "$pythonVersion-$libraryVersionSuffix"; each build derives it from these two values and fails if
36+
# its own version disagrees (#70).
37+
libraryVersionSuffix=alpha01
3438

3539
# GraalVM native-image (sample's nativeCompile task). Liberica NIK is not in a location Gradle's
3640
# toolchain auto-detection scans, so it is registered explicitly here. Adding a path only makes a

‎python-multiplatform-gradle-plugin/build.gradle.kts‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,17 @@ plugins {
88
}
99

1010
group = "io.github.thisisthepy"
11-
version = "3.13.0" // kept in step with the root build's version, which the processor is published under
11+
// Same published version as the library and the KSP processor (#70): "$pythonVersion-$suffix" from
12+
// the root's gradle.properties, a -P override winning as it does in the root build (Gradle hands
13+
// start-parameter properties to included builds too).
14+
val rootGradleProperties = Properties().apply {
15+
val file = rootDir.resolve("../gradle.properties")
16+
if (file.isFile) file.inputStream().use { load(it) }
17+
}
18+
fun rootProperty(name: String, fallback: String): String =
19+
findProperty(name)?.toString() ?: rootGradleProperties.getProperty(name) ?: fallback
20+
val publishedVersion = "${rootProperty("pythonVersion", "3.15.0")}-${rootProperty("libraryVersionSuffix", "alpha01")}"
21+
version = publishedVersion
1222

1323
/**
1424
* `KlibScanner`'s reader, named once because three places have to agree on it: this module's own
@@ -239,20 +249,13 @@ val generateCoordinates = tasks.register("generateCoordinates") {
239249
// second copy of these values that drifted would pair a stdlib with an interpreter from a
240250
// different build. The fallbacks match `python-multiplatform/build.gradle.kts`'s own, for the
241251
// case where this build is checked out without the root's properties beside it.
242-
val rootProperties = Properties().apply {
243-
val file = rootDir.resolve("../gradle.properties")
244-
if (file.isFile) file.inputStream().use { load(it) }
245-
}
246-
val pythonVersionValue = rootProperties.getProperty("pythonVersion") ?: "3.15.0"
247-
val pbsReleaseValue = rootProperties.getProperty("pythonBuildStandaloneRelease") ?: "20261013"
248-
val freeThreadedValue = rootProperties.getProperty("pythonFreeThreaded")?.toBoolean() ?: false
252+
val pythonVersionValue = rootProperty("pythonVersion", "3.15.0")
253+
val pbsReleaseValue = rootProperty("pythonBuildStandaloneRelease", "20261013")
254+
val freeThreadedValue = rootProperty("pythonFreeThreaded", "false").toBoolean()
249255

250-
// `python-multiplatform` itself is versioned "$pythonVersion-alpha01" -- see that build's own
251-
// `val libraryVersion` -- which is *not* this plugin build's `project.version` (kept in step by
252-
// hand, see the top of this file). The wasm-runtime zip is published under the library's
253-
// version, alongside the library artifact it has to pair with, so the coordinate has to be
254-
// built the same way rather than reusing this plugin's own version.
255-
val libraryVersionValue = "$pythonVersionValue-alpha01"
256+
// The library and this plugin publish under one version since #70, so the wasm-runtime zip
257+
// (published beside the library artifact) is at this build's own version.
258+
val libraryVersionValue = publishedVersion
256259
val wasmRuntimeCoordinatesValue = "${project.group}:python-multiplatform-wasm-runtime:$libraryVersionValue"
257260

258261
val klibWorkerValue = klibWorkerCoordinates
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package python.multiplatform.gradle
2+
3+
import java.io.File
4+
import java.util.Properties
5+
import kotlin.test.Test
6+
import kotlin.test.assertEquals
7+
8+
/**
9+
* Issue #70: the library, the KSP processor and this plugin publish under one version,
10+
* "$pythonVersion-$libraryVersionSuffix" from the root `gradle.properties`. The plugin hands a
11+
* consumer the processor's and the wasm runtime's coordinates at its own version, so both must carry
12+
* exactly the library's version: a plugin left at an older number (it was 3.13.0 beside a 3.14.7
13+
* library) would resolve a processor nobody published with that library.
14+
*/
15+
class PublishedVersionTest {
16+
17+
private val expected: String = Properties().run {
18+
File("../gradle.properties").inputStream().use { load(it) }
19+
"${getProperty("pythonVersion")}-${getProperty("libraryVersionSuffix")}"
20+
}
21+
22+
@Test
23+
fun theProcessorCoordinateCarriesTheLibraryVersion() {
24+
assertEquals(
25+
"io.github.thisisthepy:python-multiplatform-ksp:$expected",
26+
DEFAULT_PROCESSOR_COORDINATES,
27+
)
28+
}
29+
30+
@Test
31+
fun theWasmRuntimeCoordinateCarriesTheLibraryVersion() {
32+
assertEquals(
33+
"io.github.thisisthepy:python-multiplatform-wasm-runtime:$expected",
34+
DEFAULT_WASM_RUNTIME_COORDINATES,
35+
)
36+
}
37+
}

‎python-multiplatform/build.gradle.kts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ plugins {
6262
}
6363

6464

65-
val configuredPythonVersion = project.findProperty("pythonVersion")?.toString() ?: project.rootProject.version.toString()
65+
val configuredPythonVersion = project.property("pythonVersion").toString()
6666
val pythonFreeThreaded = project.findProperty("pythonFreeThreaded")?.toString()?.toBoolean() ?: false
6767
val pbsRelease = project.findProperty("pythonBuildStandaloneRelease")?.toString() ?: "20261013"
6868
val pythonAppleSupportBuild = project.findProperty("pythonAppleSupportBuild")?.toString() ?: "b11"
6969

7070
val pythonVersion = configuredPythonVersion
71-
val libraryVersion = "$pythonVersion-alpha01"
71+
val libraryVersion = "$pythonVersion-${project.property("libraryVersionSuffix")}" // the root's publishedVersion (#70)
7272
version = libraryVersion
7373

7474
buildkonfig {

0 commit comments

Comments
 (0)