|
2
|
1 <?xml version="1.0"?>
|
|
3
|
2 <tool_dependency>
|
|
2
|
3 <package name="python3" version="3.4.1">
|
|
|
4 <install version="1.0">
|
|
|
5 <actions>
|
|
|
6 <action type="download_by_url">https://www.python.org/ftp/python/3.4.1/Python-3.4.1.tgz</action>
|
|
|
7
|
|
|
8 <action type="set_environment_for_install">
|
|
|
9 <repository changeset_revision="31f1e69aae89" name="package_zlib_1_2_8" owner="iuc" toolshed="http://toolshed.g2.bx.psu.edu">
|
|
|
10 <package name="zlib" version="1.2.8" />
|
|
|
11 </repository>
|
|
|
12 </action>
|
|
|
13
|
|
|
14 <action type="shell_command">
|
|
|
15 # The python build system doesn't check CPATH / C(PLUS)_INCLUDE_PATH which is set by the depended-upon
|
|
|
16 # tool definitions for these sources, but it does check CPPFLAGS / LDFLAGS
|
|
|
17 # Currently not whitespace-safe, I haven't found a way yet to quote the *FLAGS values so that they are
|
|
|
18 # correctly recognized by both the python build process and the compiler. But as galaxy itself isn't
|
|
|
19 # whitespace-safe either it doesn't really matter (currently).
|
|
|
20 oldifs="$IFS"
|
|
|
21 IFS=":"
|
|
|
22 for p in $CPLUS_INCLUDE_PATH
|
|
|
23 do
|
|
|
24 CPPFLAGS="$CPPFLAGS -I$p"
|
|
|
25 done
|
|
|
26 for p in $LD_LIBRARY_PATH
|
|
|
27 do
|
|
|
28 LDFLAGS="$LDFLAGS -L$p"
|
|
|
29 done
|
|
|
30 IFS="$oldifs"
|
|
|
31 export CPPFLAGS
|
|
|
32 export LDFLAGS
|
|
|
33
|
|
|
34 # Clear variables that may be used in Galaxy's extenal python 2 environment
|
|
|
35 unset PYTHONPATH
|
|
|
36 unset PYTHONHOME
|
|
|
37
|
|
|
38 ./configure --prefix="$INSTALL_DIR" --with-ensurepip \
|
|
|
39 && make \
|
|
|
40 && make install
|
|
|
41 </action>
|
|
|
42
|
|
|
43 <action type="set_environment">
|
|
|
44 <environment_variable action="prepend_to" name="PATH">$INSTALL_DIR/bin</environment_variable>
|
|
|
45 <environment_variable action="prepend_to" name="LD_LIBRARY_PATH">$ENV[LD_LIBRARY_PATH]</environment_variable>
|
|
|
46 <!-- clear PYTHONPATH, otherwise we will get Galaxy's Python 2 libraries in the Python 3 path. -->
|
|
|
47 <environment_variable action="set_to" name="PYTHONPATH" />
|
|
|
48 <environment_variable action="set_to" name="PYTHONHOME">$INSTALL_DIR</environment_variable>
|
|
|
49 <environment_variable action="prepend_to" name="PKG_CONFIG_PATH">$INSTALL_DIR/lib/pkgconfig</environment_variable>
|
|
|
50 </action>
|
|
|
51 </actions>
|
|
|
52 </install>
|
|
|
53
|
|
|
54 <readme>
|
|
|
55 Python 3.4.1
|
|
|
56
|
|
|
57 The Python programming language version 3.
|
|
|
58
|
|
|
59 http://www.python.org
|
|
|
60
|
|
|
61
|
|
|
62 A lean build of python 3.4.1. It does not include modules with external dependencies except for the zlib module, which requires the zlib library installed on your system. For a build with more such modules included look at https://toolshed.g2.bx.psu.edu/view/jankanis/package_python3_4 written by jankanis, of which this package is a shameless plagiarism.
|
|
|
63
|
|
|
64 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:
|
|
|
65
|
|
|
66 <action type="set_environment_for_install">
|
|
|
67 <repository name="python3" owner="wolma">
|
|
|
68 <package name="python3" version="3.4.1" />
|
|
|
69 </repository>
|
|
|
70 <!-- other install time dependencies -->
|
|
|
71 </action>
|
|
|
72
|
|
|
73 <action type="shell_command">
|
|
|
74 # Unset any saved environment settings from parent virtual
|
|
|
75 # environments, e.g. for python 2 or if Galaxy itself is running
|
|
|
76 # from within a virtual environment.
|
|
|
77 unset _OLD_VIRTUAL_PATH; unset _OLD_VIRTUAL_PYTHONHOME
|
|
|
78 # Create virtual environment MY_TOOL_venv
|
|
|
79 pyvenv MY_TOOL_venv
|
|
|
80 # install python packages
|
|
|
81 MY_TOOL_venv/bin/pip3 install {{NEEDED_PYTHON_PACKAGES}}
|
|
|
82 </action>
|
|
|
83
|
|
|
84 <action type="set_environment">
|
|
|
85
|
|
|
86 <!-- Setting the PYTHONPATH correctly can be a bit tricky, because you must
|
|
|
87 make sure that the runtime PYTHONPATH from galaxy itself is not
|
|
|
88 included, as it probably points to python 2 code that can crash a
|
|
|
89 program if python 3 tries to load it.
|
|
|
90
|
|
|
91 If you only use a single virtual environment that is created
|
|
|
92 specifically for a tool you are creating, you can just use a set_to
|
|
|
93 like below.
|
|
|
94
|
|
|
95 If you create a virtual environment installation that is meant to be
|
|
|
96 reused by other packages, the virtual environment should probably
|
|
|
97 prepend its site-packages to the PYTHONPATH since a tool could be
|
|
|
98 using python modules from several virtual environments. But in such a
|
|
|
99 scenario the tool that uses these virtual environments should also
|
|
|
100 depend directly on the python3 package, and this dependency should be
|
|
|
101 listed before any virtual environment dependencies. This ensures that
|
|
|
102 the python3 environment settings that clear PYTHONPATH are sourced
|
|
|
103 first so galaxy's runtime PYTHONPATH is excluded. Virtual environments
|
|
|
104 can then prepend their PYTHONPATHs to each other. -->
|
|
|
105 <environment_variable name="PYTHONPATH" action="set_to">$INSTALL_DIR/MY_TOOL_venv/lib/python3.4/site-packages</environment_variable>
|
|
|
106 <!-- All that is really needed to use a specific virtual environment is that the
|
|
|
107 python interpreter in that environment is used, so add it to PATH -->
|
|
|
108 <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR/MY_TOOL_venv/bin</environment_variable>
|
|
|
109 <!-- Clear incoming PYTHONHOME just like the venv's 'activate' command does -->
|
|
|
110 <environment_variable name="PYTHONHOME" action="set_to"></environment_variable>
|
|
|
111 <!-- To find shared libraries for python built-in modules such as libssl or libsqlite3
|
|
|
112 we need to re-export LD_LIBRARY_PATH -->
|
|
|
113 <environment_variable name="LD_LIBRARY_PATH" action="prepend_to">$ENV[LD_LIBRARY_PATH]</environment_variable>
|
|
|
114 </action>
|
|
|
115
|
|
|
116
|
|
|
117 Then, in your MY_TOOL.xml add the following requirement:
|
|
|
118
|
|
|
119 <requirements>
|
|
|
120 <requirement name="package" version="XXX">MY_TOOL_venv</requirement>
|
|
|
121 </requirements>
|
|
|
122
|
|
|
123 </readme>
|
|
|
124
|
|
|
125 </package>
|
|
|
126 </tool_dependency>
|