Skip to content

Commit 150c491

Browse files
authored
IGNITE-27645 Python DB API: Fix version generation (#7466)
1 parent 63ae31f commit 150c491

File tree

3 files changed

+30
-83
lines changed

3 files changed

+30
-83
lines changed

modules/platforms/build.gradle

Lines changed: 24 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ plugins {
1919
id 'signing'
2020
alias(libs.plugins.checksum)
2121
alias(libs.plugins.cmake)
22-
alias(libs.plugins.dockerRemoteApi)
2322
}
2423

2524
import dev.welbyseely.CMakeBuildTask
@@ -28,11 +27,6 @@ import groovy.json.JsonOutput
2827
import groovy.json.JsonSlurper
2928
import org.apache.tools.ant.taskdefs.condition.Os
3029
import org.gradle.crypto.checksum.Checksum
31-
import com.bmuschko.gradle.docker.tasks.container.DockerStartContainer
32-
import com.bmuschko.gradle.docker.tasks.container.DockerStopContainer
33-
import com.bmuschko.gradle.docker.tasks.container.DockerCreateContainer
34-
import com.bmuschko.gradle.docker.tasks.container.DockerExecContainer
35-
import com.bmuschko.gradle.docker.tasks.image.DockerBuildImage
3630

3731
configurations {
3832
cppClient
@@ -42,9 +36,6 @@ configurations {
4236
platformsHeaders
4337
}
4438

45-
def manylinuxWheelsContainerName = "ignite_manylinux_wheels"
46-
def manylinuxWheelsImageName = "ignite_manylinux_python_wheels_build"
47-
4839
dependencies {
4940
platformsHeaders project(path: ':ignite-api', configuration: 'platformsHeaders')
5041
}
@@ -267,6 +258,29 @@ private String simpleProjectVersion(String version) {
267258
return version
268259
}
269260

261+
/**
262+
* Converts the version to the python version format.
263+
* See https://packaging.python.org/en/latest/discussions/versioning/
264+
*/
265+
private String pythonProjectVersion(String version) {
266+
def (simple, addition) = version.tokenize('-')
267+
if (addition == null) {
268+
return simple
269+
}
270+
271+
def pythonAddition = addition
272+
.toLowerCase()
273+
.replace("alpha", "a")
274+
.replace("beta", "b")
275+
.replace("patch", "post")
276+
.replace("snapshot", "dev")
277+
278+
if (pythonAddition.matches("(a|b|rc)\\d+")) {
279+
return simple + pythonAddition
280+
}
281+
return simple + '.' + pythonAddition
282+
}
283+
270284
private void updateDotnetVersion(String version) {
271285
def versionFile = file("$projectDir/dotnet/version.json")
272286
def json = new JsonSlurper().parseText(versionFile.text)
@@ -277,73 +291,5 @@ private void updateDotnetVersion(String version) {
277291

278292
private void updatePythonVersion(String version) {
279293
def versionFile = file("$projectDir/python/pyignite_dbapi/_version.txt")
280-
versionFile.text = simpleProjectVersion(version)
281-
}
282-
283-
def buildWindowsDbApiWheels = tasks.register('buildWindowsDbApiWheels', Exec) {
284-
workingDir "$projectDir/python"
285-
286-
commandLine "cmd", "/c", "Powershell -File .\\scripts\\BuildWheels.ps1 -PyVers \"$dbapiPythonVersions\""
287-
}
288-
289-
private void handleError(Throwable exc) {
290-
if (exc == null)
291-
return;
292-
String strErr = exc.toString()
293-
project.logger.info(">>>>>>>>> Error: " + strErr)
294-
if (!strErr.contains('NotModifiedException') &&
295-
!strErr.contains('No such container')) {
296-
project.logger.info(">>>>>>>>> Re-throwing error")
297-
throw new RuntimeException(exc)
298-
}
294+
versionFile.text = pythonProjectVersion(version)
299295
}
300-
301-
def buildManyLinuxWheelsDockerImage = tasks.register('buildManyLinuxWheelsDockerImage', DockerBuildImage) {
302-
inputDir = file("$projectDir/python/scripts")
303-
images = ["$manylinuxWheelsImageName"]
304-
}
305-
306-
def createManyLinuxWheelsContainer = tasks.register('createManyLinuxWheelsContainer', DockerCreateContainer) {
307-
dependsOn buildManyLinuxWheelsDockerImage
308-
targetImageId "$manylinuxWheelsImageName"
309-
containerName = "$manylinuxWheelsContainerName"
310-
withEnvVar("PLAT", "manylinux2014_x86_64")
311-
hostConfig.autoRemove = true
312-
hostConfig.binds = [
313-
"$projectDir/python":"/pyignite_dbapi",
314-
"$projectDir/cpp":"/cpp",
315-
"$projectDir/python/distr":"/dist"
316-
]
317-
tty = true
318-
}
319-
320-
def startManyLinuxWheelsContainer = tasks.register('startManyLinuxWheelsContainer', DockerStartContainer) {
321-
dependsOn createManyLinuxWheelsContainer
322-
targetContainerId("$manylinuxWheelsContainerName")
323-
onError { exception -> handleError(exception) }
324-
}
325-
326-
def stopManyLinuxWheelsContainer = tasks.register('stopManyLinuxWheelsContainer', DockerStopContainer) {
327-
targetContainerId("$manylinuxWheelsContainerName")
328-
onError { exception -> handleError(exception) }
329-
}
330-
331-
def buildLinuxDbApiWheels = tasks.register('buildLinuxDbApiWheels', DockerExecContainer) {
332-
dependsOn startManyLinuxWheelsContainer
333-
targetContainerId("$manylinuxWheelsContainerName")
334-
commands.add(["/pyignite_dbapi/scripts/build_wheels.sh", "$dbapiPythonVersions"] as String[])
335-
onError { exception -> handleError(exception) }
336-
}
337-
338-
def buildDbApiSourceDist = tasks.register('buildDbApiSourceDist', DockerExecContainer) {
339-
dependsOn startManyLinuxWheelsContainer
340-
targetContainerId("$manylinuxWheelsContainerName")
341-
commands.add(["/pyignite_dbapi/scripts/create_sdist.sh", "$dbapiPythonVersions"] as String[])
342-
onError { exception -> handleError(exception) }
343-
}
344-
345-
def buildLinuxDbApi = tasks.register('buildLinuxDbApi', Task) {
346-
dependsOn buildDbApiSourceDist, buildLinuxDbApiWheels
347-
finalizedBy stopManyLinuxWheelsContainer
348-
}
349-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.2.0
1+
3.2.0.dev

modules/platforms/python/setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
# limitations under the License.
1515
import os
1616
import platform
17+
import re
1718
import subprocess
1819
import setuptools
1920
import sys
@@ -52,11 +53,11 @@ def is_a_requirement(req_line):
5253

5354
def cmake_project_version(version):
5455
"""
55-
Strips the pre-release portion of the project version string to satisfy CMake requirements
56+
Strips the extra portion of the project version string to satisfy CMake requirements
5657
"""
57-
dash_index = version.find("-")
58-
if dash_index != -1:
59-
return version[:dash_index]
58+
end_index = re.search(r"\d+\.\d+\.\d+", version).end()
59+
if end_index != -1:
60+
return version[:end_index]
6061
return version
6162

6263
def _get_env_variable(name, default='OFF'):

0 commit comments

Comments
 (0)