Skip to content

Commit 5fe6b7d

Browse files
marshallmcdonnellpeterfpeterson
authored andcommitted
Conda recipe with deployment on tags via Travis (#235)
* 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
1 parent 8c7e61a commit 5fe6b7d

File tree

10 files changed

+166
-66
lines changed

10 files changed

+166
-66
lines changed

.travis.yml

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
language: python
22
dist: trusty
33

4-
branches:
5-
only:
6-
- master
7-
84
services:
95
- xvfb
106

@@ -21,34 +17,44 @@ matrix:
2117

2218
before_install:
2319
- |
20+
# Install conda
2421
"/sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_99.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :99 -ac -screen 0 1280x1024x16"
2522
if [ "$TRAVIS_OS_NAME" = "linux" ]; then export CXX=g++-4.8 CC=gcc-4.8; fi
2623
if [ "$TRAVIS_OS_NAME" = "linux" ]; then OS=Linux-x86_64; else OS=MacOSX-x86_64; fi
2724
wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda${CONDA:0:1}-latest-$OS.sh
2825
bash miniconda.sh -b -p $HOME/miniconda
2926
export PATH="$HOME/miniconda/bin:$PATH"
30-
conda config --set always_yes yes --set changeps1 no
31-
conda config --add channels conda-forge
32-
conda update -q conda
33-
conda create -n test-environment -q python=$CONDA
34-
conda update -n test-environment -q conda
35-
conda install -n test-environment -q conda-build
36-
conda install -n test-environment -c mantid mantid-workbench nexus poco
37-
conda install -n test-environment flake8
3827
3928
install:
4029
- |
41-
source activate test-environment
42-
conda list
30+
# Setup channels
31+
conda config --set always_yes yes --set changeps1 no --set anaconda_upload no
32+
conda config --add channels conda-forge --add channels marshallmcdonnell --add channels mantid --add channels mantid/label/nightly
33+
34+
conda update -q conda
35+
conda info -a
36+
37+
# Activate environment
38+
conda create -q -n addie_env python=$CONDA flake8 conda-build conda-verify anaconda-client
39+
source activate addie_env
40+
41+
# Build recipe and install addie
42+
conda build conda.recipe
43+
export PKG_FILE=$(conda build conda.recipe --output)
44+
conda install ${PKG_FILE}
4345
4446
before_script:
45-
# create a properties file that turns off network access
46-
- mkdir ~/.mantid
47-
- echo "CheckMantidVersion.OnStartup=0" > ~/.mantid/Mantid.user.properties
48-
- echo "UpdateInstrumentDefinitions.OnStartup=0" >> ~/.mantid/Mantid.user.properties
49-
- echo "usagereports.enabled=0" >> ~/.mantid/Mantid.user.properties
50-
- export DISPLAY=:99.0
51-
- sleep 3
47+
- |
48+
# create a properties file that turns off network access
49+
mkdir ~/.mantid
50+
echo "CheckMantidVersion.OnStartup=0" > ~/.mantid/Mantid.user.properties
51+
echo "UpdateInstrumentDefinitions.OnStartup=0" >> ~/.mantid/Mantid.user.properties
52+
echo "usagereports.enabled=0" >> ~/.mantid/Mantid.user.properties
53+
export DISPLAY=:99.0
54+
sleep 3
55+
- |
56+
conda install -c mantid/label/nightly mantid-workbench
57+
conda install -c marshallmcdonnell mantid-total-scattering-python-wrapper
5258
5359
script:
5460
# lint the code and generate an error if a warning is introduced
@@ -70,3 +76,13 @@ script:
7076
- python setup.py install
7177
- which addie
7278
- xvfb-run --server-args="-screen 0 640x480x24" --auto-servernum addie --version
79+
80+
deploy:
81+
# Deploy conda package to Anaconda.org https://anaconda.org/addie-diffraction/addie
82+
- provider: script
83+
script: cd conda.recipe && chmod +x anaconda_upload.sh && ./anaconda_upload.sh ${PKG_FILE}
84+
skip_cleanup: true
85+
skip_existing: true
86+
on:
87+
branch: master
88+
tags: true

Pipfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ psutil = "*"
1717
pyoncat = {file = "https://oncat.ornl.gov/packages/pyoncat-1.3.2-py2.py3-none-any.whl"}
1818
six = "==1.11.0"
1919
QtPy = "==1.6.0"
20+
flake8 = "*"

scripts/addie renamed to addie/main.py

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env python
21
from __future__ import (absolute_import, division, print_function)
32

43
import copy
@@ -43,8 +42,7 @@
4342

4443
# PyONcat
4544
try:
46-
from addie.processing.mantid.master_table.import_from_database.import_from_database_handler import \
47-
ImportFromDatabaseHandler
45+
from addie.processing.mantid.master_table.import_from_database.import_from_database_handler import ImportFromDatabaseHandler # noqa
4846
ONCAT_ENABLED = True
4947
except ImportError:
5048
print('pyoncat module not found. Functionality disabled')
@@ -55,7 +53,8 @@
5553
import addie.addiedriver as driver
5654
import addie.calculate_gr.edit_sq_dialog
5755

58-
from addie.icons import icons_rc # necessary to see all the icons
56+
# necessary to see all the icons
57+
from addie.icons import icons_rc # noqa
5958

6059
from addie.calculate_gr.pdf_lines_manager import PDFPlotManager
6160

@@ -425,7 +424,7 @@ def help_button_clicked_autonom(self):
425424

426425
def main_tab_widget_changed(self, tab_selected):
427426
if tab_selected == 0:
428-
o_gui = Step1GuiHandler(main_window=self)
427+
Step1GuiHandler(main_window=self)
429428
autonom_event_handler.check_step1_gui(self)
430429
if tab_selected == 1:
431430
_o_gui = Step2GuiHandler(main_window=self)
@@ -471,7 +470,7 @@ def update_logbook(self, text):
471470
if self.job_monitor_interface is None:
472471
self.logbook_thread.stop()
473472
else:
474-
_logbook_handler = LogbookHandler(parent=self)
473+
LogbookHandler(parent=self)
475474

476475
# autoNOM
477476

@@ -921,32 +920,33 @@ def apply_clicked(self):
921920
self.close()
922921

923922

924-
def main(mode):
923+
def main(config=None):
924+
925+
if config is None:
926+
import argparse # noqa
927+
parser = argparse.ArgumentParser(description='ADvanced DIffraction Environment')
928+
parser.add_argument('--version', action='version', version='%(prog)s version {}'.format(__version__))
929+
parser.add_argument('--mode', type=str, default='mantid',
930+
help='Set processing mode (default=%(default)s)', choices=['mantid', 'idl'])
931+
932+
try: # set up bash completion as a soft dependency
933+
import argcomplete # noqa
934+
argcomplete.autocomplete(parser)
935+
except ImportError:
936+
pass # silently skip this
937+
938+
# parse the command line options
939+
config = parser.parse_args()
940+
925941
app = QApplication(sys.argv)
926-
app.setOrganizationName("Qtrac Ltd.")
927-
app.setOrganizationDomain("qtrac.eu")
928-
app.setApplicationName("Image Changer")
942+
app.setOrganizationName("ORNL / SNS")
943+
app.setOrganizationDomain("https://neutrons.ornl.gov/")
944+
app.setApplicationName("ADDIE: ADvanced DIffraction Environment")
929945
app.setWindowIcon(QIcon(":/icon.png"))
930-
form = MainWindow(processing_mode=mode)
946+
form = MainWindow(processing_mode=config.mode)
931947
form.show()
932948
app.exec_()
933949

934950

935951
if __name__ == '__main__':
936-
import argparse # noqa
937-
parser = argparse.ArgumentParser(description='ADvanced DIffraction Environment')
938-
parser.add_argument('--version', action='version', version='%(prog)s version {}'.format(__version__))
939-
parser.add_argument('--mode', type=str, default='mantid',
940-
help='Set processing mode (default=%(default)s)', choices=['mantid', 'idl'])
941-
942-
try: # set up bash completion as a soft dependency
943-
import argcomplete # noqa
944-
argcomplete.autocomplete(parser)
945-
except ImportError:
946-
pass # silently skip this
947-
948-
# parse the command line options
949-
options = parser.parse_args()
950-
951-
# start the main program
952-
main(options.mode)
952+
main()

addiedevel.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ echo using $RAW_PYTHON version $PYTHON_VERSION
3030
$CMD setup.py build
3131

3232
# launch addie
33-
QT_API=$LOCAL_QT_API PYTHONPATH=build/lib:$PYTHONPATH $CMD --classic build/scripts-${PYTHON_VERSION}/addie
33+
QT_API=$LOCAL_QT_API PYTHONPATH=build/lib:$PYTHONPATH $CMD --classic build/lib/addie/main.py

conda.recipe/anaconda_upload.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
3+
# Input
4+
if [[ $# -ne 1 ]]
5+
then
6+
echo "Usage: anaconda_upload.sh <full package path>"
7+
exit 1
8+
fi
9+
10+
PKG_PATH=$1
11+
PKG_FILE=$(basename ${PKG_PATH})
12+
13+
echo "Uploading ${PKG_PATH} artifact..."
14+
anaconda -v -t ${CONDA_UPLOAD_TOKEN} upload ${PKG_PATH} --force
15+
16+
echo "Successfully deployed ${PKG_FILE} to Anaconda.org."

conda.recipe/meta.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{% set data = load_setup_py_data() %}
2+
3+
package:
4+
name: "addie"
5+
version: "{{ data['version'] }}"
6+
7+
source:
8+
path: ..
9+
10+
build:
11+
string: py{{py}}
12+
script: python setup.py install --single-version-externally-managed --record=record.txt
13+
14+
requirements:
15+
build:
16+
- mantid-total-scattering-python-wrapper
17+
- mantid-workbench
18+
- periodictable
19+
- psutil
20+
- python
21+
- setuptools
22+
23+
run:
24+
- mantid-total-scattering-python-wrapper
25+
- mantid-workbench
26+
- periodictable
27+
- psutil
28+
- python
29+
30+
test:
31+
imports:
32+
- addie
33+
34+
about:
35+
home: https://github.com/neutrons/addie
36+
license: GPL (version 3)
37+
license_family: GPL3
38+
license_file:
39+
summary: ADvanced DIffraction Environment
40+
41+
extra:
42+
recipe-maintainers:
43+
- JeanBilheux
44+
- marshallmcdonnell
45+
- peterfpeterson

install-requirements.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mantid-total-scattering
2+
periodictable
3+
psutil
4+
QtPy

requirements.txt

Lines changed: 0 additions & 9 deletions
This file was deleted.

setup.py

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,31 @@
1+
import os
12
from setuptools import setup, find_packages
23
import versioneer # https://github.com/warner/python-versioneer
34

5+
# ==============================================================================
6+
# Constants
7+
# ==============================================================================
8+
THIS_DIR = os.path.dirname(__file__)
9+
10+
# ==============================================================================
11+
# Package requirements helper
12+
# ==============================================================================
13+
14+
15+
def read_requirements_from_file(filepath):
16+
'''Read a list of requirements from the given file and split into a
17+
list of strings. It is assumed that the file is a flat
18+
list with one requirement per line.
19+
:param filepath: Path to the file to read
20+
:return: A list of strings containing the requirements
21+
'''
22+
with open(filepath, 'rU') as req_file:
23+
return req_file.readlines()
24+
25+
26+
setup_args = dict(install_requires=read_requirements_from_file(os.path.join(THIS_DIR, 'install-requirements.txt')),
27+
tests_require=read_requirements_from_file(os.path.join(THIS_DIR, 'test-requirements.txt')))
28+
429
setup(name="addie",
530
version=versioneer.get_version(),
631
cmdclass=versioneer.get_cmdclass(),
@@ -10,16 +35,16 @@
1035
url="http://github.com/neutrons/addie",
1136
long_description="""Should have a longer description""",
1237
license="The MIT License (MIT)",
13-
scripts=["scripts/addie"],
38+
entry_points = {
39+
'console_scripts': [
40+
"addie = addie.main:main"
41+
]
42+
},
1443
packages=find_packages(),
1544
package_data={'': ['*.ui', '*.png', '*.qrc', '*.json']},
1645
include_package_data=True,
17-
install_requires=[
18-
'matplotlib <= 2.2.3',
19-
'numpy == 1.15.4',
20-
'periodictable == 1.5.0',
21-
'psutil==5.4.2',
22-
'QtPy==1.6.0' ],
2346
setup_requires=[],
47+
install_requires=setup_args["install_requires"],
48+
tests_require=setup_args["install_requires"] + setup_args["tests_require"],
2449
test_suite='tests'
2550
)

test-requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
mock
2+
pytest

0 commit comments

Comments
 (0)