-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when overriding packages at build time (#449)
* First prototype warning on build of overridden packages Signed-off-by: Shane Loretz <[email protected]> * Add FindInstalledPackagesExtensionPoint and improve override warning text Signed-off-by: Shane Loretz <[email protected]> * its -> their Signed-off-by: Shane Loretz <[email protected]> * Fix CI Signed-off-by: Shane Loretz <[email protected]> * Update docstring of find_installed_packages Signed-off-by: Shane Loretz <[email protected]> * Make unit tests aware of FindInstalledPackagesExtensionPoint Signed-off-by: Shane Loretz <[email protected]> * Fix import order Signed-off-by: Shane Loretz <[email protected]> * Test raises NotImplementedError Signed-off-by: Shane Loretz <[email protected]> * Add extend action for older python versions Signed-off-by: Shane Loretz <[email protected]> * Flake8 tuple whitespace Signed-off-by: Shane Loretz <[email protected]> * Spellcheck extra words Signed-off-by: Shane Loretz <[email protected]> * Make override warning clearer Signed-off-by: Shane Loretz <[email protected]> * Grammar in path arg documentation Signed-off-by: Shane Loretz <[email protected]> * Check packages is not None Signed-off-by: Shane Loretz <[email protected]> * Test warning when extension reports package that doesn't exist Signed-off-by: Shane Loretz <[email protected]> * Test two extensions finding same package in same install base Signed-off-by: Shane Loretz <[email protected]> * Fix expected string on windows Signed-off-by: Shane Loretz <[email protected]> Co-authored-by: Scott K Logan <[email protected]>
- Loading branch information
Showing
6 changed files
with
326 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Copyright 2016-2021 Dirk Thomas | ||
# Licensed under the Apache License, Version 2.0 | ||
|
||
from pathlib import Path | ||
|
||
from colcon_core.location import get_relative_package_index_path | ||
from colcon_core.shell import FindInstalledPackagesExtensionPoint | ||
|
||
|
||
class IsolatedInstalledPackageFinder(FindInstalledPackagesExtensionPoint): | ||
"""Find installed packages in colcon isolated install spaces.""" | ||
|
||
def find_installed_packages(self, install_base: Path): | ||
"""Find installed packages in colcon isolated install spaces.""" | ||
marker_file = install_base / '.colcon_install_layout' | ||
if not marker_file.is_file(): | ||
return None | ||
install_layout = marker_file.read_text().rstrip() | ||
if install_layout != 'isolated': | ||
return None | ||
|
||
packages = {} | ||
# for each subdirectory look for the package specific file | ||
for p in install_base.iterdir(): | ||
if not p.is_dir(): | ||
continue | ||
if p.name.startswith('.'): | ||
continue | ||
marker = p / get_relative_package_index_path() / p.name | ||
if marker.is_file(): | ||
packages[p.name] = p | ||
return packages | ||
|
||
|
||
class MergedInstalledPackageFinder(FindInstalledPackagesExtensionPoint): | ||
"""Find installed packages in colcon merged install spaces.""" | ||
|
||
def find_installed_packages(self, install_base: Path): | ||
"""Find installed packages in colcon isolated install spaces.""" | ||
marker_file = install_base / '.colcon_install_layout' | ||
if not marker_file.is_file(): | ||
return None | ||
install_layout = marker_file.read_text().rstrip() | ||
if install_layout != 'merged': | ||
return None | ||
|
||
packages = {} | ||
# find all files in the subdirectory | ||
if (install_base / get_relative_package_index_path()).is_dir(): | ||
package_index = install_base / get_relative_package_index_path() | ||
for p in package_index.iterdir(): | ||
if not p.is_file(): | ||
continue | ||
if p.name.startswith('.'): | ||
continue | ||
packages[p.name] = install_base | ||
return packages |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.