Skip to content

Commit

Permalink
Merge pull request #50 from JetBrains-Research/khbminus/no-binary-flag
Browse files Browse the repository at this point in the history
`NoBinary` option
  • Loading branch information
khbminus committed Mar 13, 2023
2 parents edb637a + b4f8782 commit b996459
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/gradle-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -523,20 +523,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 @@ -133,6 +133,9 @@
},
"version": {
"type": "string"
},
"noBinary": {
"type": "boolean"
}
}
}
Expand All @@ -151,6 +154,9 @@
},
"version": {
"type": "string"
},
"noBinary": {
"type": "boolean"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ object PipResolver {
noCacheDir = project.pythonRegistry.noCacheDir
packages = requirementsAsPipArgs
additionalArgs = project.repositories.resolved.asPipArgs
noBinaryList = project.requirements.descriptors.filter { it.isNoBinary }.map { it.name }
noIndex = project.environment.noIndex
}.args
val executable = project.environment.localInterpreterPath.absolutePathString()
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()
var noIndex: Boolean = false
fun build() = PipArgs(buildList {
add("-m")
Expand All @@ -22,6 +23,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 = ","))
}
if (noIndex) {
add("--no-index")
}
Expand Down

0 comments on commit b996459

Please sign in to comment.