From 6b082a6b536572b3ea788b4dc249f48f6cc741ac Mon Sep 17 00:00:00 2001 From: khbminus Date: Sun, 12 Mar 2023 18:40:44 +0100 Subject: [PATCH 1/4] `NoBinary` option --- README.md | 13 ++++++++++--- idea/src/main/resources/schema/paddle-schema.json | 6 ++++++ .../python/dependencies/resolvers/PipResolver.kt | 1 + .../paddle/plugin/python/extensions/Requirements.kt | 13 ++++++++++--- .../kotlin/io/paddle/plugin/python/utils/PipArgs.kt | 5 +++++ 5 files changed, 32 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 93dfdf3c..7428902a 100644 --- a/README.md +++ b/README.md @@ -520,6 +520,8 @@ requirements: - name: numpy version: <=1.22.4 - name: pandas + - name: lxml + noBinary: true dev: - name: pytest - name: twine @@ -527,13 +529,18 @@ requirements: ``` Each requirement **must** have a specified `name` to look for in the PyPI repository, as well as an -optional `version` property. If the version is not specified, Paddle will try to resolve it by -itself when running the `resolveRequirements` task. +optional `version` and `noBinary` property. If the version is not specified, Paddle will try to +resolve it by itself when running the `resolveRequirements` task. -The version identifier can be specified as a number with some relation (e.g., by using prefixes `<=`, `>=`, `<`, `>`, +The version identifier can be specified as a number with some relation (e.g., by using +prefixes `<=`, `>=`, `<`, `>`, `==`, `!=`, `~=`, `===`), or just a general version number (the same as with `==` prefix). +`noBinary` specifies a strategy to choose a package's distribution methods. If that option is not +set, or set to false, Paddle will prefer binary wheel, otherwise Paddle will use source code +distribution. + **Note:** for now, only this format of requirement specification is available. Specifying requirements by URL/URI will be added in an upcoming Paddle release, stay tuned! diff --git a/idea/src/main/resources/schema/paddle-schema.json b/idea/src/main/resources/schema/paddle-schema.json index 3dd33b68..abfefd15 100644 --- a/idea/src/main/resources/schema/paddle-schema.json +++ b/idea/src/main/resources/schema/paddle-schema.json @@ -129,6 +129,9 @@ }, "version": { "type": "string" + }, + "noBinary": { + "type": "boolean" } } } @@ -147,6 +150,9 @@ }, "version": { "type": "string" + }, + "noBinary": { + "type": "boolean" } } } diff --git a/plugins/python/src/main/kotlin/io/paddle/plugin/python/dependencies/resolvers/PipResolver.kt b/plugins/python/src/main/kotlin/io/paddle/plugin/python/dependencies/resolvers/PipResolver.kt index 49682a55..c104306a 100644 --- a/plugins/python/src/main/kotlin/io/paddle/plugin/python/dependencies/resolvers/PipResolver.kt +++ b/plugins/python/src/main/kotlin/io/paddle/plugin/python/dependencies/resolvers/PipResolver.kt @@ -39,6 +39,7 @@ object PipResolver { noCacheDir = project.pythonRegistry.noCacheDir packages = requirementsAsPipArgs additionalArgs = project.repositories.resolved.asPipArgs + noBinaryList = project.requirements.descriptors.filter { it.isNoBinary }.map { it.name } }.args val executable = project.environment.localInterpreterPath.absolutePathString() val input = (pipResolveArgs + executable).map { it.hashable() }.hashable().hash() diff --git a/plugins/python/src/main/kotlin/io/paddle/plugin/python/extensions/Requirements.kt b/plugins/python/src/main/kotlin/io/paddle/plugin/python/extensions/Requirements.kt index 2a8bb5b2..ccb2e43e 100644 --- a/plugins/python/src/main/kotlin/io/paddle/plugin/python/extensions/Requirements.kt +++ b/plugins/python/src/main/kotlin/io/paddle/plugin/python/extensions/Requirements.kt @@ -56,7 +56,8 @@ class Requirements(val project: PaddleProject, val descriptors: MutableList must be provided for every requirement." }, versionSpecifier = req["version"]?.let { PyPackageVersionSpecifier.fromString(it) }, - type = Descriptor.Type.MAIN + type = Descriptor.Type.MAIN, + isNoBinary = req["noBinary"].toBoolean() ) } + devRequirements.map { req -> Descriptor( @@ -64,7 +65,8 @@ class Requirements(val project: PaddleProject, val descriptors: MutableList must be provided for every requirement." }, versionSpecifier = req["version"]?.let { PyPackageVersionSpecifier.fromString(it) }, - type = Descriptor.Type.DEV + type = Descriptor.Type.DEV, + isNoBinary = req["noBinary"].toBoolean() ) } @@ -72,7 +74,12 @@ class Requirements(val project: PaddleProject, val descriptors: MutableList) { var noCacheDir: Boolean = false var additionalArgs: List = emptyList() var packages: List = listOf() + var noBinaryList: List = listOf() fun build() = PipArgs(buildList { add("-m") add("pip") @@ -21,6 +22,10 @@ internal class PipArgs private constructor(val args: List) { if (noCacheDir) { add("--no-cache-dir") } + if (noBinaryList.isNotEmpty()) { + add("--no-binary") + add(noBinaryList.joinToString(separator = ",")) + } addAll(additionalArgs) addAll(packages) }) From ebd26e273474f81109c20a427e80c5366e070c12 Mon Sep 17 00:00:00 2001 From: khbminus Date: Sun, 12 Mar 2023 19:04:32 +0100 Subject: [PATCH 2/4] Added opt-ins --- .../kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt b/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt index ff54735e..f1ad2190 100644 --- a/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt +++ b/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt @@ -1,5 +1,6 @@ package io.paddle.plugin.python.utils +import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.json.Json @@ -8,5 +9,6 @@ internal val jsonParser = Json { ignoreUnknownKeys = true } +@ExperimentalSerializationApi class WrappedSerialDescriptor(override val serialName: String, original: SerialDescriptor) : SerialDescriptor by original From 406c8cdcb3896a36cec2ec9dbb67275eff5d442d Mon Sep 17 00:00:00 2001 From: khbminus Date: Mon, 13 Mar 2023 13:00:17 +0100 Subject: [PATCH 3/4] Revert "Added opt-ins" This reverts commit ebd26e273474f81109c20a427e80c5366e070c12. --- .../kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt | 2 -- 1 file changed, 2 deletions(-) diff --git a/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt b/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt index f1ad2190..ff54735e 100644 --- a/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt +++ b/plugins/python/src/main/kotlin/io/paddle/plugin/python/utils/SerializatoinUtils.kt @@ -1,6 +1,5 @@ package io.paddle.plugin.python.utils -import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.descriptors.SerialDescriptor import kotlinx.serialization.json.Json @@ -9,6 +8,5 @@ internal val jsonParser = Json { ignoreUnknownKeys = true } -@ExperimentalSerializationApi class WrappedSerialDescriptor(override val serialName: String, original: SerialDescriptor) : SerialDescriptor by original From b5425531bf01ca2603589e8345be73ef31dda57c Mon Sep 17 00:00:00 2001 From: khbminus Date: Mon, 13 Mar 2023 13:14:02 +0100 Subject: [PATCH 4/4] Add publishing test report on failure --- .github/workflows/gradle-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/gradle-test.yml b/.github/workflows/gradle-test.yml index 289bd91f..49db7d91 100644 --- a/.github/workflows/gradle-test.yml +++ b/.github/workflows/gradle-test.yml @@ -17,3 +17,8 @@ jobs: - name: 'Test with Gradle' run: ./gradlew test + - name: 'Publish Test Report' + uses: mikepenz/action-junit-report@v3 + if: failure() + with: + report_paths: '**/build/test-results/test/TEST-*.xml'