diff --git a/ament_cmake_virtualenv/CHANGELOG.rst b/ament_cmake_virtualenv/CHANGELOG.rst
index 795ed45..a2a038f 100644
--- a/ament_cmake_virtualenv/CHANGELOG.rst
+++ b/ament_cmake_virtualenv/CHANGELOG.rst
@@ -2,6 +2,10 @@
Changelog for package ament_cmake_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+0.0.5 (2020-01-10)
+------------------
+* fixed various bugs identified by CI
+
0.0.4 (2019-12-09)
------------------
* added fallbacks for different environments
diff --git a/ament_cmake_virtualenv/package.xml b/ament_cmake_virtualenv/package.xml
index 875286b..c290a09 100644
--- a/ament_cmake_virtualenv/package.xml
+++ b/ament_cmake_virtualenv/package.xml
@@ -22,7 +22,7 @@ along with this program. If not, see .
-->
ament_cmake_virtualenv
- 0.0.4
+ 0.0.5
Bundle python requirements in a ament package via virtualenv.
Max Krichenbauer
diff --git a/ament_virtualenv/CHANGELOG.rst b/ament_virtualenv/CHANGELOG.rst
index af90503..ae11e48 100644
--- a/ament_virtualenv/CHANGELOG.rst
+++ b/ament_virtualenv/CHANGELOG.rst
@@ -2,6 +2,10 @@
Changelog for package ament_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+0.0.5 (2020-01-10)
+------------------
+* fixed various bugs identified by CI
+
0.0.4 (2019-12-09)
------------------
* added fallbacks for different environments
diff --git a/ament_virtualenv/ament_virtualenv/build_venv.py b/ament_virtualenv/ament_virtualenv/build_venv.py
index 3dbb855..3c71ff5 100755
--- a/ament_virtualenv/ament_virtualenv/build_venv.py
+++ b/ament_virtualenv/ament_virtualenv/build_venv.py
@@ -111,7 +111,13 @@ def main(argv=sys.argv[1:]):
retries=args.retries
)
-def build_venv(root_dir, python_version, requirements_filename, use_system_packages=False, extra_pip_args="", retries=0):
+
+def build_venv(root_dir,
+ python_version,
+ requirements_filename,
+ use_system_packages=False,
+ extra_pip_args="",
+ retries=0):
root_dir = os.path.realpath(root_dir)
python_executable = find_python(python_version)
os.environ['DH_VIRTUALENV_INSTALL_ROOT'] = os.path.dirname(root_dir)
diff --git a/ament_virtualenv/ament_virtualenv/combine_requirements.py b/ament_virtualenv/ament_virtualenv/combine_requirements.py
index 6318a8e..16c8340 100755
--- a/ament_virtualenv/ament_virtualenv/combine_requirements.py
+++ b/ament_virtualenv/ament_virtualenv/combine_requirements.py
@@ -31,10 +31,10 @@
try:
from ament_virtualenv.requirements import VcsRequirement
-except:
+except ImportError:
try:
from requirements import VcsRequirement
- except:
+ except ImportError:
from .requirements import VcsRequirement
comment_regex = re.compile(r'\s*#\s.*$', flags=re.MULTILINE)
@@ -73,10 +73,8 @@ def combine_requirements(requirements_list, output_file):
)
else:
combined_requirements[requirement.name].suppressed_set.add(
- SuppressedRequirement(
- requirement=requirement,
- source=requirements_file.name)
- )
+ SuppressedRequirement(requirement=requirement,
+ source=requirements_file.name))
for entry in combined_requirements.values():
output_file.write("{} # from {}\n".format(entry.requirement, entry.source))
diff --git a/ament_virtualenv/ament_virtualenv/deployment.py b/ament_virtualenv/ament_virtualenv/deployment.py
index d27983b..3b5584b 100644
--- a/ament_virtualenv/ament_virtualenv/deployment.py
+++ b/ament_virtualenv/ament_virtualenv/deployment.py
@@ -125,8 +125,9 @@ def __init__(self,
# Keep a copy with well-suported options only (for upgrading pip itself)
self.pip_upgrade_args = self.pip_args[:]
- # Add in any user supplied pip args
- extra_pip_arg = [e for e in extra_pip_arg if e != ''] # remove empty strings
+ # Add in any user supplied pip args,
+ # removing empty strings.
+ extra_pip_arg = [e for e in extra_pip_arg if e != '']
self.pip_args.extend(extra_pip_arg)
# (pbovbel) Set pip_upgrade_args here to keep flags like -q, disregard L111 above.
diff --git a/ament_virtualenv/ament_virtualenv/glob_requirements.py b/ament_virtualenv/ament_virtualenv/glob_requirements.py
index a3a2d78..9b756be 100755
--- a/ament_virtualenv/ament_virtualenv/glob_requirements.py
+++ b/ament_virtualenv/ament_virtualenv/glob_requirements.py
@@ -28,40 +28,42 @@
try:
from ament_virtualenv.package import parse_package
-except:
+except ImportError:
try:
from package import parse_package
- except:
+ except ImportError:
from .package import parse_package
try:
from queue import Queue
-except:
+except ImportError:
from Queue import Queue
def find_in_workspaces(project, file, workspaces=[]):
# Add default workspace search paths
ament_paths = os.environ.get('AMENT_PREFIX_PATH')
- if ament_paths != None:
+ if ament_paths is not None:
# AMENT_PREFIX_PATH points at install/
ament_paths = ament_paths.split(os.pathsep)
for path in ament_paths:
- if (os.path.sep + 'install' + os.path.sep) in path or (os.path.sep + 'install_isolated' + os.path.sep) in path:
+ if ((os.path.sep + 'install' + os.path.sep) in path or
+ (os.path.sep + 'install_isolated' + os.path.sep) in path):
workspaces.append(os.path.join(path, '..'))
- workspaces.append(os.path.join(path, '..', '..' , 'src'))
+ workspaces.append(os.path.join(path, '..', '..', 'src'))
break
if len(workspaces) == 0:
# if AMENT_PREFIX_PATH wasn't set, we can fall back on
# CMAKE_PREFIX_PATH (should contain the same information)
cmake_paths = os.environ.get('CMAKE_PREFIX_PATH')
- if cmake_paths != None:
+ if cmake_paths is not None:
# CMAKE_PREFIX_PATH points at install/ or install_isolated/
cmake_paths = cmake_paths.split(os.pathsep)
for path in cmake_paths:
- if (os.path.sep + 'install' + os.path.sep) in path or (os.path.sep + 'install_isolated' + os.path.sep) in path:
+ if ((os.path.sep + 'install' + os.path.sep) in path or
+ (os.path.sep + 'install_isolated' + os.path.sep) in path):
workspaces.append(os.path.join(path, '..'))
- workspaces.append(os.path.join(path, '..', '..' , 'src'))
+ workspaces.append(os.path.join(path, '..', '..', 'src'))
break
if len(workspaces) == 0:
# COLCON_PREFIX_PATH points to the `install/` directory,
@@ -70,14 +72,14 @@ def find_in_workspaces(project, file, workspaces=[]):
# but ament_cmake does not copy the files until after the
# build, which is too late. So for ament_cmake we also
# need to add the neighboring `src/` folder to the seach
- # (eg.: `install/../src/`)
+ # (eg.: `install/../src/`)
colcon_paths = os.environ.get('COLCON_PREFIX_PATH')
- if colcon_paths != None:
+ if colcon_paths is not None:
colcon_paths = colcon_paths.split(os.pathsep)
for path in colcon_paths:
if (os.path.sep + 'install') in path or (os.path.sep + 'install_isolated') in path:
workspaces.append(path)
- workspaces.append(os.path.join(path, '..' , 'src'))
+ workspaces.append(os.path.join(path, '..', 'src'))
if len(workspaces) == 0:
# final fallback: use working directory (usually src/)
path = os.getcwd()
@@ -85,19 +87,18 @@ def find_in_workspaces(project, file, workspaces=[]):
workspaces.append(path)
if len(workspaces) == 0:
raise RuntimeError(
- "[ament_virtualenv] Failed to find any workspaces."
- + "\nAMENT_PREFIX_PATH=" + os.environ.get('AMENT_PREFIX_PATH', 'NOT SET')
- + "\nCMAKE_PREFIX_PATH=" + os.environ.get('CMAKE_PREFIX_PATH', 'NOT SET')
- + "\nCOLCON_PREFIX_PATH=" + os.environ.get('COLCON_PREFIX_PATH', 'NOT SET')
- + "\nCWD=" + os.getcwd()
+ "[ament_virtualenv] Failed to find any workspaces." +
+ "\nAMENT_PREFIX_PATH=" + os.environ.get('AMENT_PREFIX_PATH', 'NOT SET') +
+ "\nCMAKE_PREFIX_PATH=" + os.environ.get('CMAKE_PREFIX_PATH', 'NOT SET') +
+ "\nCOLCON_PREFIX_PATH=" + os.environ.get('COLCON_PREFIX_PATH', 'NOT SET') +
+ "\nCWD=" + os.getcwd()
)
# now search the workspaces
for workspace in (workspaces or []):
for d, dirs, files in os.walk(workspace, topdown=True, followlinks=True):
- if ('CATKIN_IGNORE' in files or
- 'COLCON_IGNORE' in files or
- 'AMENT_IGNORE' in files
- ):
+ if (('CATKIN_IGNORE' in files) or
+ ('COLCON_IGNORE' in files) or
+ ('AMENT_IGNORE' in files)):
del dirs[:]
continue
dirname = os.path.basename(d)
@@ -146,8 +147,8 @@ def process_package(package_name, soft_fail=True):
)
if not package_path:
if not soft_fail:
- raise RuntimeError("Failed to find package.xml for package "
- + package_name + ' in ' + ';'.join(workspaces))
+ raise RuntimeError("Failed to find package.xml for package " +
+ package_name + ' in ' + ';'.join(workspaces))
else:
# This is not an ament dependency
return [], []
diff --git a/ament_virtualenv/ament_virtualenv/install.py b/ament_virtualenv/ament_virtualenv/install.py
index 1ddb209..84271e1 100644
--- a/ament_virtualenv/ament_virtualenv/install.py
+++ b/ament_virtualenv/ament_virtualenv/install.py
@@ -33,16 +33,19 @@
from ament_virtualenv.combine_requirements import combine_requirements
from ament_virtualenv.build_venv import build_venv
ament_virtualenv_import_failed = False
-except:
+except ImportError:
ament_virtualenv_import_failed = True
#
+
def find_program(name='build_venv.py', package='ament_virtualenv'):
- '''
+ """
+ Find modules which are part of this package.
+
Helper function to find the modules that are part of this
package (glob_requirements, combine_requirements, build_venv),
in cases where a direct import failes due to python path issues.
- '''
+ """
ament_prefix_path = os.environ.get("AMENT_PREFIX_PATH")
if not ament_prefix_path:
return None
@@ -61,7 +64,7 @@ def find_program(name='build_venv.py', package='ament_virtualenv'):
def install_venv(install_base, package_name, python_version='2'):
venv_install_dir = os.path.join(install_base, 'venv')
bin_dir = os.path.join(install_base, 'bin')
- #
+ #
# Build the virtual environment
python = shutil.which("python3")
if not python:
@@ -71,14 +74,15 @@ def install_venv(install_base, package_name, python_version='2'):
return 1
# glob_requirements --package-name ament_cmake_haros
- if ament_virtualenv_import_failed == True:
+ if ament_virtualenv_import_failed is True:
# Fallback: try to find the command line script and run it
- glob_requirements_py = find_program(name='glob_requirements.py', package='ament_virtualenv')
+ glob_requirements_py = find_program(name='glob_requirements.py',
+ package='ament_virtualenv')
if not glob_requirements_py:
print("ERROR: Failed to locate glob_requirements", file=sys.stderr)
return 1
cmd = [
- python,
+ python,
glob_requirements_py,
'--package-name',
package_name
@@ -92,9 +96,11 @@ def install_venv(install_base, package_name, python_version='2'):
#
# combine_requirements --requirements-list a/requirements.txt;b/requirements.txt
# --output-file x/generated_requirements.txt
- generated_requirements = os.path.join(install_base, package_name + '-generated_requirements.txt')
+ generated_requirements = os.path.join(install_base,
+ package_name + '-generated_requirements.txt')
if ament_virtualenv_import_failed:
- combine_requirements_py = find_program(name='combine_requirements.py', package='ament_virtualenv')
+ combine_requirements_py = find_program(name='combine_requirements.py',
+ package='ament_virtualenv')
if not combine_requirements_py:
print("ERROR: Failed to locate combine_requirements", file=sys.stderr)
return 1
@@ -136,9 +142,9 @@ def install_venv(install_base, package_name, python_version='2'):
# '--use-system-packages',
'--extra-pip-args', '\"-qq\"',
]
- ret = subprocess.check_output(cmd)
+ subprocess.check_output(cmd)
else:
- ret = build_venv(
+ build_venv(
root_dir=venv_install_dir,
python_version=python_version,
requirements_filename=generated_requirements,
@@ -146,16 +152,17 @@ def install_venv(install_base, package_name, python_version='2'):
extra_pip_args="-qq",
retries=3
)
- #
+ #
# Wrapper shell executables we installed
for bin_file in os.listdir(bin_dir):
if bin_file[-5:] == '-venv':
- continue # possible left-over from last installation
+ # possible left-over from last installation
+ continue
# rename file from 'xxx' to 'xxx-venv'
bin_path = os.path.join(bin_dir, bin_file)
if not os.path.isfile(bin_path):
continue
- os.rename(bin_path, bin_path+'-venv')
+ os.rename(bin_path, bin_path + '-venv')
venv_rel_path = os.path.relpath(venv_install_dir, bin_dir)
# create new file with the name of the previous file
with open(bin_path, "w") as f:
@@ -166,7 +173,8 @@ def install_venv(install_base, package_name, python_version='2'):
f.write("if __name__ == '__main__':\n")
f.write(" dir_path = os.path.dirname(os.path.realpath(__file__))\n")
f.write(" bin_path = os.path.join(dir_path, '" + bin_file + "-venv')\n")
- f.write(" vpy_path = os.path.abspath(os.path.join(dir_path, '" + venv_rel_path +"'))\n")
+ f.write(" vpy_path = os.path.abspath(os.path.join(dir_path, '")
+ f.write(venv_rel_path + "'))\n")
f.write(" vpy_path = os.path.join(vpy_path, 'bin', 'python')\n")
f.write(" cmd = vpy_path + ' ' + bin_path\n")
f.write(" if len(sys.argv) > 1:\n")
@@ -178,6 +186,7 @@ def install_venv(install_base, package_name, python_version='2'):
#
return 0
+
def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser()
parser.add_argument('--install-base', required=True)
diff --git a/ament_virtualenv/ament_virtualenv/wrap_module.py b/ament_virtualenv/ament_virtualenv/wrap_module.py
index 5b7f042..a40e581 100644
--- a/ament_virtualenv/ament_virtualenv/wrap_module.py
+++ b/ament_virtualenv/ament_virtualenv/wrap_module.py
@@ -26,13 +26,14 @@
import sys
import argparse
+
def wrap_module(bin_path, venv_install_dir):
if not os.path.isfile(bin_path):
return -1
- bin_dir = os.path.dirname(bin_path)
+ bin_dir = os.path.dirname(bin_path)
bin_file = os.path.basename(bin_path)
# rename file from 'xxx' to 'xxx-venv'
- os.rename(bin_path, bin_path+'-venv')
+ os.rename(bin_path, bin_path + '-venv')
venv_rel_path = os.path.relpath(venv_install_dir, bin_dir)
# create new file with the name of the previous file
with open(bin_path, "w") as f:
@@ -43,7 +44,8 @@ def wrap_module(bin_path, venv_install_dir):
f.write("if __name__ == '__main__':\n")
f.write(" dir_path = os.path.dirname(os.path.realpath(__file__))\n")
f.write(" bin_path = os.path.join(dir_path, '" + bin_file + "-venv')\n")
- f.write(" vpy_path = os.path.abspath(os.path.join(dir_path, '" + venv_rel_path +"'))\n")
+ f.write(" vpy_path = os.path.abspath(os.path.join(dir_path, '")
+ f.write(venv_rel_path + "'))\n")
f.write(" vpy_path = os.path.join(vpy_path, 'bin', 'python')\n")
f.write(" cmd = vpy_path + ' ' + bin_path\n")
f.write(" if len(sys.argv) > 1:\n")
diff --git a/ament_virtualenv/ament_virtualenv/wrap_package.py b/ament_virtualenv/ament_virtualenv/wrap_package.py
index 8a66475..4199d9d 100644
--- a/ament_virtualenv/ament_virtualenv/wrap_package.py
+++ b/ament_virtualenv/ament_virtualenv/wrap_package.py
@@ -26,17 +26,20 @@
import sys
import argparse
+
def wrap_package(bin_dir, venv_install_dir):
for bin_file in os.listdir(bin_dir):
if bin_file[-3:] != '.py':
- continue # only wrap python files
+ # only wrap python files
+ continue
if bin_file[-5:] == '__.py':
- continue # don't wrap __init__.py etc
+ # don't wrap __init__.py etc
+ continue
bin_path = os.path.join(bin_dir, bin_file)
if not os.path.isfile(bin_path):
continue
# rename file from 'xxx.py' to 'xxx.py-venv'
- os.rename(bin_path, bin_path+'-venv')
+ os.rename(bin_path, bin_path + '-venv')
venv_rel_path = os.path.relpath(venv_install_dir, bin_dir)
# create new file with the name of the previous file
with open(bin_path, "w") as f:
@@ -47,7 +50,8 @@ def wrap_package(bin_dir, venv_install_dir):
f.write("if __name__ == '__main__':\n")
f.write(" dir_path = os.path.dirname(os.path.realpath(__file__))\n")
f.write(" bin_path = os.path.join(dir_path, '" + bin_file + "-venv')\n")
- f.write(" vpy_path = os.path.abspath(os.path.join(dir_path, '" + venv_rel_path +"'))\n")
+ f.write(" vpy_path = os.path.abspath(os.path.join(dir_path, '")
+ f.write(venv_rel_path + "'))\n")
f.write(" vpy_path = os.path.join(vpy_path, 'bin', 'python')\n")
f.write(" cmd = vpy_path + ' ' + bin_path\n")
f.write(" if len(sys.argv) > 1:\n")
diff --git a/ament_virtualenv/package.xml b/ament_virtualenv/package.xml
index 20d3cf8..68afc02 100644
--- a/ament_virtualenv/package.xml
+++ b/ament_virtualenv/package.xml
@@ -22,7 +22,7 @@ along with this program. If not, see .
-->
ament_virtualenv
- 0.0.4
+ 0.0.5
Bundle python requirements in a ament package via virtualenv.
Max Krichenbauer
diff --git a/ament_virtualenv/setup.py b/ament_virtualenv/setup.py
index e6c654a..d7ddce0 100644
--- a/ament_virtualenv/setup.py
+++ b/ament_virtualenv/setup.py
@@ -5,7 +5,7 @@
setup(
name=package_name,
- version='0.0.4',
+ version='0.0.5',
packages=find_packages(exclude=['test']),
data_files=[
('share/' + package_name, ['package.xml']),
diff --git a/test_ament_cmake_virtualenv/CHANGELOG.rst b/test_ament_cmake_virtualenv/CHANGELOG.rst
index 5b21f62..f304f8f 100644
--- a/test_ament_cmake_virtualenv/CHANGELOG.rst
+++ b/test_ament_cmake_virtualenv/CHANGELOG.rst
@@ -2,6 +2,10 @@
Changelog for package test_ament_cmake_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+0.0.5 (2020-01-10)
+------------------
+* fixed various bugs identified by CI
+
0.0.4 (2019-12-09)
------------------
* added fallbacks for different environments
diff --git a/test_ament_cmake_virtualenv/package.xml b/test_ament_cmake_virtualenv/package.xml
index 8113f4c..73184a8 100644
--- a/test_ament_cmake_virtualenv/package.xml
+++ b/test_ament_cmake_virtualenv/package.xml
@@ -22,7 +22,7 @@ along with this program. If not, see .
-->
test_ament_cmake_virtualenv
- 0.0.4
+ 0.0.5
Package to test ament_cmake_virtualenv
Max Krichenbauer
GPL
diff --git a/test_ament_virtualenv/CHANGELOG.rst b/test_ament_virtualenv/CHANGELOG.rst
index 9b06afb..e2c3ede 100644
--- a/test_ament_virtualenv/CHANGELOG.rst
+++ b/test_ament_virtualenv/CHANGELOG.rst
@@ -2,6 +2,10 @@
Changelog for package test_ament_virtualenv
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+0.0.5 (2020-01-10)
+------------------
+* fixed various bugs identified by CI
+
0.0.4 (2019-12-09)
------------------
* added fallbacks for different environments
diff --git a/test_ament_virtualenv/package.xml b/test_ament_virtualenv/package.xml
index 9cb2f16..4f89d4d 100644
--- a/test_ament_virtualenv/package.xml
+++ b/test_ament_virtualenv/package.xml
@@ -22,7 +22,7 @@ along with this program. If not, see .
-->
test_ament_virtualenv
- 0.0.4
+ 0.0.5
Package to test ament_virtualenv.
Max Krichenbauer
diff --git a/test_ament_virtualenv/setup.py b/test_ament_virtualenv/setup.py
index 1f89c97..4a84115 100644
--- a/test_ament_virtualenv/setup.py
+++ b/test_ament_virtualenv/setup.py
@@ -17,7 +17,7 @@ def run(self):
'install': InstallCommand
},
name=package_name,
- version='0.0.4',
+ version='0.0.5',
packages=[package_name],
data_files=[
('share/'+package_name, ['package.xml', 'requirements.txt']),