Skip to content

Commit

Permalink
Horis ci (#41)
Browse files Browse the repository at this point in the history
Add python and JS building and publishing
  • Loading branch information
IRyabov-HORIS committed Oct 16, 2019
1 parent 09c1e0f commit 1311185
Show file tree
Hide file tree
Showing 13 changed files with 248 additions and 42 deletions.
18 changes: 18 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
language: java

os: linux
dist: bionic
jdk: oraclejdk8

branches:
only:
- horis-ci

before_install:
- sudo apt install -y python3-dev

install: true

env: ORG_GRADLE_PROJECT_python_include_path=/usr/include/python3.6m

script: ./gradlew build
10 changes: 3 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins {
id 'org.jetbrains.gradle.plugin.idea-ext' version '0.5' apply false
// executing node scripts (adds support for Yarn. Also - NPM, Grunt and Gulp)
id 'com.moowork.node' version '1.3.1' apply false
// publishing to bintray
id "com.jfrog.bintray" version "1.8.4" apply false
}


Expand All @@ -12,12 +14,6 @@ allprojects {
// println "--- project ---: $project.name $project.rootDir"
}

task printProps {
doLast {
println System.env.PYTHON_INCLUDE
}
}

def publishedProjects = [
'base-portable',
'base',
Expand Down Expand Up @@ -67,4 +63,4 @@ subprojects {
}
}
}
}
}
30 changes: 29 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,32 @@ ktor_version=1.2.3

rootProject.name=datalore-plot

org.gradle.warning.mode=all
org.gradle.warning.mode=all


# -------------------------------------------------------------------
# Python settings
# -------------------------------------------------------------------

# Python bin path (for building datalore-plot python package)
python_bin_path=/usr/bin

# Set this path for building datalore-plot python package
# python_include_path=

# PyPI repository url
# python_repository_url=

# PyPI credentials for publishing
# pypi_username=
# pypi_password=



# -------------------------------------------------------------------
# Bintray settings
# -------------------------------------------------------------------

# Bintray credentials
bintray_user=
bintray_key=
14 changes: 14 additions & 0 deletions js-package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# datalorePlot JS library.

## Building

* build project with Gradle (`./gradlew build`)

* take library files in `js-package/build/dist` directory


## Publishing in Bintray CDN

* set `bintray_user` and `bintray_api_key` in `gradle.properties` with your Bintray credentials

* run `:js-package:bintrayUpload` gradle task (`./gradlew :js-package:bintrayUpload`)
26 changes: 26 additions & 0 deletions js-package/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
id 'kotlin-multiplatform'
id "com.moowork.node"
// publishing to bintray
id "com.jfrog.bintray"
}
repositories {
mavenCentral()
Expand Down Expand Up @@ -52,6 +54,30 @@ node {
download = true
}

if (hasProperty('bintray_user') && hasProperty('bintray_key')) {
bintray {
user = bintray_user
key = bintray_key

filesSpec {
from 'build/dist'
into '.'
}

publish = true

pkg {
repo = 'datalore-plot'
name = 'datalore-plot-js'
licenses = ['MIT']
vcsUrl = 'https://github.com/JetBrains/datalore-plot'
version {
name = '0.0.dev1'
}
}
}
}

repositories.whenObjectAdded {
if (it instanceof IvyArtifactRepository) {
metadataSources {
Expand Down
8 changes: 4 additions & 4 deletions js-package/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "demoweb",
"name": "datalore-plot-bundling",
"version": "1.0.0",
"description": "",
"description": "file for setup js part bundling environment",
"main": "plot-demo.js",
"directories": {
"lib": "lib"
Expand All @@ -11,8 +11,8 @@
"webpack-build-dev": "webpack --config webpack.dev.config.js",
"webpack-build-prod": "webpack --config webpack.prod.config.js"
},
"author": "",
"license": "ISC",
"author": "JetBrains",
"license": "MIT",
"devDependencies": {
"webpack": "^4.41.0",
"webpack-cli": "^3.3.9"
Expand Down
41 changes: 24 additions & 17 deletions python-extension/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,41 @@ plugins {
}

kotlin {
macosX64() {
binaries {
staticLib {
baseName = "datalore-plot-${project.name}"
if (project.properties['python_include_path'] != null) {
macosX64() {
binaries {
staticLib {
baseName = "datalore-plot-${project.name}"
}
}
}

compilations.main.cinterops {
python {
compilerOpts "-I$System.env.PYTHON_INCLUDE"
compilations.main.cinterops {
python {
compilerOpts "-I${project.properties['python_include_path']}"
}
}
}
}

linuxX64() {
binaries {
sharedLib {
baseName = "datalore-plot-${project.name}"
linuxX64() {
binaries {
sharedLib {
baseName = "datalore-plot-${project.name}"
}
}
}

compilations.main.cinterops {
python {
compilerOpts "-I$System.env.PYTHON_INCLUDE"
compilations.main.cinterops {
python {
compilerOpts "-I${project.properties['python_include_path']}"
}
}
}
} else {
println("------------------------------------------------------------------------------------------------")
println("Python package build unavailable. Please set \"python_include_path\" property in gradle.properties file.")
println("------------------------------------------------------------------------------------------------")
}


sourceSets {
commonMain {
dependencies {
Expand Down
14 changes: 4 additions & 10 deletions python-package/HOWTO_JUPYTER.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
- Jupyter must be installed in Python environment (IPython.display is required)

- set PYTHON_INCLUDE environment variable with path to python include path
- set `python_include_path` and `python_bin_path` properties in gradle.properties file.

- build project (gradle)

In terminal:
- create/activate Python environment (I use conda)
- cd to datalore-plot/python-package
- copy all JS to package data: python setup.py update_js
- install python package (egg): python setup.py install
or
- build and install wheel:
python setup.py update_js bdist_wheel
pip install --no-index --find-links=dist/ datalore-plot
- uninstall datalore-plot with `pip uninstall datalore-plot` if needed

- run localInstallPythonPackage gradle task from python-package module (./gradlew :python-package:localInstallPythonPackage)


Start local web-server to serve our js scripts (from /datalore-plot/plot-demo/build/demoWeb/lib):
Expand Down
9 changes: 9 additions & 0 deletions python-package/HOWTO_PYPI_PUBLISH.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
- twine must be installed (pip install twine)

- set `pypi_username` and `pypi_password` properties in gradle.properties file.

- if needed set `python_repository_url` property in gradle.properties file.

- build project (gradle)

- run publishPythonPackage gradle task from python-package module (./gradlew :python-package:publishPythonPackage)
33 changes: 33 additions & 0 deletions python-package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# datalore-plot Python package

## Building

* install `python-dev` package (if you use Anaconda it's already installed)

* install python `setuptools` (run `pip install setuptools`)

* set `python_include_path` in `gradle.properties`.
For getting this path you can run `python -c "from sysconfig import get_paths as gp; print(gp()['include'])"`.

* check if `python_bin_path` in `gradle.properties` contents true path to your python bin path (default is `/usr/bin`).
For getting this path you can run `python -c "from sysconfig import get_paths as gp; print(gp()['scripts'])"`.

* build project with Gradle (run `./gradlew build`)


## Local installing

* build package

* run `:python-package:localInstallPythonPackage` gradle task (`./gradlew :python-package:localInstallPythonPackage`)


## Publishing

* build package

* set `pypi_username` and `pypi_password` in `gradle.properties` with your PyPI credentials

* set `python_repository_url` in `gradle.properties` if you need publish to not standard PyPI repository (i.e. `https://test.pypi.org/legacy/` for testing publishing).

* run `:python-package:publishPythonPackage`
83 changes: 83 additions & 0 deletions python-package/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
plugins {
id 'kotlin-multiplatform'
}

def PYTHON_BIN_PATH_PROPERTY = 'python_bin_path'
def PYTHON_REPOSITORY_URL_PROPERTY = 'python_repository_url'

if (hasProperty('python_include_path')) {
if (hasProperty(PYTHON_BIN_PATH_PROPERTY)) {


task updateJs(type:Exec) {
workingDir project.projectDir

commandLine "${project.properties[PYTHON_BIN_PATH_PROPERTY]}/python3", 'setup.py', 'update_js'
}

task buildPythonPackage(type:Exec) {
workingDir project.projectDir

commandLine "${project.properties[PYTHON_BIN_PATH_PROPERTY]}/python3",
'setup.py',
'bdist_wheel',
"--dist-dir=${project.buildDir}/dist"
}

task localInstallPythonPackage(type:Exec) {
workingDir "${project.buildDir}/dist"

commandLine "${project.properties[PYTHON_BIN_PATH_PROPERTY]}/pip",
'install',
'--no-index',
'--find-links=./',
'datalore-plot'
}

task publishPythonPackage(type:Exec) {
workingDir "${project.buildDir}/dist"

if (project.properties[PYTHON_REPOSITORY_URL_PROPERTY] != null) {
commandLine "${project.properties[PYTHON_BIN_PATH_PROPERTY]}/twine",
"upload",
"--repository-url",
project.properties[PYTHON_REPOSITORY_URL_PROPERTY],
"-u",
project.properties["pypi_username"],
"-p",
project.properties["pypi_password"],
"./*"
} else {
commandLine "${project.properties[PYTHON_BIN_PATH_PROPERTY]}/twine",
"upload",
"-u",
project.properties["pypi_username"],
"-p",
project.properties["pypi_password"],
"./*"
}
}

updateJs.dependsOn(':js-package:build')

buildPythonPackage.dependsOn(':python-extension:build')

buildPythonPackage.dependsOn(updateJs)

build.dependsOn(buildPythonPackage)

localInstallPythonPackage.dependsOn(buildPythonPackage)
//publishPythonPackage.dependsOn(buildPythonPackage)


} else {
println("------------------------------------------------------------------------------------------------")
println("Python package build unavailable. Please set \"python_bin\" property in gradle.properties file.")
println("------------------------------------------------------------------------------------------------")
}

} else {
println("------------------------------------------------------------------------------------------------")
println("Python package build unavailable. Please set \"python_include_path\" property in gradle.properties file.")
println("------------------------------------------------------------------------------------------------")
}
3 changes: 0 additions & 3 deletions python-package/setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
[metadata]
# description-file = README.md
license_file = ../LICENSE

[bdist_wheel]
universal = 1
1 change: 1 addition & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ include 'base-portable',
'vis-demo-svg-mapper',
'plot-demo',
'python-extension',
'python-package',
'js-package',
'jvm-jfx-package',
'test-common'
Expand Down

0 comments on commit 1311185

Please sign in to comment.