Mercurial > repos > wolma > package_python3_zlib_dependent_1_0
comparison tool_dependencies.xml @ 7:5cfafaafa263 draft default tip
streamlined documentation
| author | wolma |
|---|---|
| date | Fri, 12 Dec 2014 06:40:11 -0500 |
| parents | 79f0803e3bbb |
| children |
comparison
equal
deleted
inserted
replaced
| 6:79f0803e3bbb | 7:5cfafaafa263 |
|---|---|
| 61 The Python programming language version 3. | 61 The Python programming language version 3. |
| 62 | 62 |
| 63 http://www.python.org | 63 http://www.python.org |
| 64 | 64 |
| 65 | 65 |
| 66 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. | 66 A lean build of python 3.4.1. It does not include modules with external dependencies except for the zlib module (handled in here by depending on package_zlib_1_2_8). |
| 67 | |
| 68 In particular, this build does not compile Python's ssl module, which would cause dependency on openssl and, in turn, on Perl. This means that **the pip installation tool will not be available with this build**. | |
| 69 | |
| 70 For a build with more modules (and also ssl) included look at | |
| 71 https://toolshed.g2.bx.psu.edu/view/jankanis/package_python3_4 | |
| 72 written by jankanis, of which this package is a shameless plagiarism. | |
| 67 | 73 |
| 68 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: | 74 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: |
| 69 | 75 |
| 70 <action type="set_environment_for_install"> | 76 <action type="set_environment_for_install"> |
| 71 <repository name="python3" owner="wolma"> | 77 <repository name="package_python3_zlib_dependent_1_0" owner="wolma"> |
| 72 <package name="python3" version="3.4.1" /> | 78 <package name="python3" version="3.4.1" /> |
| 73 </repository> | 79 </repository> |
| 74 <!-- other install time dependencies --> | 80 <!-- other install time dependencies --> |
| 75 </action> | 81 </action> |
| 76 | 82 |
| 77 <action type="shell_command"> | 83 <action type="shell_command"> |
| 78 # Unset any saved environment settings from parent virtual | 84 |
| 79 # environments, e.g. for python 2 or if Galaxy itself is running | |
| 80 # from within a virtual environment. | |
| 81 unset _OLD_VIRTUAL_PATH; unset _OLD_VIRTUAL_PYTHONHOME | |
| 82 # Create virtual environment MY_TOOL_venv | 85 # Create virtual environment MY_TOOL_venv |
| 83 pyvenv MY_TOOL_venv | 86 # pip cannot be used for installation because it depends on ssl, |
| 87 # which this build does not provide | |
| 88 | |
| 89 pyvenv --without-pip $INSTALL_DIR/MY_TOOL_venv | |
| 90 | |
| 84 # install python packages | 91 # install python packages |
| 85 MY_TOOL_venv/bin/pip3 install {{NEEDED_PYTHON_PACKAGES}} | 92 # assuming you are in the download directory of the package |
| 93 | |
| 94 $INSTALL_DIR/MY_TOOL_venv/bin/python3 setup.py install | |
| 86 </action> | 95 </action> |
| 87 | |
| 88 <action type="set_environment"> | |
| 89 | |
| 90 <!-- Setting the PYTHONPATH correctly can be a bit tricky, because you must | |
| 91 make sure that the runtime PYTHONPATH from galaxy itself is not | |
| 92 included, as it probably points to python 2 code that can crash a | |
| 93 program if python 3 tries to load it. | |
| 94 | |
| 95 If you only use a single virtual environment that is created | |
| 96 specifically for a tool you are creating, you can just use a set_to | |
| 97 like below. | |
| 98 | |
| 99 If you create a virtual environment installation that is meant to be | |
| 100 reused by other packages, the virtual environment should probably | |
| 101 prepend its site-packages to the PYTHONPATH since a tool could be | |
| 102 using python modules from several virtual environments. But in such a | |
| 103 scenario the tool that uses these virtual environments should also | |
| 104 depend directly on the python3 package, and this dependency should be | |
| 105 listed before any virtual environment dependencies. This ensures that | |
| 106 the python3 environment settings that clear PYTHONPATH are sourced | |
| 107 first so galaxy's runtime PYTHONPATH is excluded. Virtual environments | |
| 108 can then prepend their PYTHONPATHs to each other. --> | |
| 109 <environment_variable name="PYTHONPATH" action="set_to">$INSTALL_DIR/MY_TOOL_venv/lib/python3.4/site-packages</environment_variable> | |
| 110 <!-- All that is really needed to use a specific virtual environment is that the | |
| 111 python interpreter in that environment is used, so add it to PATH --> | |
| 112 <environment_variable name="PATH" action="prepend_to">$INSTALL_DIR/MY_TOOL_venv/bin</environment_variable> | |
| 113 <!-- Clear incoming PYTHONHOME just like the venv's 'activate' command does --> | |
| 114 <environment_variable name="PYTHONHOME" action="set_to"></environment_variable> | |
| 115 <!-- To find shared libraries for python built-in modules such as libssl or libsqlite3 | |
| 116 we need to re-export LD_LIBRARY_PATH --> | |
| 117 <environment_variable name="LD_LIBRARY_PATH" action="prepend_to">$ENV[LD_LIBRARY_PATH]</environment_variable> | |
| 118 </action> | |
| 119 | |
| 120 | |
| 121 Then, in your MY_TOOL.xml add the following requirement: | |
| 122 | |
| 123 <requirements> | |
| 124 <requirement name="package" version="XXX">MY_TOOL_venv</requirement> | |
| 125 </requirements> | |
| 126 | 96 |
| 97 For an example of how this could used by a package look at: | |
| 98 | |
| 99 https://testtoolshed.g2.bx.psu.edu/view/wolma/package_mimodd_0_1_5 | |
| 100 | |
| 127 </readme> | 101 </readme> |
| 128 | 102 |
| 129 </package> | 103 </package> |
| 130 </tool_dependency> | 104 </tool_dependency> |
