# HG changeset patch # User jankanis # Date 1401288243 14400 # Node ID d30e6a97dfbf7a762b01919412d90f0e2eb0eb0d # Parent 7719329e5b98e0b1ad4fc8869e2037feabfff4a0 add dependency on zlib diff -r 7719329e5b98 -r d30e6a97dfbf tool_dependencies.xml --- a/tool_dependencies.xml Wed May 28 05:28:22 2014 -0400 +++ b/tool_dependencies.xml Wed May 28 10:44:03 2014 -0400 @@ -4,6 +4,10 @@ + + + + @@ -19,6 +23,9 @@ https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz + + + @@ -61,8 +68,8 @@ $INSTALL_DIR/bin - $ENV[LD_LIBRARY_PATH] - + $ENV[LD_LIBRARY_PATH] + $INSTALL_DIR $INSTALL_DIR/lib/pkgconfig @@ -80,41 +87,65 @@ This build of python is configured with --enable-loadable-sqlite-extensions, any other settings are default. This build does not include modules for lzma and Tkinter, but does include ssl, (g)dbm and sqlite. Adding the missing modules should not be very difficult but requires wrapping the external sources that these modules require inside galaxy. - Python as of version 3.3 includes a built-in virtual environment manager. To create a python 3 virtual env, include the following actions in your tool_dependencies.xml: + Python as of version 3.3 includes a built-in virtual environment manager. To create a python 3 virtual env, include the following actions in your tool_dependencies.xml, e.g. for a package MY_TOOL_venv: <action type="set_environment_for_install"> <repository name="python3" owner="jankanis"> <package name="python3" version="3.4.1" /> </repository> - <!-- other install time dependencies --> + <!-- other install time dependencies --> </action> <action type="shell_command"> - # Unset any saved environment settings from parent virtual - # environments, e.g. for python 2 or if Galaxy itself is running - # from within a virtual environment. - unset _OLD_VIRTUAL_PATH; unset _OLD_VIRTUAL_PYTHONHOME - # Create virtual environment MY_TOOL_venv - pyvenv MY_TOOL_venv - # install python packages - MY_TOOL_venv/bin/pip3 install {{NEEDED_PYTHON_PACKAGES}} + # Unset any saved environment settings from parent virtual + # environments, e.g. for python 2 or if Galaxy itself is running + # from within a virtual environment. + unset _OLD_VIRTUAL_PATH; unset _OLD_VIRTUAL_PYTHONHOME + # Create virtual environment MY_TOOL_venv + pyvenv MY_TOOL_venv + # install python packages + MY_TOOL_venv/bin/pip3 install {{NEEDED_PYTHON_PACKAGES}} </action> <action type="set_environment"> - <!-- Remove any incoming PYTHONPATH elements from Galaxy's own python 2 environment, - but include an existing install time PYTHONPATH (e.g. from other python3 virtual - environments in the dependency hierarchy. --> - <environment_variable name="PYTHONPATH" action="set_to">$INSTALL_DIR/MY_TOOL_venv/lib/python3.4/site-packages:$ENV[PYTHONPATH]</environment_variable> - <!-- All that is really needed to use a specific virtual environment is that the - python interpreter in that environment is used, so add it to PATH --> - <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR/MY_TOOL_venv/bin</environment_variable> - <!-- Clear incoming PYTHONHOME just like the venv's 'activate' command does --> - <environment_variable name="PYTHONHOME" action="set_to"></environment_variable> - <!-- To find shared libraries for python built-in modules such as libssl or libsqlite3 - we need to re-export LD_LIBRARY_PATH --> - <environment_variable name="LD_LIBRARY_PATH" action="prepend_to">$ENV[LD_LIBRARY_PATH]</environment_variable> + + <!-- Setting the PYTHONPATH correctly can be a bit tricky, because you must + make sure that the runtime PYTHONPATH from galaxy itself is not + included, as it probably points to python 2 code that can crash a + program if python 3 tries to load it. + + If you only use a single virtual environment that is created + specifically for a tool you are creating, you can just use a set_to + like below. + + If you create a virtual environment installation that is meant to be + reused by other packages, the virtual environment should probably + prepend its site-packages to the PYTHONPATH since a tool could be + using python modules from several virtual environments. But in such a + scenario the tool that uses these virtual environments should also + depend directly on the python3 package, and this dependency should be + listed before any virtual environment dependencies. This ensures that + the python3 environment settings that clear PYTHONPATH are sourced + first so galaxy's runtime PYTHONPATH is excluded. Virtual environments + can then prepend their PYTHONPATHs to each other. --> + <environment_variable name="PYTHONPATH" action="set_to">$INSTALL_DIR/MY_TOOL_venv/lib/python3.4/site-packages</environment_variable> + <!-- All that is really needed to use a specific virtual environment is that the + python interpreter in that environment is used, so add it to PATH --> + <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR/MY_TOOL_venv/bin</environment_variable> + <!-- Clear incoming PYTHONHOME just like the venv's 'activate' command does --> + <environment_variable name="PYTHONHOME" action="set_to"></environment_variable> + <!-- To find shared libraries for python built-in modules such as libssl or libsqlite3 + we need to re-export LD_LIBRARY_PATH --> + <environment_variable name="LD_LIBRARY_PATH" action="prepend_to">$ENV[LD_LIBRARY_PATH]</environment_variable> </action> + + Then, in your MY_TOOL.xml add the following requirement: + + <requirements> + <requirement name="package" version="XXX">MY_TOOL_venv</requirement> + </requirements> +