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

Refactor build scripts #962

Merged
merged 14 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Refactoring
  • Loading branch information
VDovidaytis-HORIS committed Dec 12, 2023
commit d9dea59544675486e2b04d4298b04affd6c65cc3
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ __pycache__/

# Local properties file
local.properties
# Old properties file
build_settings.yml

# Autogenerated folder with yarn.lock file
kotlin-js-store
Expand Down
41 changes: 18 additions & 23 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ allprojects {
def readPropertiesFromParameters() {
def properties = new Properties()
if (project.hasProperty("enable_python_package")) {
properties."enable_python_package" = project.getProperty("enable_python_package")
properties."enable_python_package" = project.getProperty("enable_python_package").toBoolean()
}
if (properties.enable_python_package) {
properties."python.bin_path" = project.getProperty("python.bin_path")
Expand All @@ -79,18 +79,19 @@ def readPropertiesFromFile() {
throw new FileNotFoundException("${localPropsFileName} file not found!\n" +
"Check ${localPropsFileName}_template file for the template.")
}
properties."enable_python_package" = properties."enable_python_package".toBoolean()

if (!os.windows) {
assert properties."architecture" != null // Windows only 64bit version can be built, so the arch parameter is not needed and may not be set.
}

if (properties."enable_python_package") {

def pythonBinPath = properties."python.bin_path" as String
def pythonIncludePath = properties."python.include_path" as String
def pythonBinPath = properties."python.bin_path"
def pythonIncludePath = properties."python.include_path"

assert (pythonBinPath != null) && (pythonBinPath != "")
assert (pythonIncludePath != null) && (pythonIncludePath != "")
assert pythonBinPath != null
assert pythonIncludePath != null

if (!os.windows) {
def getArchOutput = new ByteArrayOutputStream()
Expand All @@ -102,9 +103,7 @@ def readPropertiesFromFile() {
}
def currentPythonArch = getArchOutput.toString().trim()

println(properties."enable_python_package" as Boolean)

if (currentPythonArch != properties."architecture" as String) {
if (currentPythonArch != properties."architecture") {
throw new IllegalArgumentException("Project and Python architectures don't match!\n" +
" - Value, from your '${localPropsFileName}' file: ${properties.architecture}\n" +
" - Your Python architecture: ${currentPythonArch}\n" +
Expand All @@ -117,7 +116,6 @@ def readPropertiesFromFile() {

// For build_release.py settings will be read from commandline parameters.
// In other cases, settings will be read from local.properties.
//Properties localProps = new Properties()
if (project.hasProperty("build_release")) {
ext.localProps = readPropertiesFromParameters()
} else {
Expand All @@ -132,17 +130,14 @@ project.ext.localMavenRepository = "$rootDir/.maven-publish-dev-repo"
// define Sonatype nexus repository manager settings:
def sonatypeUsername = localProps."sonatype.username" as String
def sonatypePassword = localProps."sonatype.password" as String

if (sonatypeUsername != null && sonatypePassword != null) {
nexusPublishing {
repositories {
maven {
username = sonatypeUsername
password = sonatypePassword
stagingProfileId = "11c25ff9a87b89"
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
}
nexusPublishing {
repositories {
maven {
username = sonatypeUsername
password = sonatypePassword
stagingProfileId = "11c25ff9a87b89"
nexusUrl.set(uri("https://oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
Expand Down Expand Up @@ -180,9 +175,9 @@ subprojects {
def os = platform.getCurrentOperatingSystem()

kotlin {
if (os.macOsX & localProps."architecture" as String == "x86_64") {
if (os.macOsX & localProps."architecture" == "x86_64") {
macosX64()
} else if (os.macOsX & localProps."architecture" as String == "arm64") {
} else if (os.macOsX & localProps."architecture" == "arm64") {
if (project.hasProperty("build_release")) {
macosX64()
macosArm64()
Expand All @@ -193,7 +188,7 @@ subprojects {
if (project.hasProperty("build_release")) {
linuxX64()
linuxArm64()
} else if (project.localProps."architecture" as String == "x86_64") {
} else if (project.localProps."architecture" == "x86_64") {
linuxX64()
}
} else if (os.windows) {
Expand Down
4 changes: 2 additions & 2 deletions local.properties.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
architecture=x86_64

# Enable tasks responsible for building and publishing of lets-plot python package.
# Comment the next line to disable python package build.
enable_python_package=yes
# Set 'true' or 'false' here:
enable_python_package=false

# -------------------------------------------------------------------
# Python settings
Expand Down
2 changes: 1 addition & 1 deletion python-extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ kotlin {

def os = platform.getCurrentOperatingSystem()
def target
if (os.macOsX & localProps.architecture as String == "x86_64") {
if (os.macOsX & localProps.architecture == "x86_64") {
target = macosX64("native")
} else if (os.macOsX & localProps."architecture" == "arm64") {
target = macosArm64("native")
Expand Down
8 changes: 4 additions & 4 deletions python-package-build/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ clean {
if (localProps.enable_python_package) {
def os = platform.getCurrentOperatingSystem()

def pypiTestUsername = localProps."pypi.test.username" as String
def pypiTestPassword = localProps."pypi.test.password" as String
def pypiTestUsername = localProps."pypi.test.username"
def pypiTestPassword = localProps."pypi.test.password"

def pypiProdUsername = localProps."pypi.prod.username" as String
def pypiProdPassword = localProps."pypi.prod.password" as String
def pypiProdUsername = localProps."pypi.prod.username"
def pypiProdPassword = localProps."pypi.prod.password"

def pythonBinPath = localProps."python.bin_path"
def pythonTwineCommand = "${pythonBinPath}/twine"
Expand Down
2 changes: 1 addition & 1 deletion python-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Edit `local.properties` in the project root:

* `architecture` - set to `arm64` or `x86_64` depending on your Python architecture.
* `enable_python_package=yes` - uncomment this line for working with Python package.
* `enable_python_package` - set to `true` for working with Python package.
* `python.include_path` - path to Python include directory where Python.h located.
To get this path you can run `python -c "from sysconfig import get_paths as gp; print(gp()['include'])"`.
* `python.bin_path` - path to your Python bin directory.
Expand Down