Skip to content
This repository has been archived by the owner on Apr 30, 2021. It is now read-only.

Update Travis and Update to Python 3 #38

Merged
merged 1 commit into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
65 changes: 44 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,62 @@
language: python
dist: xenial
env:
global:
- BINARY_VERSION=$(git describe --tags --dirty --always)

python:
- "2.7"

addons:
artifacts:
paths:
- ./dist/mac/ODK-XLSForm-Offline-macOS.zip
- ./dist/win
target_paths:
- ${TRAVIS_BUILD_NUMBER}
debug: true

matrix:
jobs:
include:
- os: osx
- stage: Build binaries
os: osx
language: sh
python: "2.7"
python:
- "3.6"
before_install:
- brew update
- brew install unix2dos
- pip install pyinstaller wxpython pyxform
- pip3 install pyinstaller wxpython pyxform
script:
- ./make-mac.sh
- ./make-dist.sh
workspaces:
create:
name: mac-binaries
paths:
- ./dist/mac/ODK-XLSForm-Offline.app
- os: windows
language: sh
python: "2.x"
python:
- "3.6"
before_install:
- choco install python2 --params "/InstallDir:C:\\Python"
- choco install python3 --params "/InstallDir:C:\\Python"
- export PATH="/c/Python:/c/Python/Scripts:$PATH"
- pip install pyinstaller
- pip install pyxform
- pip3 install pyinstaller
- pip3 install pyxform
script:
- ./make-win.bat
workspaces:
create:
name: windows-binaries
paths:
- ./dist/win/ODK-XLSForm-Offline.exe
- stage: Deploy
os: osx
language: sh
workspaces:
use:
- mac-binaries
- windows-binaries
before_install:
- brew update
- brew install unix2dos
script:
- ./make-dist.sh
addons:
artifacts:
paths:
- ./dist/mac/ODK-XLSForm-Offline-macOS-${BINARY_VERSION}.zip
- ./dist/win/ODK-XLSForm-Offline-Windows-${BINARY_VERSION}.zip
target_paths:
- ${TRAVIS_BUILD_NUMBER}
debug: true

cache: pip
29 changes: 26 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
![Platform](https://img.shields.io/badge/platform-Python-blue.svg)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![Slack status](http://slack.opendatakit.org/badge.svg)](http://slack.opendatakit.org)
![Build status](https://travis-ci.com/opendatakit/xlsform-offline.svg?branch=master)
[![Build status](https://travis-ci.com/opendatakit/xlsform-offline.svg?branch=travis)](https://travis-ci.com/opendatakit/xlsform-offline)

ODK XLSForm Offline is a Windows and macOS application for converting an XLSForm into an XForm that is compliant with the [ODK XForms spec](http://opendatakit.github.io/xforms-spec). Once converted, the application also validates that the XForm will run perfectly with all ODK tools.

Expand All @@ -16,9 +16,9 @@ ODK XLSForm Offline is part of Open Data Kit (ODK), a free and open-source set o

## Prerequisites

1. Install [Python 2.7](https://www.python.org/downloads/)
1. Install [Python 3.6](https://www.python.org/downloads/)
* Windows: Use the 32 bit version.
1. Install Python packages: ``pip install pyinstaller wxpython pyxform``
1. Install Python packages: ``pip3 install pyinstaller wxpython pyxform``
* macOS: Use the default Python. virtualenvs will not work.
1. Install packaging utilities
* macOS: ``brew install unix2dos``
Expand All @@ -36,3 +36,26 @@ The easiest way to package is to use a macOS machine running a Windows 10 virtua
1. In the Windows VM, run `make-win.bat` to build the Windows binary.
1. Copy the resulting binaries into the `dist/mac` and `dist/win` folders on the host machine.
1. On the host machine, run `./make-dist.sh` to zip up the Mac and Windows binaries.

# Build Location

If you're building on [travis](https://travis-ci.com/), the MacOS zip file will be output to

http://travis-opendatakit-org.s3-website-us-west-2.amazonaws.com/{TRAVIS_BUILD_NUMBER}/dist/mac/ODK-XLSForm-Offline-macOS-{GIT_HASH}.zip

And the windows to

http://travis-opendatakit-org.s3-website-us-west-2.amazonaws.com/{TRAVIS_BUILD_NUMBER}/dist/win/ODK-XLSForm-Offline-Windows-{GIT_HASH}.zip

Where {TRAVIS_BUILD_NUMBER} should be replaced with the actual build number, and {GIT_HASH} should be replaced with the output of the command
```shell
git describe --tags --dirty --always
```
For example, if I were on [build #119](https://travis-ci.com/github/shouryaj/xlsform-offline/builds/159146104), then the output of the `git hash` command would be:
```
v1.7.0-15-g2cf312f
```
and to download the mac binary, I would go to:
http://travis-opendatakit-org.s3-website-us-west-2.amazonaws.com/119/dist/mac/ODK-XLSForm-Offline-macOS-v1.7.0-15-g2cf312f.zip
for the windows binary, I would go to:
http://travis-opendatakit-org.s3-website-us-west-2.amazonaws.com/119/dist/win/ODK-XLSForm-Offline-Windows-v1.7.0-15-g2cf312f.zip
39 changes: 35 additions & 4 deletions make-dist.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,46 @@

#!/bin/bash
set -e

VERSION=$(git describe --tags --dirty --always)

README='pkg/Read me.txt'

MAC_BINARY='dist/mac/ODK XLSForm Offline.app'
MAC_README='dist/mac/Read me.txt'
CWD=$(pwd)

MAC_BINARY="dist/mac/ODK-XLSForm-Offline.app"
MAC_README="dist/mac/Read me.txt"

# Travis workspaces is weird with windows
WIN_DIR="C:${CWD}/dist/win"
WIN_BINARY="${WIN_DIR}/ODK-XLSForm-Offline.exe"
WIN_README="${WIN_DIR}/Read me.txt"

if [[ -e "$MAC_BINARY" ]]; then
echo 'Mac version exists';
fold -w 80 -s "$README" > "$MAC_README";
cd dist/mac;
zip -r9 "ODK-XLSForm-Offline-macOS.zip" . -x "*.DS_Store"
cd ../..;
mv "ODK-XLSForm-Offline.app" "ODK XLSForm Offline.app"
# Add the binary version in the zip name
zip -r9 "ODK-XLSForm-Offline-macOS-${VERSION}.zip" . -x "*.DS_Store"
echo "ODK-XLSForm-Offline-macOS-${VERSION}.zip"
cd $CWD;
fi

if [[ -e "$WIN_BINARY" ]]; then
if ! [[ -d dist ]]; then
mkdir dist
fi
mkdir dist/win
echo 'Windows version exists';
fold -w 80 -s "$README" > "$WIN_README";
mac2unix "$WIN_README" && unix2dos "$WIN_README";
cd $WIN_DIR;
ls
mv "ODK-XLSForm-Offline.exe" "ODK XLSForm Offline.exe"
zip -r9 "ODK-XLSForm-Offline-Windows.zip" . -x "*.DS_Store"
# Add the binary version in the zip name
mv "ODK-XLSForm-Offline-Windows.zip" "$CWD/dist/win/ODK-XLSForm-Offline-Windows-${VERSION}.zip"
echo "$CWD/dist/win/ODK-XLSForm-Offline-Windows-${VERSION}.zip"
cd $CWD;
fi
3 changes: 2 additions & 1 deletion make-win.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pip install PyInstaller wxpython pyxform
rd /s /q build\xlsform-offline-win
rd /s /q dist\win
del /s /q *.pyc
pyinstaller pkg\xlsform-offline-win.spec --distpath dist\win --onefile --windowed --noconfirm --clean
python -m PyInstaller pkg\xlsform-offline-win.spec --distpath dist\win --onefile --windowed --noconfirm --clean
25 changes: 16 additions & 9 deletions pkg/xlsform-offline-mac.spec
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,30 @@ for path in site.getsitepackages():
iana_path = test_iana_path

a = Analysis(['../src/main.py'])
pyz = PYZ(a.pure)
pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(pyz,
a.scripts,
[],
exclude_binaries=True,
name='ODK XLSForm Offline',
console=False
)
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
[('res/about.html', os.getcwd() + '/src/res/about.html', 'DATA')],
[('pyxform/validators/odk_validate/bin/ODK_Validate.jar', validate_path, 'DATA')],
[('pyxform/iana_subtags.txt', iana_path, 'DATA')],
name='ODK XLSForm Offline',
strip=True
)
strip=False,
upx=True,
upx_exclude=[],
name='ODK XLSForm Offline')
app = BUNDLE(coll,
name='ODK XLSForm Offline.app',
name='ODK-XLSForm-Offline.app',
icon='icon.icns',
info_plist={ 'NSHighResolutionCapable': 'True' }
)
info_plist={ 'NSHighResolutionCapable': 'True' },
bundle_identifier=None)
12 changes: 8 additions & 4 deletions pkg/xlsform-offline-win.spec
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
# -*- mode: python -*-

import site;
for path in site.getsitepackages():
path = path.replace("lib", "Lib")
test_validate_path = os.path.join(path, 'pyxform/validators/odk_validate/bin/ODK_Validate.jar')
if os.path.exists(test_validate_path):
validate_path = test_validate_path
test_iana_path = os.path.join(path, 'pyxform/iana_subtags.txt')
if os.path.exists(test_iana_path):
iana_path = test_iana_path

a = Analysis(['../src/main.py'])
pyz = PYZ(a.pure)


a = Analysis(['..\\src\\main.py'])
pyz = PYZ(a.pure, a.zipped_data)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[('res\\about.html', os.getcwd() + '\\src\\res\\about.html', 'DATA')],
[('pyxform\\validators\\odk_validate\\bin\\ODK_Validate.jar', validate_path, 'DATA')],
[('pyxform\\iana_subtags.txt', iana_path, 'DATA')],
name='ODK XLSForm Offline.exe',
name='ODK-XLSForm-Offline.exe',
icon='icon.ico',
upx=True,
console=False
Expand Down
4 changes: 2 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ def on_result(self, event):
self.status_text_ctrl.AppendText(event.data)

def on_progress(self, event):
if self.result_thread is not None and self.result_thread.isAlive():
if self.result_thread is not None and self.result_thread.is_alive():
self.status_gauge.Pulse()

@staticmethod
Expand All @@ -325,7 +325,7 @@ def is_java_installed():
startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW

java_version = None
java_regex = re.compile('(java|openjdk) version')
java_regex = re.compile(b'(java|openjdk) version')
try:
java_version = subprocess.Popen(['java', '-version'], stderr=subprocess.PIPE, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=False, startupinfo=startupinfo).communicate()[
Expand Down