Skip to content

Commit

Permalink
Deal with pip packages only if we need to.
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Lalancette <[email protected]>
  • Loading branch information
clalancette committed Mar 27, 2024
1 parent 0a62f49 commit c4a2025
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions ros2_batch_job/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ def need_package_from_pipy(pkg_name):

potential_pip_packages = pip_dependencies
if not args.colcon_branch:
pip_packages += colcon_packages
potential_pip_packages += colcon_packages

# We prefer to get packages from the distribution if they are already installed.
# If not, we add to the list to install from pip.
Expand Down Expand Up @@ -507,26 +507,27 @@ def need_package_from_pipy(pkg_name):
['"%s"' % job.python, '-m', 'pip', 'uninstall', '-y'] +
['cryptography', 'lxml', 'numpy'], shell=True)

print('Using constraints:')
print('\n'.join(constraints))
with open('constraints.txt', 'w') as outfp:
outfp.write('\n'.join(constraints) + '\n')

pip_cmd = ['"%s"' % job.python, '-m', 'pip', 'install', '-c', 'constraints.txt', '-U']
if sys.platform == 'win32':
# Force reinstall so all dependencies are in virtual environment
# On Windows since we switch between the debug and non-debug
# interpreter all packages need to be reinstalled too
pip_cmd.append('--force-reinstall')
else:
# We need to use --user so that certain packages (like flake8-blind-except)
# can successfully build on RHEL-8 (Humble).
if args.ros_distro == 'humble':
pip_cmd.append('--user')
if pip_packages:
print('Using constraints:')
print('\n'.join(constraints))
with open('constraints.txt', 'w') as outfp:
outfp.write('\n'.join(constraints) + '\n')

pip_cmd = ['"%s"' % job.python, '-m', 'pip', 'install', '-c', 'constraints.txt', '-U']
if sys.platform == 'win32':
# Force reinstall so all dependencies are in virtual environment
# On Windows since we switch between the debug and non-debug
# interpreter all packages need to be reinstalled too
pip_cmd.append('--force-reinstall')
else:
# We need to use --user so that certain packages (like flake8-blind-except)
# can successfully build on RHEL-8 (Humble).
if args.ros_distro == 'humble':
pip_cmd.append('--user')

job.run(
pip_cmd + pip_packages,
shell=True)
job.run(
pip_cmd + pip_packages,
shell=True)

vcs_cmd = ['vcs']

Expand Down

0 comments on commit c4a2025

Please sign in to comment.