Skip to content
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

NoBinary option #50

Merged
merged 6 commits into from
Mar 13, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -520,20 +520,27 @@ requirements:
- name: numpy
version: <=1.22.4
- name: pandas
- name: lxml
noBinary: true
dev:
- name: pytest
- name: twine
version: 4.0.1
```

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!

Expand Down
6 changes: 6 additions & 0 deletions idea/src/main/resources/schema/paddle-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@
},
"version": {
"type": "string"
},
"noBinary": {
"type": "boolean"
}
}
}
Expand All @@ -147,6 +150,9 @@
},
"version": {
"type": "string"
},
"noBinary": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,30 @@ class Requirements(val project: PaddleProject, val descriptors: MutableList<Desc
"Failed to parse ${project.buildFile.canonicalPath}: <name> 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(
name = checkNotNull(req["name"]) {
"Failed to parse ${project.buildFile.canonicalPath}: <name> 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()
)
}

return Requirements(project, descriptors.toMutableList())
}
}

data class Descriptor(val name: PyPackageName, val versionSpecifier: PyPackageVersionSpecifier? = null, val type: Type = Type.MAIN) : Hashable {
data class Descriptor(
val name: PyPackageName,
val versionSpecifier: PyPackageVersionSpecifier? = null,
val type: Type = Type.MAIN,
val isNoBinary: Boolean = false
) : Hashable {
enum class Type {
MAIN, DEV
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ internal class PipArgs private constructor(val args: List<String>) {
var noCacheDir: Boolean = false
var additionalArgs: List<String> = emptyList()
var packages: List<PyUrl> = listOf()
var noBinaryList: List<PyPackageName> = listOf()
fun build() = PipArgs(buildList {
add("-m")
add("pip")
Expand All @@ -21,6 +22,10 @@ internal class PipArgs private constructor(val args: List<String>) {
if (noCacheDir) {
add("--no-cache-dir")
}
if (noBinaryList.isNotEmpty()) {
add("--no-binary")
add(noBinaryList.joinToString(separator = ","))
}
addAll(additionalArgs)
addAll(packages)
SmirnovOleg marked this conversation as resolved.
Show resolved Hide resolved
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.paddle.plugin.python.utils

import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.json.Json

Expand All @@ -8,5 +9,6 @@ internal val jsonParser = Json {
ignoreUnknownKeys = true
}

@ExperimentalSerializationApi
SmirnovOleg marked this conversation as resolved.
Show resolved Hide resolved
class WrappedSerialDescriptor(override val serialName: String, original: SerialDescriptor) :
SerialDescriptor by original