Skip to content

Commit

Permalink
NXDRIVE-1280: Add GNU/Linux support 🍾!
Browse files Browse the repository at this point in the history
For now, we are stuck with Python 3.6.8 because of an incomptibility with SSL:

    Could not build the ssl module!
     Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl
     with X509_VERIFY_PARAM_set1_host().
     LibreSSL 2.6.4 and earlier do not provide the necessary APIs,
     libressl/portable#381

* Compile Python with --enabled-shared on GNU/Linux too;
* Display the SKIP envar only if set.
  • Loading branch information
Mickaël committed Jun 18, 2019
1 parent f9e12f3 commit 77b9b50
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 12 deletions.
6 changes: 4 additions & 2 deletions nxdrive/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from contextlib import suppress
from typing import Any, Set

from nxdrive.constants import APP_NAME
from nxdrive.constants import APP_NAME, LINUX
from nxdrive.fatal_error import check_executable_path, show_critical_error
from nxdrive.options import Options

Expand Down Expand Up @@ -71,7 +71,9 @@ def main() -> int:

try:
# XXX_PYTHON
if sys.version_info < (3, 7):
if LINUX and sys.version_info[:2] < (3, 6):
raise RuntimeError(f"{APP_NAME} requires Python 3.6+")
elif not LINUX and sys.version_info[:2] < (3, 7):
raise RuntimeError(f"{APP_NAME} requires Python 3.7+")

if not check_executable_path():
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
appdirs==1.4.3
dataclasses==0.6; python_version < '3.7'
distro==1.4.0; sys_platform == 'linux'
https://github.com/GoodRx/universal-analytics-python/archive/77ce628c56de1ba51a9bf0774794fd687f785803.zip
https://github.com/gorakhargosh/watchdog/archive/8b94506c3156a3b66faef7aac9a139f603772506.zip
Expand Down
65 changes: 65 additions & 0 deletions tools/jenkins/package_linux.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#!groovy
// Script to build Nuxeo Drive package on GNU/Linux.
// An AppImage will be built on the docker image manylinux2010.

// Pipeline properties
properties([
disableConcurrentBuilds(),
pipelineTriggers([[$class: 'GitHubPushTrigger']]),
[$class: 'BuildDiscarderProperty', strategy:
[$class: 'LogRotator', daysToKeepStr: '60', numToKeepStr: '60', artifactNumToKeepStr: '1']],
[$class: 'SchedulerPreference', preferEvenload: true],
[$class: 'RebuildSettings', autoRebuild: false, rebuildDisabled: false],
[$class: 'ParametersDefinitionProperty', parameterDefinitions: [
[$class: 'StringParameterDefinition',
name: 'BRANCH_NAME',
defaultValue: 'master']
]]
])

pipeline {
agent {
docker {
label 'PUB_DEPLOY'
image 'python:3.7.3-slim-stretch'
args '-u root --privileged'
}
}

stages {
stage('Install') {
steps {
// https://github.com/pyenv/pyenv/wiki/Common-build-problems#prerequisites
echo 'Installing pyenv requirements'
sh """
apt update
apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils libffi-dev liblzma-dev python-openssl git
"""
}
}

stage('Checkout') {
steps {
checkout scm
}
}

stage('Build') {
steps {
sh """
tools/linux/deploy_jenkins_slave.sh --install-release || (cat /tmp/python-build.*.log && exit 1)
tools/linux/deploy_jenkins_slave.sh --build
"""
}
}

stage('Archive') {
steps {
archiveArtifacts artifacts: 'dist/*.appimage', fingerprint: true
archiveArtifacts artifacts: 'dist/*.zip', fingerprint: true
}
}
}
}
17 changes: 11 additions & 6 deletions tools/posix/deploy_jenkins_slave.sh
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ check_vars() {
echo "Please do not call this script directly. Use the good one from 'tools/OS/deploy_jenkins_slave.sh'."
exit 1
fi
if [ "${SKIP:=unset}" = "unset" ]; then
export SKIP=""
fi
if [ "${WORKSPACE_DRIVE:=unset}" = "unset" ]; then
if [ -d "${WORKSPACE}/sources" ]; then
export WORKSPACE_DRIVE="${WORKSPACE}/sources"
Expand All @@ -116,7 +113,6 @@ check_vars() {
echo " WORKSPACE = ${WORKSPACE}"
echo " WORKSPACE_DRIVE = ${WORKSPACE_DRIVE}"
echo " STORAGE_DIR = ${STORAGE_DIR}"
echo " SKIP = ${SKIP}"

cd "${WORKSPACE_DRIVE}"

Expand All @@ -126,6 +122,12 @@ check_vars() {
echo " SPECIFIC_TEST = ${SPECIFIC_TEST}"
export SPECIFIC_TEST="tests/${SPECIFIC_TEST}"
fi

if [ "${SKIP:=unset}" = "unset" ]; then
export SKIP=""
else
echo " SKIP = ${SKIP}"
fi
}

install_deps() {
Expand Down Expand Up @@ -173,8 +175,11 @@ install_pyenv() {
install_python() {
local version="$1"

# To fix Mac error when building the package "libpython27.dylib does not exist"
[ "${OSI}" = "osx" ] && export PYTHON_CONFIGURE_OPTS="--enable-shared"
# To fix this error when building the package "libpythonXY.dylib does not exist"
# Some of 3rd party tool like PyInstaller might require CPython installation
# built with --enable-shared
# Source: https://github.com/pyenv/pyenv/wiki#how-to-build-cpython-with---enable-shared
export PYTHON_CONFIGURE_OPTS="--enable-shared"

pyenv install --skip-existing "${version}"

Expand Down
10 changes: 6 additions & 4 deletions tools/windows/deploy_jenkins_slave.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,6 @@ function check_vars {
if (-Not ($Env:ISCC_PATH)) {
$Env:ISCC_PATH = "C:\Program Files (x86)\Inno Setup 5"
}
if (-Not ($Env:SKIP)) {
$Env:SKIP = ""
}
if (-Not ($Env:PYTHON_DIR)) {
$ver_major, $ver_minor = $Env:PYTHON_DRIVE_VERSION.split('.')[0,1]
$Env:PYTHON_DIR = "C:\Python$ver_major$ver_minor-32"
Expand All @@ -206,7 +203,6 @@ function check_vars {
Write-Output " STORAGE_DIR = $Env:STORAGE_DIR"
Write-Output " PYTHON_DIR = $Env:PYTHON_DIR"
Write-Output " ISCC_PATH = $Env:ISCC_PATH"
Write-Output " SKIP = $Env:SKIP"

Set-Location "$Env:WORKSPACE_DRIVE"

Expand All @@ -216,6 +212,12 @@ function check_vars {
Write-Output " SPECIFIC_TEST = $Env:SPECIFIC_TEST"
$Env:SPECIFIC_TEST = "tests\$Env:SPECIFIC_TEST"
}

if (-Not ($Env:SKIP)) {
$Env:SKIP = ""
} else {
Write-Output " SKIP = $Env:SKIP"
}
}

function download($url, $output) {
Expand Down

0 comments on commit 77b9b50

Please sign in to comment.