From 1e312faccd0c396c182637cda563166ba1872a22 Mon Sep 17 00:00:00 2001 From: Nate Coraor Date: Wed, 14 Oct 2015 23:15:51 -0400 Subject: [PATCH] Make Galaxy installable the Pythonic way via setup.py. Incomplete, but if you install it and then run `galaxy` from the root of a Galaxy clone, after installing all the dependencies (see the end of ./scripts/common_startup.sh), it should start. --- lib/galaxy/model/migrate/versions/__init__.py | 0 .../migrate/versions/__init__.py | 0 scripts/galaxy | 126 ++++++++++++++++++ setup.py | 62 +++++++++ 4 files changed, 188 insertions(+) create mode 100644 lib/galaxy/model/migrate/versions/__init__.py create mode 100644 lib/tool_shed/galaxy_install/migrate/versions/__init__.py create mode 100755 scripts/galaxy create mode 100644 setup.py diff --git a/lib/galaxy/model/migrate/versions/__init__.py b/lib/galaxy/model/migrate/versions/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/tool_shed/galaxy_install/migrate/versions/__init__.py b/lib/tool_shed/galaxy_install/migrate/versions/__init__.py new file mode 100644 index 00000000000..e69de29bb2d diff --git a/scripts/galaxy b/scripts/galaxy new file mode 100755 index 00000000000..323875c78fd --- /dev/null +++ b/scripts/galaxy @@ -0,0 +1,126 @@ +#!/bin/bash + +show_help() { +cat <&2 + exit 1 + fi + ;; + -c|--config) + if [ $# -gt 1 ]; then + GALAXY_CONFIG_DIR=$2 + shift 2 + else + echo "--config requires explicit argument" 1>&2 + exit 1 + fi + ;; + --) + shift + break + ;; + *) + break; + ;; + esac +done + +SCRIPTS_DIRECTORY="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +PROJECT_DIRECTORY=$SCRIPTS_DIRECTORY/.. + +GALAXY_CONFIG_DIR=${GALAXY_CONFIG_DIR:-"./config"} +export GALAXY_CONFIG_DIR + +GALAXY_LOCAL_ENV=${GALAXY_LOCAL_ENV:-$GALAXY_CONFIG_DIR/local_env.sh} +export GALAXY_LOCAL_ENV + +GALAXY_VIRTUALENV=${GALAXY_VIRTUALENV:-$PROJECT_DIRECTORY/.venv} +export GALAXY_VIRTUALENV + +if [ -e $GALAXY_LOCAL_ENV ]; +then + echo "Sourcing file $GALAXY_LOCAL_ENV" + . $GALAXY_LOCAL_ENV +fi + +if [ -d $GALAXY_VIRTUALENV ]; +then + echo "Activating virtual environment $GALAXY_VIRTUALENV/bin/activate" + . $GALAXY_VIRTUALENV/bin/activate +fi + +GALAXY_CONFIG_SAMPLE_FILE="${PROJECT_DIRECTORY}/galaxy.ini.sample" +if [ -z "$GALAXY_CONFIG_FILE" ]; then + if [ -f "${GALAXY_CONFIG_DIR}/galaxy.ini" ]; then + GALAXY_CONFIG_FILE="${GALAXY_CONFIG_DIR}/galaxy.ini" + else + GALAXY_CONFIG_FILE="$GALAXY_CONFIG_SAMPLE_FILE" + fi + export GALAXY_CONFIG_FILE +fi + +if [ -z "$MODE" ]; +then + if hash uwsgi 2>/dev/null; then + MODE="uwsgi" + else + MODE="paster" + fi +fi + +if [ "$MODE" == "uwsgi" ]; then + echo "Starting galaxy with command [uwsgi --ini-paste \"$GALAXY_CONFIG_FILE\" \"$@\"]" + uwsgi --ini-paste "$GALAXY_CONFIG_FILE" "$@" +elif [ "$MODE" == "paster" ]; then + echo "Starting galaxy with command [galaxy-paster serve \"$GALAXY_CONFIG_FILE\" \"$@\"]" + galaxy-paster serve "$GALAXY_CONFIG_FILE" "$@" +elif [ "$MODE" == "webless" ]; then + if hash galaxy-main 2>/dev/null; then + # Running from pip install since + # galaxy-main is available on PATH. + echo "Starting galaxy with command [galaxy-main]" + galaxy-main + else + # Running locally. + PROJECT_DIRECTORY=$GALAXY_SCRIPTS_DIR/.. + cd $PROJECT_DIRECTORY + export PYTHONPATH=.:$PYTHONPATH + echo "Starting galaxy with command [python lib/galaxy/main.py]" + python lib/pulsar/main.py + fi +else + echo "Unknown mode passed to --mode argument." 1>&2 + exit 1 +fi diff --git a/setup.py b/setup.py new file mode 100644 index 00000000000..4b3634016db --- /dev/null +++ b/setup.py @@ -0,0 +1,62 @@ +import sys + +from setuptools import setup, find_packages + + +readme = open('README.rst').read() + +# Obviously this should not be empty, but for the moment, use: +# pip install -e git+https://github.com/natefoo/pip@linux-wheels#egg=pip && \ +# pip install -r requirements.txt --index-url https://wheels.galaxyproject.org/simple/ +requirements = [ +] + + +# sets VERSION (also VERSION_MAJOR and VERSION_MINOR) +execfile('lib/galaxy/version.py') + +scripts = ["scripts/galaxy"] + +setup( + name='galaxy', + version=VERSION, + description='Galaxy (http://galaxyproject.org/).', + long_description=readme, + author='Galaxy Project', + author_email='galaxy-dev@lists.galaxyproject.org', + url='https://github.com/galaxyproject/galaxy', + packages=find_packages('lib'), + entry_points=''' + [console_scripts] + galaxy-paster=galaxy.util.pastescript.serve:run + galaxy-main=galaxy.main:main + ''', + scripts=scripts, + package_data={'galaxy': [ + 'exceptions/error_codes.json', + 'jobs/runners/util/job_script/DEFAULT_JOB_FILE_TEMPLATE.sh', + 'jobs/runners/util/job_script/CLUSTER_SLOTS_STATEMENT.sh', + 'model/migrate/migrate.cfg', + 'util/docutils_template.txt', + ], 'tool_shed': [ + 'galaxy_install/migrate/migrate.cfg', + ]}, + package_dir={'': 'lib'}, + include_package_data=True, + install_requires=requirements, + license="Academic Free License 3.0", + zip_safe=False, + keywords='galaxy', + classifiers=[ + 'Development Status :: 5 - Production/Stable', + 'Intended Audience :: Developers', + 'Environment :: Console', + 'License :: OSI Approved :: Apache Software License', + 'Operating System :: POSIX', + 'Natural Language :: English', + "Programming Language :: Python :: 2", + 'Programming Language :: Python :: 2.6', + 'Programming Language :: Python :: 2.7', + ], + test_suite='test' +)