-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overhaul virtualenv generation and add Python 3 support #1
Conversation
…rtualenv internally
|
||
file(READ ${program_file} program_contents) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has gotten significantly simpler because of the bash-based python script loaders.
@@ -3,7 +3,7 @@ | |||
<name>catkin_virtualenv</name> | |||
<version>0.0.0</version> | |||
<description>Bundle a virtualenv with a catkin package.</description> | |||
<license>BSD</license> | |||
<license>GPL</license> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
linking with dh_virtualenv, so must inherit license
47b2eef
to
3abca2c
Compare
3abca2c
to
579a9ed
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to find things to complain about. Also, you still have a Python3 unit test TODO. Don't know if you are planning to fix that up in this PR or not.
@@ -65,76 +8,65 @@ function(catkin_install_python) | |||
message(FATAL_ERROR "catkin_install_python() called without required DESTINATION argument.") | |||
endif() | |||
|
|||
catkin_generate_virtualenv() | |||
|
|||
# If this package doesn't need a virtualenv, bypass processing python scripts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't seem to be "bypassing" any longer. Comment needs updating.
|
||
if(EXISTS ${program_file}) | ||
stamp(${program_file}) # Reconfigure when the python script changes. This mirrors upstream behaviour. | ||
# # Use CMake templating to load virtualenv into all specified python scripts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double "#' in comment
@@ -0,0 +1,4 @@ | |||
<?xml version="1.0"?> | |||
<launch> | |||
<test test-name="test_virtualenv_script_py3" pkg="test_catkin_virtualenv_py3" type="test_virtualenv_script" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what the "best practices" are for naming things, but I find the ROS generated test names to be frustrating. They throw in an extra "test" in places.
Outputting test results to .../rostest-test_test_virtualenv_script.xml
[Testcase: testtest_virtualenv_script] ... ok
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
README.md
Outdated
|
||
Make sure your python executables are installed using `catkin_install_python`: | ||
# Generate the virtualenv, potentially in PYTHON3 mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inconsistent spacing between #
and text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
I'm not planning to sink any more time into python3 rostest at the moment, I'll come back to it in a sprint or if it's in demand. |
Will copyrightify after PR is merged |
e5b2388
to
212ac36
Compare
212ac36
to
fb0b1c1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're releasing this into the public sphere, I'd suggest adding explicit expectations about issues/support requests. e.g. An issue template which just says in big letters "If you can't figure out how X works, consult ROS answers first " might be valuable.
(Mostly because I don't love getting notifications for the repos I follow when someone sends a confused message about, e.g., how to compile.)
DEPENDS ${requirements_list} | ||
) | ||
|
||
# Build a virtualenv in CMAKE_BINARY_DIR, with internal file structure set up for in devel or installspace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you want to strike either "for" or "in". Technically, "devel-" should be hyphenated if you're shorthanding "develspace or installspace".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
DEPENDS ${generated_requirements} | ||
) | ||
|
||
# Symlink virtualenv to the destination - this really only has an effect in develspace. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"-" should be an em-dash ("--").
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
catkin_virtualenv/scripts/build_venv
Outdated
parser.add_argument('--requirements', required=True, help="Packages to install into the virtual environment.") | ||
parser.add_argument('--venv-dir', required=True, help="Directory where to generate the virtual environment.") | ||
parser.add_argument('--install-dir', help="Directory where the virtual environment will be installed.") | ||
parser.add_argument('--python3', action='store_true', help="Python interpreter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
help="Use the Python 3 interpreter instead of Python 2."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
catkin_virtualenv/scripts/build_venv
Outdated
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser(description="Build a relocatable virtualenv.") | ||
parser.add_argument('--requirements', required=True, help="Packages to install into the virtual environment.") | ||
parser.add_argument('--venv-dir', required=True, help="Directory where to generate the virtual environment.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Where to" -> "Directory in which to generate the virtual environment."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
catkin_virtualenv/scripts/build_venv
Outdated
parser = argparse.ArgumentParser(description="Build a relocatable virtualenv.") | ||
parser.add_argument('--requirements', required=True, help="Packages to install into the virtual environment.") | ||
parser.add_argument('--venv-dir', required=True, help="Directory where to generate the virtual environment.") | ||
parser.add_argument('--install-dir', help="Directory where the virtual environment will be installed.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confusing -- the venv is generated in one directory, then installed in another. Should --venv-dir
be "Directory from which to generate a venv"? Or maybe this should be "Directory where requirements for the virtual environment will be installed"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it's generated in directory one, but the paths have to be rewritten for it to live in directory two, whether it's develspace, installspace, or /opt/ros
one = venv_dir
two = install_dir
any suggestions on how to clarify?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comments since this is now hidden.
import tempfile | ||
|
||
ROOT_ENV_KEY = 'DH_VIRTUALENV_INSTALL_ROOT' | ||
DEFAULT_INSTALL_DIR = '/opt/venvs/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
# self.virtualenv_install_dir = os.path.join(install_root, install_suffix) | ||
# self.package_dir = os.path.join(self.debian_root, install_suffix) | ||
|
||
# (pbovbel) slightly modified to allow specifiying exactly which dir houses the generated and installed venv |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you wanted to preserve the old behavior in some format, you could pepper the old logic with appropriate if not package_dir
and if not install_dir
blocks.
self.pip_args.extend(extra_pip_arg) | ||
|
||
@classmethod | ||
def from_options(cls, package, options): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not updated with your new options.
|
||
@classmethod | ||
def from_options(cls, package, options): | ||
verbose = options.verbose or os.environ.get('DH_VERBOSE') == '1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May need to adjust if you want to use it in the script. (also I really thought os.environ would convert variables to integers, but it super doesn't.)
self.setuptools = setuptools | ||
self.python = python | ||
self.builtin_venv = builtin_venv | ||
self.sourcedirectory = '.' if sourcedirectory is None else sourcedirectory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upstream's disdain for underscores is sad. :(
@tappan-at-git I've eliminated the venv-dir arg entirely to simplify the build_venv usage. The venv is generated into the CWD, and the paths are rewritten for install_dir. |
0c06fe3
to
6b71f8a
Compare
8cea76a
to
2bad526
Compare
2bad526
to
8d4027f
Compare
The intent is to release this module publicly, so please be pedantic.