Skip to content

Commit

Permalink
Conda recipe with deployment on tags via Travis (#235)
Browse files Browse the repository at this point in the history
* Adding conda recipe and CD to travis

* Removed master-only from travis yaml

* Removed un-used USER variable

* Fixed summary in meta.yaml

* Added mantidTS channel, libGL install, and updates to upload

* Fix conda upload function call

* added mantid channel to travis yaml

* Cleanup in conda recipe

* Add the build section to conda recipe + refactor run

* Fixing conda build statements

* Fix conda upload function call

* Rerun travis build with new api token setup for conda deploy

* Adding conda recipe and CD to travis

* Removed master-only from travis yaml

* Removed un-used USER variable

* Fixed summary in meta.yaml

* Added mantidTS channel, libGL install, and updates to upload

* Fix conda upload function call

* added mantid channel to travis yaml

* Cleanup in conda recipe

* Add the build section to conda recipe + refactor run

* Fixing conda build statements

* Fix conda upload function call

* Moved main script and updated setup.py for console_scripts

* Updated addiedevel.sh with change to main script

* Added flake8 to Pipfile

* Flake8 fixes to addie/main.py

* Added package pyX string, setuptools to build, and test for import of addie to recipe

* Refactor of conda setup + deploy in travis CI

* Adding python to recipe to debug failure

* Added pytest to setup.py

* Added conda install lines to travis yaml

* Pinned version of mantid workbench in recipe

* Added pinned workbench version to travis yaml

* Remove pinned versions and dependencies included in mantid

* Refactor setup.py for requirements files

* Updated recipe and requirement files

* Removed pinned workbench after changing upstream labels

* Remove setup requirements to fix conda recipe issues

* Fix flake8 for setup.py

* Switch travis conda deploy to production
  • Loading branch information
marshallmcdonnell authored and peterfpeterson committed May 15, 2019
1 parent 8c7e61a commit 5fe6b7d
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 66 deletions.
58 changes: 37 additions & 21 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
language: python
dist: trusty

branches:
only:
- master

services:
- xvfb

Expand All @@ -21,34 +17,44 @@ matrix:

before_install:
- |
# Install conda
"/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi
if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=Linux-x86_64; else OS=MacOSX-x86_64; fi
wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda${CONDA:0:1}-latest-$OS.sh
bash miniconda.sh -b -p $HOME/miniconda
export PATH="$HOME/miniconda/bin:$PATH"
conda config --set always_yes yes --set changeps1 no
conda config --add channels conda-forge
conda update -q conda
conda create -n test-environment -q python=$CONDA
conda update -n test-environment -q conda
conda install -n test-environment -q conda-build
conda install -n test-environment -c mantid mantid-workbench nexus poco
conda install -n test-environment flake8
install:
- |
source activate test-environment
conda list
# Setup channels
conda config --set always_yes yes --set changeps1 no --set anaconda_upload no
conda config --add channels conda-forge --add channels marshallmcdonnell --add channels mantid --add channels mantid/label/nightly
conda update -q conda
conda info -a
# Activate environment
conda create -q -n addie_env python=$CONDA flake8 conda-build conda-verify anaconda-client
source activate addie_env
# Build recipe and install addie
conda build conda.recipe
export PKG_FILE=$(conda build conda.recipe --output)
conda install ${PKG_FILE}
before_script:
# create a properties file that turns off network access
- mkdir ~/.mantid
- echo "CheckMantidVersion.OnStartup=0" > ~/.mantid/Mantid.user.properties
- echo "UpdateInstrumentDefinitions.OnStartup=0" >> ~/.mantid/Mantid.user.properties
- echo "usagereports.enabled=0" >> ~/.mantid/Mantid.user.properties
- export DISPLAY=:99.0
- sleep 3
- |
# create a properties file that turns off network access
mkdir ~/.mantid
echo "CheckMantidVersion.OnStartup=0" > ~/.mantid/Mantid.user.properties
echo "UpdateInstrumentDefinitions.OnStartup=0" >> ~/.mantid/Mantid.user.properties
echo "usagereports.enabled=0" >> ~/.mantid/Mantid.user.properties
export DISPLAY=:99.0
sleep 3
- |
conda install -c mantid/label/nightly mantid-workbench
conda install -c marshallmcdonnell mantid-total-scattering-python-wrapper
script:
# lint the code and generate an error if a warning is introduced
Expand All @@ -70,3 +76,13 @@ script:
- python setup.py install
- which addie
- xvfb-run --server-args="-screen 0 640x480x24" --auto-servernum addie --version

deploy:
# Deploy conda package to Anaconda.org https://anaconda.org/addie-diffraction/addie
- provider: script
script: cd conda.recipe && chmod +x anaconda_upload.sh && ./anaconda_upload.sh ${PKG_FILE}
skip_cleanup: true
skip_existing: true
on:
branch: master
tags: true
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ psutil = "*"
pyoncat = {file = "https://oncat.ornl.gov/packages/pyoncat-1.3.2-py2.py3-none-any.whl"}
six = "==1.11.0"
QtPy = "==1.6.0"
flake8 = "*"
56 changes: 28 additions & 28 deletions scripts/addie → addie/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env python
from __future__ import (absolute_import, division, print_function)

import copy
Expand Down Expand Up @@ -43,8 +42,7 @@

# PyONcat
try:
from addie.processing.mantid.master_table.import_from_database.import_from_database_handler import \
ImportFromDatabaseHandler
from addie.processing.mantid.master_table.import_from_database.import_from_database_handler import ImportFromDatabaseHandler # noqa
ONCAT_ENABLED = True
except ImportError:
print('pyoncat module not found. Functionality disabled')
Expand All @@ -55,7 +53,8 @@
import addie.addiedriver as driver
import addie.calculate_gr.edit_sq_dialog

from addie.icons import icons_rc # necessary to see all the icons
# necessary to see all the icons
from addie.icons import icons_rc # noqa

from addie.calculate_gr.pdf_lines_manager import PDFPlotManager

Expand Down Expand Up @@ -425,7 +424,7 @@ def help_button_clicked_autonom(self):

def main_tab_widget_changed(self, tab_selected):
if tab_selected == 0:
o_gui = Step1GuiHandler(main_window=self)
Step1GuiHandler(main_window=self)
autonom_event_handler.check_step1_gui(self)
if tab_selected == 1:
_o_gui = Step2GuiHandler(main_window=self)
Expand Down Expand Up @@ -471,7 +470,7 @@ def update_logbook(self, text):
if self.job_monitor_interface is None:
self.logbook_thread.stop()
else:
_logbook_handler = LogbookHandler(parent=self)
LogbookHandler(parent=self)

# autoNOM

Expand Down Expand Up @@ -921,32 +920,33 @@ def apply_clicked(self):
self.close()


def main(mode):
def main(config=None):

if config is None:
import argparse # noqa
parser = argparse.ArgumentParser(description='ADvanced DIffraction Environment')
parser.add_argument('--version', action='version', version='%(prog)s version {}'.format(__version__))
parser.add_argument('--mode', type=str, default='mantid',
help='Set processing mode (default=%(default)s)', choices=['mantid', 'idl'])

try: # set up bash completion as a soft dependency
import argcomplete # noqa
argcomplete.autocomplete(parser)
except ImportError:
pass # silently skip this

# parse the command line options
config = parser.parse_args()

app = QApplication(sys.argv)
app.setOrganizationName("Qtrac Ltd.")
app.setOrganizationDomain("qtrac.eu")
app.setApplicationName("Image Changer")
app.setOrganizationName("ORNL / SNS")
app.setOrganizationDomain("https://neutrons.ornl.gov/")
app.setApplicationName("ADDIE: ADvanced DIffraction Environment")
app.setWindowIcon(QIcon(":/icon.png"))
form = MainWindow(processing_mode=mode)
form = MainWindow(processing_mode=config.mode)
form.show()
app.exec_()


if __name__ == '__main__':
import argparse # noqa
parser = argparse.ArgumentParser(description='ADvanced DIffraction Environment')
parser.add_argument('--version', action='version', version='%(prog)s version {}'.format(__version__))
parser.add_argument('--mode', type=str, default='mantid',
help='Set processing mode (default=%(default)s)', choices=['mantid', 'idl'])

try: # set up bash completion as a soft dependency
import argcomplete # noqa
argcomplete.autocomplete(parser)
except ImportError:
pass # silently skip this

# parse the command line options
options = parser.parse_args()

# start the main program
main(options.mode)
main()
2 changes: 1 addition & 1 deletion addiedevel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ echo using $RAW_PYTHON version $PYTHON_VERSION
$CMD setup.py build

# launch addie
QT_API=$LOCAL_QT_API PYTHONPATH=build/lib:$PYTHONPATH $CMD --classic build/scripts-${PYTHON_VERSION}/addie
QT_API=$LOCAL_QT_API PYTHONPATH=build/lib:$PYTHONPATH $CMD --classic build/lib/addie/main.py
16 changes: 16 additions & 0 deletions conda.recipe/anaconda_upload.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/usr/bin/env bash

# Input
if [[ $# -ne 1 ]]
then
echo "Usage: anaconda_upload.sh <full package path>"
exit 1
fi

PKG_PATH=$1
PKG_FILE=$(basename ${PKG_PATH})

echo "Uploading ${PKG_PATH} artifact..."
anaconda -v -t ${CONDA_UPLOAD_TOKEN} upload ${PKG_PATH} --force

echo "Successfully deployed ${PKG_FILE} to Anaconda.org."
45 changes: 45 additions & 0 deletions conda.recipe/meta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% set data = load_setup_py_data() %}

package:
name: "addie"
version: "{{ data['version'] }}"

source:
path: ..

build:
string: py{{py}}
script: python setup.py install --single-version-externally-managed --record=record.txt

requirements:
build:
- mantid-total-scattering-python-wrapper
- mantid-workbench
- periodictable
- psutil
- python
- setuptools

run:
- mantid-total-scattering-python-wrapper
- mantid-workbench
- periodictable
- psutil
- python

test:
imports:
- addie

about:
home: https://github.com/neutrons/addie
license: GPL (version 3)
license_family: GPL3
license_file:
summary: ADvanced DIffraction Environment

extra:
recipe-maintainers:
- JeanBilheux
- marshallmcdonnell
- peterfpeterson
4 changes: 4 additions & 0 deletions install-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
mantid-total-scattering
periodictable
psutil
QtPy
9 changes: 0 additions & 9 deletions requirements.txt

This file was deleted.

39 changes: 32 additions & 7 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
import os
from setuptools import setup, find_packages
import versioneer # https://github.com/warner/python-versioneer

# ==============================================================================
# Constants
# ==============================================================================
THIS_DIR = os.path.dirname(__file__)

# ==============================================================================
# Package requirements helper
# ==============================================================================


def read_requirements_from_file(filepath):
'''Read a list of requirements from the given file and split into a
list of strings. It is assumed that the file is a flat
list with one requirement per line.
:param filepath: Path to the file to read
:return: A list of strings containing the requirements
'''
with open(filepath, 'rU') as req_file:
return req_file.readlines()


setup_args = dict(install_requires=read_requirements_from_file(os.path.join(THIS_DIR, 'install-requirements.txt')),
tests_require=read_requirements_from_file(os.path.join(THIS_DIR, 'test-requirements.txt')))

setup(name="addie",
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
Expand All @@ -10,16 +35,16 @@
url="http://github.com/neutrons/addie",
long_description="""Should have a longer description""",
license="The MIT License (MIT)",
scripts=["scripts/addie"],
entry_points = {
'console_scripts': [
"addie = addie.main:main"
]
},
packages=find_packages(),
package_data={'': ['*.ui', '*.png', '*.qrc', '*.json']},
include_package_data=True,
install_requires=[
'matplotlib <= 2.2.3',
'numpy == 1.15.4',
'periodictable == 1.5.0',
'psutil==5.4.2',
'QtPy==1.6.0' ],
setup_requires=[],
install_requires=setup_args["install_requires"],
tests_require=setup_args["install_requires"] + setup_args["tests_require"],
test_suite='tests'
)
2 changes: 2 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mock
pytest

0 comments on commit 5fe6b7d

Please sign in to comment.