pax_global_header00006660000000000000000000000064141716047210014515gustar00rootroot0000000000000052 comment=f8ea958fd02cff6f4192425e28566369c92b5e34 ament_package-0.14.0/000077500000000000000000000000001417160472100143565ustar00rootroot00000000000000ament_package-0.14.0/.flake8000066400000000000000000000001761417160472100155350ustar00rootroot00000000000000[flake8] extend-ignore = D100,D103,D104 import-order-style = google max-line-length = 99 show-source = true statistics = true ament_package-0.14.0/.gitignore000066400000000000000000000000531417160472100163440ustar00rootroot00000000000000*.pyc /ament_package.egg-info /build /dist ament_package-0.14.0/CHANGELOG.rst000066400000000000000000000162431417160472100164050ustar00rootroot00000000000000^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Changelog for package ament_package ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0.14.0 (2022-01-18) ------------------- 0.12.1 (2022-01-14) ------------------- * Set forthcoming for previous version * Add support for appending to environment variables (`#130 `_) This works largely the same as 'prepend-non-duplicate', but instead puts the candidate value at the end of the target variable. * Update maintainers to Audrow Nash (`#135 `_) * Make python executable variable ament_package specific (`#134 `_) * Contributors: Audrow Nash, Scott K Logan, Shane Loretz 0.12.0 (2022-01-14) ------------------- * Revert "Generate Setuptools Dict Helper Method (`#126 `_)" (`#131 `_) * Contributors: Audrow Nash 0.11.0 (2021-03-18) ------------------- * Generate Setuptools Dict Helper Method (`#126 `_) * Add Audrow as a maintainer (`#127 `_) * Contributors: Audrow Nash, David V. Lu!! 0.10.1 (2021-01-25) ------------------- * Support Python 3.8-provided importlib.metadata (`#124 `_) * Declare missing dependency on python3-importlib-resources (`#123 `_) * Contributors: Scott K Logan 0.10.0 (2020-12-07) ------------------- * make AMENT_TRACE_SETUP_FILES output sourceable (`#120 `_) * update maintainers * Switch ament_package to using importlib. (`#118 `_) * Add pytest.ini so local tests don't display warning (`#117 `_) * Contributors: Chris Lalancette, Dirk Thomas, Mabel Zhang 0.9.2 (2020-06-05) ------------------ * add configure-time flag to skip parent_prefix_path (`#115 `_) * Contributors: Dirk Thomas 0.9.1 (2020-05-12) ------------------ * [Windows] Fix _ament_python_executable fallback code path. (`#113 `_) * Contributors: Dirk Thomas 0.9.0 (2020-04-24) ------------------ * Convert format to f-string. (`#112 `_) * Contributors: Dirk Thomas 0.8.8 (2019-12-10) ------------------ * fix removing trailing semicolon logic in bat (`#111 `_) * Contributors: Dirk Thomas 0.8.7 (2019-12-05) ------------------ * fix handling of empty env var (`#110 `_) * Contributors: Dirk Thomas 0.8.6 (2019-12-04) ------------------ * improve error message when split for dsv line raises (`#108 `_) * skip empty lines in dsv files (`#107 `_) * fix performance regression in environment setup (`#106 `_) * Contributors: Dirk Thomas 0.8.5 (2019-11-08) ------------------ * Fix sh command to remove trailing separator (`#105 `_) * Always prepend with a trailing separator (`#104 `_) * Contributors: Jacob Perron 0.8.4 (2019-10-23) ------------------ * add dsv type set-if-unset (`#102 `_) * Add support for prepending multiple values to env variables from .dsv files (`#101 `_) * Contributors: Dirk Thomas, Jacob Perron, Shane Loretz 0.8.3 (2019-10-11) ------------------ * add type 'set' for dsv files (`#95 `_) * keep using default ignore list (`#96 `_) * Contributors: Dirk Thomas 0.8.2 (2019-10-04 15:45) ------------------------ * provide ament_prepend_unique_value function in prefix level sh script (`#94 `_) * Contributors: Dirk Thomas 0.8.1 (2019-10-04 14:34) ------------------------ * fix reading the package run dependencies (`#93 `_) * if no package.dsv is available fallback to a local_setup file (`#92 `_) * Contributors: Dirk Thomas 0.8.0 (2019-10-04 10:32) ------------------------ * perform environment calculation in Python (`#89 `_) * escape closing parenthesis in local_setup.bat file (`#91 `_) * add quotes around ament_python_executable variable in local_setup.bat (`#90 `_) * fix pytest warning about unknown markers (`#88 `_) * install resource marker file for package (`#87 `_) * Contributors: Dirk Thomas 0.7.2 (2019-09-18) ------------------ * install package manifest (`#86 `_) * Contributors: Dirk Thomas 0.7.1 (2019-08-21) ------------------ * add warning/fallback for AMENT_CURRENT_PREFIX if relocated (`#85 `_) * Contributors: Dirk Thomas 0.7.0 (2019-04-08) ------------------ * add section about DCO to CONTRIBUTING.md * Contributors: Dirk Thomas 0.6.0 (2018-11-13) ------------------ * Fix lint warnings from invalid escape sequences (`#82 `_) * Contributors: Jacob Perron 0.5.2 (2018-07-19) ------------------ * fix custom zsh logic for handling arrays (`#80 `_) * Contributors: Dirk Thomas 0.5.1 (2018-06-14) ------------------ * Use flake8 directly (`#77 `_) * Drop dependency on pyparsing. (`#78 `_) * Contributors: Steven! Ragnarök 0.5.0 (2018-06-13) ------------------ * remove all Python modules by the templates (`#75 `_) * add pytest markers to linter tests * support file attribution of license tag (`#73 `_) * set zip_safe to avoid warning during installation (`#72 `_) * Revert "Revert "consider condition for group membership (`#69 `_)" (`#70 `_)" (`#71 `_) * Revert "consider condition for group membership (`#69 `_)" (`#70 `_) * consider condition for group membership (`#69 `_) * fix copyright year * Contributors: Dirk Thomas, Mikael Arguedas, Tamaki Nishino ament_package-0.14.0/CONTRIBUTING.md000066400000000000000000000016231417160472100166110ustar00rootroot00000000000000Any contribution that you make to this repository will be under the Apache 2 License, as dictated by that [license](http://www.apache.org/licenses/LICENSE-2.0.html): ~~~ 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. ~~~ Contributors must sign-off each commit by adding a `Signed-off-by: ...` line to commit messages to certify that they have the right to submit the code they are contributing to the project according to the [Developer Certificate of Origin (DCO)](https://developercertificate.org/). ament_package-0.14.0/LICENSE000066400000000000000000000261361417160472100153730ustar00rootroot00000000000000 Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives. Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ament_package-0.14.0/ament_package/000077500000000000000000000000001417160472100171355ustar00rootroot00000000000000ament_package-0.14.0/ament_package/__init__.py000066400000000000000000000020601417160472100212440ustar00rootroot00000000000000# Copyright 2014 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. """Package providing the templates for various shell scripts.""" # set version number try: try: import importlib.metadata as importlib_metadata except ModuleNotFoundError: import importlib_metadata try: __version__ = importlib_metadata.version('ament_package') except importlib_metadata.PackageNotFoundError: __version__ = 'unset' finally: del importlib_metadata except ImportError: __version__ = 'unset' ament_package-0.14.0/ament_package/template/000077500000000000000000000000001417160472100207505ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/__init__.py000066400000000000000000000000001417160472100230470ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/environment_hook/000077500000000000000000000000001417160472100243345ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/environment_hook/__init__.py000066400000000000000000000000001417160472100264330ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/environment_hook/ament_prefix_path.bat000066400000000000000000000021361417160472100305230ustar00rootroot00000000000000:: copied from ament_package/template/environment_hook/ament_prefix_path.bat @echo off call:ament_prepend_unique_value AMENT_PREFIX_PATH "%AMENT_CURRENT_PREFIX%" goto:eof :: Prepend non-duplicate values to environment variables :: using semicolons as separators and avoiding trailing separators. :: first argument: the name of the result variable :: second argument: the value :ament_prepend_unique_value setlocal enabledelayedexpansion :: arguments set "listname=%~1" set "value=%~2" :: skip if path doesn't exist if NOT EXIST "%value%" ( goto:eof ) :: expand the list variable set "list=!%listname%!" :: check if the list contains the value set "is_duplicate=" if "%list%" NEQ "" ( for %%v in ("%list:;=";"%") do ( if "%%~v" == "%value%" set "is_duplicate=1" ) ) :: if it is not a duplicate prepend it if "%is_duplicate%" == "" ( :: if not empty, prepend a semi-colon if "!list!" NEQ "" set "list=;!list!" :: prepend the value set "list=%value%!list!" ) endlocal & ( :: set result variable in parent scope set "%~1=%list%" ) goto:eof ament_package-0.14.0/ament_package/template/environment_hook/ament_prefix_path.sh000066400000000000000000000002211417160472100303600ustar00rootroot00000000000000# copied from ament_package/template/environment_hook/ament_prefix_path.sh ament_prepend_unique_value AMENT_PREFIX_PATH "$AMENT_CURRENT_PREFIX" ament_package-0.14.0/ament_package/template/environment_hook/library_path.sh000066400000000000000000000006331417160472100273520ustar00rootroot00000000000000# copied from ament_package/template/environment_hook/library_path.sh # detect if running on Darwin platform _UNAME=`uname -s` _IS_DARWIN=0 if [ "$_UNAME" = "Darwin" ]; then _IS_DARWIN=1 fi unset _UNAME if [ $_IS_DARWIN -eq 0 ]; then ament_prepend_unique_value LD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib" else ament_prepend_unique_value DYLD_LIBRARY_PATH "$AMENT_CURRENT_PREFIX/lib" fi unset _IS_DARWIN ament_package-0.14.0/ament_package/template/environment_hook/path.bat000066400000000000000000000022161417160472100257610ustar00rootroot00000000000000:: copied from ament_package/template/environment_hook/path.bat @echo off call:ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\bin" call:ament_prepend_unique_value PATH "%AMENT_CURRENT_PREFIX%\Scripts" goto:eof :: Prepend non-duplicate values to environment variables :: using semicolons as separators and avoiding trailing separators. :: first argument: the name of the result variable :: second argument: the value :ament_prepend_unique_value setlocal enabledelayedexpansion :: arguments set "listname=%~1" set "value=%~2" :: skip if path doesn't exist if NOT EXIST "%value%" ( goto:eof ) :: expand the list variable set "list=!%listname%!" :: check if the list contains the value set "is_duplicate=" if "%list%" NEQ "" ( for %%v in ("%list:;=";"%") do ( if "%%~v" == "%value%" set "is_duplicate=1" ) ) :: if it is not a duplicate prepend it if "%is_duplicate%" == "" ( :: if not empty, prepend a semi-colon if "!list!" NEQ "" set "list=;!list!" :: prepend the value set "list=%value%!list!" ) endlocal & ( :: set result variable in parent scope set "%~1=%list%" ) goto:eof ament_package-0.14.0/ament_package/template/environment_hook/path.sh000066400000000000000000000001731417160472100256250ustar00rootroot00000000000000# copied from ament_package/template/environment_hook/path.sh ament_prepend_unique_value PATH "$AMENT_CURRENT_PREFIX/bin" ament_package-0.14.0/ament_package/template/environment_hook/pkg_config_path.bat000066400000000000000000000021501417160472100301440ustar00rootroot00000000000000:: copied from ament_package/template/environment_hook/pkg_config_path.bat @echo off call:ament_prepend_unique_value PKG_CONFIG_PATH "%AMENT_CURRENT_PREFIX%\lib\pkgconfig" goto:eof :: Prepend non-duplicate values to environment variables :: using semicolons as separators and avoiding trailing separators. :: first argument: the name of the result variable :: second argument: the value :ament_prepend_unique_value setlocal enabledelayedexpansion :: arguments set "listname=%~1" set "value=%~2" :: skip if path doesn't exist if NOT EXIST "%value%" ( goto:eof ) :: expand the list variable set "list=!%listname%!" :: check if the list contains the value set "is_duplicate=" if "%list%" NEQ "" ( for %%v in ("%list:;=";"%") do ( if "%%~v" == "%value%" set "is_duplicate=1" ) ) :: if it is not a duplicate prepend it if "%is_duplicate%" == "" ( :: if not empty, prepend a semi-colon if "!list!" NEQ "" set "list=;!list!" :: prepend the value set "list=%value%!list!" ) endlocal & ( :: set result variable in parent scope set "%~1=%list%" ) goto:eof ament_package-0.14.0/ament_package/template/environment_hook/pkg_config_path.sh000066400000000000000000000002331417160472100300100ustar00rootroot00000000000000# copied from ament_package/template/environment_hook/pkg_config_path.sh ament_prepend_unique_value PKG_CONFIG_PATH "$AMENT_CURRENT_PREFIX/lib/pkgconfig" ament_package-0.14.0/ament_package/template/environment_hook/pythonpath.bat.in000066400000000000000000000021531417160472100276300ustar00rootroot00000000000000:: generated from ament_package/template/environment_hook/pythonpath.bat.in @echo off call:ament_prepend_unique_value PYTHONPATH "%AMENT_CURRENT_PREFIX%\@PYTHON_INSTALL_DIR@" goto:eof :: Prepend non-duplicate values to environment variables :: using semicolons as separators and avoiding trailing separators. :: first argument: the name of the result variable :: second argument: the value :ament_prepend_unique_value setlocal enabledelayedexpansion :: arguments set "listname=%~1" set "value=%~2" :: skip if path doesn't exist if NOT EXIST "%value%" ( goto:eof ) :: expand the list variable set "list=!%listname%!" :: check if the list contains the value set "is_duplicate=" if "%list%" NEQ "" ( for %%v in ("%list:;=";"%") do ( if "%%~v" == "%value%" set "is_duplicate=1" ) ) :: if it is not a duplicate prepend it if "%is_duplicate%" == "" ( :: if not empty, prepend a semi-colon if "!list!" NEQ "" set "list=;!list!" :: prepend the value set "list=%value%!list!" ) endlocal & ( :: set result variable in parent scope set "%~1=%list%" ) goto:eof ament_package-0.14.0/ament_package/template/environment_hook/pythonpath.sh.in000066400000000000000000000002361417160472100274740ustar00rootroot00000000000000# generated from ament_package/template/environment_hook/pythonpath.sh.in ament_prepend_unique_value PYTHONPATH "$AMENT_CURRENT_PREFIX/@PYTHON_INSTALL_DIR@" ament_package-0.14.0/ament_package/template/isolated_prefix_level/000077500000000000000000000000001417160472100253205ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/isolated_prefix_level/__init__.py000066400000000000000000000000001417160472100274170ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/isolated_prefix_level/_order_isolated_packages.py000066400000000000000000000046271417160472100326770ustar00rootroot00000000000000#!/usr/bin/env python3 # Copyright 2014 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import argparse import os import sys def main(argv=sys.argv[1:]): """Get the package names in an isolated install space in topolog. order.""" parser = argparse.ArgumentParser( description='Find all package names in an isolated install space and ' 'order them topologically based on the run dependencies', ) parser.add_argument( 'root', help='The root of the isolated install space', ) args = parser.parse_args(argv) package_names = [d for d in os.listdir(args.root) if os.path.isdir(os.path.join(args.root, d))] run_dependencies = {} for pkg_name in package_names: run_dependencies[pkg_name] = [] marker_file = os.path.join( args.root, pkg_name, 'share', 'ament_index', 'resource_index', 'package_run_dependencies', pkg_name) if os.path.exists(marker_file): with open(marker_file, 'r') as h: run_dependencies[pkg_name] = \ [d for d in h.read().split(';') if d in package_names] # select packages with no dependencies in alphabetical order to_be_ordered = list(package_names) ordered = [] while to_be_ordered: pkg_name_without_deps = [ name for name in to_be_ordered if not run_dependencies[name]] if not pkg_name_without_deps: assert False pkg_name_without_deps.sort() pkg_name = pkg_name_without_deps[0] to_be_ordered.remove(pkg_name) ordered.append(pkg_name) # remove item from dependency lists for k in list(run_dependencies.keys()): if pkg_name in run_dependencies[k]: run_dependencies[k].remove(pkg_name) for name in ordered: print(name) if __name__ == '__main__': main() ament_package-0.14.0/ament_package/template/isolated_prefix_level/local_setup.bash000066400000000000000000000005751417160472100305000ustar00rootroot00000000000000# copied from ament_package/template/isolated_prefix_path/local_setup.bash AMENT_SHELL=bash # source local_setup.sh from same directory as this file AMENT_CURRENT_PREFIX=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" && pwd) # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$AMENT_CURRENT_PREFIX/local_setup.sh\"" fi . "$AMENT_CURRENT_PREFIX/local_setup.sh" ament_package-0.14.0/ament_package/template/isolated_prefix_level/local_setup.bat.in000066400000000000000000000040611417160472100307300ustar00rootroot00000000000000:: generated from ament_package/template/isolated_prefix_level/local_setup.bat.in @echo off :: get all packages in topological order call:ament_get_ordered_packages _ordered_packages "%~dp0" :: source local_setup.bat file for each package if "%_ordered_packages%" NEQ "" ( for %%p in ("%_ordered_packages:;=";"%") do ( :: bypass prefix-level local_setup file for performance reasons call:call_file "%~dp0%%~p\share\%%~p\local_setup.bat" ) set "_ordered_packages=" ) goto:eof :: Get the package names in topological order :: using semicolons as separators and avoiding leading separators. :: first argument: the name of the result variable :: second argument: the base path to look for packages :ament_get_ordered_packages setlocal enabledelayedexpansion :: use the Python executable known at configure time set "_ament_python_executable=@PYTHON_EXECUTABLE@" :: allow overriding it with a custom location if "%AMENT_PYTHON_EXECUTABLE%" NEQ "" ( set "_ament_python_executable=%AMENT_PYTHON_EXECUTABLE%" ) if NOT exist "%_ament_python_executable%" ( for %%I in (python.exe) do ( if "%%~$PATH:I" NEQ "" set "_ament_python_executable=%%~$PATH:I" ) ) if NOT exist "%_ament_python_executable%" ( echo "Could not find Python executable: either add the folder of the Python executable (e.g. installed with Chocolatey) to the PATH variable or explicitly set the environment variable AMENT_PYTHON_EXECUTABLE to the full path of the Python executable" goto:eof ) set "ordered_packages=" for /f %%p in ('""%_ament_python_executable%" "%~dp0_order_isolated_packages.py" "%~2\""') do ( if "!ordered_packages!" NEQ "" set "ordered_packages=!ordered_packages!;" set "ordered_packages=!ordered_packages!%%p" ) endlocal & ( :: set result variable in parent scope set "%~1=%ordered_packages%" ) goto:eof :: Call the specified batch file and output the name when tracing is requested. :: first argument: the batch file :call_file if "%AMENT_TRACE_SETUP_FILES%" NEQ "" echo call "%~1" if exist "%~1" call "%~1%" goto:eof ament_package-0.14.0/ament_package/template/isolated_prefix_level/local_setup.sh.in000066400000000000000000000037721417160472100306040ustar00rootroot00000000000000# generated from ament_package/template/isolated_prefix_level/local_setup.sh.in # since this file is sourced use either the provided AMENT_CURRENT_PREFIX # or fall back to the destination set at configure time : ${AMENT_CURRENT_PREFIX:=@CMAKE_INSTALL_PREFIX@} # set type of shell if not already set : ${AMENT_SHELL:=sh} # use the Python executable known at configure time _ament_python_executable="@PYTHON_EXECUTABLE@" # allow overriding it with a custom location if [ -n "$AMENT_PYTHON_EXECUTABLE" ]; then _ament_python_executable="$AMENT_PYTHON_EXECUTABLE" fi # if the Python executable doesn't exist try another fall back if [ ! -f "$_ament_python_executable" ]; then _ament_python_executable="/usr/bin/env python3" fi # get all packages in topological order _ORDERED_PACKAGES="$($_ament_python_executable "$AMENT_CURRENT_PREFIX/_order_isolated_packages.py" "$AMENT_CURRENT_PREFIX")" unset _ament_python_executable # source prefix-level local_setup.EXT or local_setup.sh file for each package _isolated_prefix_local_setup_IFS=$IFS IFS=" " # store AMENT_CURRENT_PREFIX to restore it before each package _isolated_prefix_local_setup_AMENT_CURRENT_PREFIX=$AMENT_CURRENT_PREFIX if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _ORDERED_PACKAGES fi for _package in $_ORDERED_PACKAGES; do # restore AMENT_CURRENT_PREFIX for each prefix-level local_setup file AMENT_CURRENT_PREFIX="$_isolated_prefix_local_setup_AMENT_CURRENT_PREFIX/$_package" # restore IFS before sourcing other files IFS=$_isolated_prefix_local_setup_IFS # bypass prefix-level local_setup file for performance reasons _path="$AMENT_CURRENT_PREFIX/share/$_package/local_setup.$AMENT_SHELL" # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$_path\"" fi if [ -f "$_path" ]; then . "$_path" fi unset _path done unset _package unset _ORDERED_PACKAGES unset _isolated_prefix_local_setup_AMENT_CURRENT_PREFIX IFS=$_isolated_prefix_local_setup_IFS unset _isolated_prefix_local_setup_IFS unset AMENT_CURRENT_PREFIX ament_package-0.14.0/ament_package/template/isolated_prefix_level/local_setup.zsh000066400000000000000000000012171417160472100303610ustar00rootroot00000000000000# copied from ament_package/template/isolated_prefix_level/local_setup.zsh AMENT_SHELL=zsh # source local_setup.sh from same directory as this file AMENT_CURRENT_PREFIX=$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd) # function to convert array-like strings into arrays # to wordaround SH_WORD_SPLIT not being set ament_zsh_to_array() { local _listname=$1 local _dollar="$" local _split="{=" local _to_array="(\"$_dollar$_split$_listname}\")" eval $_listname=$_to_array } # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$AMENT_CURRENT_PREFIX/local_setup.sh\"" fi . "$AMENT_CURRENT_PREFIX/local_setup.sh" ament_package-0.14.0/ament_package/template/package_level/000077500000000000000000000000001417160472100235325ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/package_level/__init__.py000066400000000000000000000000001417160472100256310ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/package_level/local_setup.bash.in000066400000000000000000000031151417160472100273100ustar00rootroot00000000000000# generated from ament_package/template/package_level/local_setup.bash.in # source local_setup.sh from same directory as this file _this_path=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" && pwd) # provide AMENT_CURRENT_PREFIX to shell script AMENT_CURRENT_PREFIX=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`/../.." && pwd) # store AMENT_CURRENT_PREFIX to restore it before each environment hook _package_local_setup_AMENT_CURRENT_PREFIX=$AMENT_CURRENT_PREFIX # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$_this_path/local_setup.sh\"" fi . "$_this_path/local_setup.sh" unset _this_path # unset AMENT_ENVIRONMENT_HOOKS # if not appending to them for return if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then unset AMENT_ENVIRONMENT_HOOKS fi # restore AMENT_CURRENT_PREFIX before evaluating the environment hooks AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX # list all environment hooks of this package @ENVIRONMENT_HOOKS@ # source all shell-specific environment hooks of this package # if not returning them if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then _package_local_setup_IFS=$IFS IFS=":" for _hook in $AMENT_ENVIRONMENT_HOOKS; do # restore AMENT_CURRENT_PREFIX for each environment hook AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX # restore IFS before sourcing other files IFS=$_package_local_setup_IFS . "$_hook" done unset _hook IFS=$_package_local_setup_IFS unset _package_local_setup_IFS unset AMENT_ENVIRONMENT_HOOKS fi unset _package_local_setup_AMENT_CURRENT_PREFIX unset AMENT_CURRENT_PREFIX ament_package-0.14.0/ament_package/template/package_level/local_setup.bat.in000066400000000000000000000045741417160472100271530ustar00rootroot00000000000000:: generated from ament_package/template/package_level/local_setup.bat.in @echo off :: the current prefix is two levels up from the package specific share folder for %%p in ("%~dp0..\..") do set "AMENT_CURRENT_PREFIX=%%~fp" :: always start with an empty list of environment hooks for this package set "AMENT_ENVIRONMENT_HOOKS[@PROJECT_NAME@]=" :: these are the environment hooks of this package @ENVIRONMENT_HOOKS@ :: if not returning the environment hooks to the parent scope if not defined AMENT_RETURN_ENVIRONMENT_HOOKS ( :: source all environment hooks of this package for %%f in ("%AMENT_ENVIRONMENT_HOOKS[@PROJECT_NAME@]:;=";"%") do ( call:call_file %%f ) set "AMENT_ENVIRONMENT_HOOKS[@PROJECT_NAME@]=" ) set "AMENT_CURRENT_PREFIX=" goto:eof :: Append values to environment variables :: using semicolons as separators and avoiding leading separators. :: first argument: the name of the result variable :: second argument: the value :ament_append_value setlocal enabledelayedexpansion :: arguments set "listname=%~1" set "value=%~2" :: expand the list variable set "list=!%listname%!" :: if not empty, append a semi-colon if "!list!" NEQ "" set "list=!list!;" :: append the value set "list=!list!%value%" ) endlocal & ( :: set result variable in parent scope set "%~1=%list%" ) goto:eof :: Append non-duplicate values to environment variables :: using semicolons as separators and avoiding trailing separators. :: first argument: the name of the result variable :: second argument: the value :ament_append_unique_value setlocal enabledelayedexpansion :: arguments set "listname=%~1" set "value=%~2" :: expand the list variable set "list=!%listname%!" :: check if the list contains the value set "is_duplicate=" if "%list%" NEQ "" ( for %%v in ("%list:;=";"%") do ( if "%%~v" == "%value%" set "is_duplicate=1" ) ) :: if it is not a duplicate append it if "%is_duplicate%" == "" ( :: if not empty, append a semi-colon if "!list!" NEQ "" set "list=!list!;" :: append the value set "list=!list!%value%" ) endlocal & ( :: set result variable in parent scope set "%~1=%list%" ) goto:eof :: Call the specified batch file and output the name when tracing is requested. :: first argument: the batch file :call_file if "%AMENT_TRACE_SETUP_FILES%" NEQ "" echo call "%~1" if exist "%~1" call "%~1%" goto:eof ament_package-0.14.0/ament_package/template/package_level/local_setup.sh.in000066400000000000000000000112661417160472100270130ustar00rootroot00000000000000# generated from ament_package/template/package_level/local_setup.sh.in # since this file is sourced use either the provided AMENT_CURRENT_PREFIX # or fall back to the destination set at configure time : ${AMENT_CURRENT_PREFIX:="@CMAKE_INSTALL_PREFIX@"} if [ ! -d "$AMENT_CURRENT_PREFIX" ]; then if [ -z "$COLCON_CURRENT_PREFIX" ]; then echo "The compile time prefix path '$AMENT_CURRENT_PREFIX' doesn't " \ "exist. Consider sourcing a different extension than '.sh'." 1>&2 else AMENT_CURRENT_PREFIX="$COLCON_CURRENT_PREFIX" fi fi # function to append values to environment variables # using colons as separators and avoiding leading separators ament_append_value() { # arguments _listname="$1" _value="$2" #echo "listname $_listname" #eval echo "list value \$$_listname" #echo "value $_value" # avoid leading separator eval _values=\"\$$_listname\" if [ -z "$_values" ]; then eval export $_listname=\"$_value\" #eval echo "set list \$$_listname" else # field separator must not be a colon _ament_append_value_IFS=$IFS unset IFS eval export $_listname=\"\$$_listname:$_value\" #eval echo "append list \$$_listname" IFS=$_ament_append_value_IFS unset _ament_append_value_IFS fi unset _values unset _value unset _listname } # function to append non-duplicate values to environment variables # using colons as separators and avoiding leading separators ament_append_unique_value() { # arguments _listname=$1 _value=$2 #echo "listname $_listname" #eval echo "list value \$$_listname" #echo "value $_value" # check if the list contains the value eval _values=\$$_listname _duplicate= _ament_append_unique_value_IFS=$IFS IFS=":" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _values fi for _item in $_values; do # ignore empty strings if [ -z "$_item" ]; then continue fi if [ $_item = $_value ]; then _duplicate=1 fi done unset _item # append only non-duplicates if [ -z "$_duplicate" ]; then # avoid leading separator if [ -z "$_values" ]; then eval $_listname=\"$_value\" #eval echo "set list \$$_listname" else # field separator must not be a colon unset IFS eval $_listname=\"\$$_listname:$_value\" #eval echo "append list \$$_listname" fi fi IFS=$_ament_append_unique_value_IFS unset _ament_append_unique_value_IFS unset _duplicate unset _values unset _value unset _listname } # function to prepend non-duplicate values to environment variables # using colons as separators and avoiding trailing separators ament_prepend_unique_value() { # arguments _listname="$1" _value="$2" #echo "listname $_listname" #eval echo "list value \$$_listname" #echo "value $_value" # check if the list contains the value eval _values=\"\$$_listname\" _duplicate= _ament_prepend_unique_value_IFS=$IFS IFS=":" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _values fi for _item in $_values; do # ignore empty strings if [ -z "$_item" ]; then continue fi if [ "$_item" = "$_value" ]; then _duplicate=1 fi done unset _item # prepend only non-duplicates if [ -z "$_duplicate" ]; then # avoid trailing separator if [ -z "$_values" ]; then eval export $_listname=\"$_value\" #eval echo "set list \$$_listname" else # field separator must not be a colon unset IFS eval export $_listname=\"$_value:\$$_listname\" #eval echo "prepend list \$$_listname" fi fi IFS=$_ament_prepend_unique_value_IFS unset _ament_prepend_unique_value_IFS unset _duplicate unset _values unset _value unset _listname } # unset AMENT_ENVIRONMENT_HOOKS # if not appending to them for return if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then unset AMENT_ENVIRONMENT_HOOKS fi # list all environment hooks of this package @ENVIRONMENT_HOOKS@ # source all shell-specific environment hooks of this package # if not returning them if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then _package_local_setup_IFS=$IFS IFS=":" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array AMENT_ENVIRONMENT_HOOKS fi for _hook in $AMENT_ENVIRONMENT_HOOKS; do if [ -f "$_hook" ]; then # restore IFS before sourcing other files IFS=$_package_local_setup_IFS # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$_hook\"" fi . "$_hook" fi done unset _hook IFS=$_package_local_setup_IFS unset _package_local_setup_IFS unset AMENT_ENVIRONMENT_HOOKS fi # reset AMENT_CURRENT_PREFIX after each package # allowing to source multiple package-level setup files unset AMENT_CURRENT_PREFIX ament_package-0.14.0/ament_package/template/package_level/local_setup.zsh.in000066400000000000000000000036701417160472100272050ustar00rootroot00000000000000# generated from ament_package/template/package_level/local_setup.zsh.in AMENT_SHELL=zsh # source local_setup.sh from same directory as this file _this_path=$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd) # provide AMENT_CURRENT_PREFIX to shell script AMENT_CURRENT_PREFIX=$(builtin cd -q "`dirname "${(%):-%N}"`/../.." > /dev/null && pwd) # store AMENT_CURRENT_PREFIX to restore it before each environment hook _package_local_setup_AMENT_CURRENT_PREFIX=$AMENT_CURRENT_PREFIX # function to convert array-like strings into arrays # to wordaround SH_WORD_SPLIT not being set ament_zsh_to_array() { local _listname=$1 local _dollar="$" local _split="{=" local _to_array="(\"$_dollar$_split$_listname}\")" eval $_listname=$_to_array } # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$_this_path/local_setup.sh\"" fi # the package-level local_setup file unsets AMENT_CURRENT_PREFIX . "$_this_path/local_setup.sh" unset _this_path # unset AMENT_ENVIRONMENT_HOOKS # if not appending to them for return if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then unset AMENT_ENVIRONMENT_HOOKS fi # restore AMENT_CURRENT_PREFIX before evaluating the environment hooks AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX # list all environment hooks of this package @ENVIRONMENT_HOOKS@ # source all shell-specific environment hooks of this package # if not returning them if [ -z "$AMENT_RETURN_ENVIRONMENT_HOOKS" ]; then _package_local_setup_IFS=$IFS IFS=":" for _hook in $AMENT_ENVIRONMENT_HOOKS; do # restore AMENT_CURRENT_PREFIX for each environment hook AMENT_CURRENT_PREFIX=$_package_local_setup_AMENT_CURRENT_PREFIX # restore IFS before sourcing other files IFS=$_package_local_setup_IFS . "$_hook" done unset _hook IFS=$_package_local_setup_IFS unset _package_local_setup_IFS unset AMENT_ENVIRONMENT_HOOKS fi unset _package_local_setup_AMENT_CURRENT_PREFIX unset AMENT_CURRENT_PREFIX ament_package-0.14.0/ament_package/template/prefix_level/000077500000000000000000000000001417160472100234345ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/prefix_level/__init__.py000066400000000000000000000000001417160472100255330ustar00rootroot00000000000000ament_package-0.14.0/ament_package/template/prefix_level/_local_setup_util.py000066400000000000000000000367041417160472100275260ustar00rootroot00000000000000# Copyright 2016-2019 Dirk Thomas # Copyright 2019 Open Source Robotics Foundation, Inc. # Licensed under the Apache License, Version 2.0 import argparse from collections import OrderedDict import os from pathlib import Path import sys FORMAT_STR_COMMENT_LINE = None FORMAT_STR_SET_ENV_VAR = None FORMAT_STR_USE_ENV_VAR = None FORMAT_STR_INVOKE_SCRIPT = None FORMAT_STR_REMOVE_TRAILING_SEPARATOR = None DSV_TYPE_APPEND_NON_DUPLICATE = 'append-non-duplicate' DSV_TYPE_PREPEND_NON_DUPLICATE = 'prepend-non-duplicate' DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS = 'prepend-non-duplicate-if-exists' DSV_TYPE_SET = 'set' DSV_TYPE_SET_IF_UNSET = 'set-if-unset' DSV_TYPE_SOURCE = 'source' def main(argv=sys.argv[1:]): # noqa: D103 global FORMAT_STR_COMMENT_LINE global FORMAT_STR_SET_ENV_VAR global FORMAT_STR_USE_ENV_VAR global FORMAT_STR_INVOKE_SCRIPT global FORMAT_STR_REMOVE_LEADING_SEPARATOR global FORMAT_STR_REMOVE_TRAILING_SEPARATOR parser = argparse.ArgumentParser( description='Output shell commands for the packages in topological ' 'order') parser.add_argument( 'primary_extension', help='The file extension of the primary shell') parser.add_argument( 'additional_extension', nargs='?', help='The additional file extension to be considered') args = parser.parse_args(argv) if args.primary_extension == 'sh': FORMAT_STR_COMMENT_LINE = '# {comment}' FORMAT_STR_SET_ENV_VAR = 'export {name}="{value}"' FORMAT_STR_USE_ENV_VAR = '${name}' FORMAT_STR_INVOKE_SCRIPT = 'AMENT_CURRENT_PREFIX="{prefix}" ' \ '_ament_prefix_sh_source_script "{script_path}"' FORMAT_STR_REMOVE_LEADING_SEPARATOR = 'if [ "$(echo -n ${name} | ' \ 'head -c 1)" = ":" ]; then export {name}=${{{name}#?}} ; fi' FORMAT_STR_REMOVE_TRAILING_SEPARATOR = 'if [ "$(echo -n ${name} | ' \ 'tail -c 1)" = ":" ]; then export {name}=${{{name}%?}} ; fi' elif args.primary_extension == 'bat': FORMAT_STR_COMMENT_LINE = ':: {comment}' FORMAT_STR_SET_ENV_VAR = 'set "{name}={value}"' FORMAT_STR_USE_ENV_VAR = '%{name}%' FORMAT_STR_INVOKE_SCRIPT = \ 'call:_ament_prefix_bat_call_script "{script_path}"' # can't use `if` here since each line is being `call`-ed FORMAT_STR_REMOVE_LEADING_SEPARATOR = \ 'call:_ament_prefix_bat_strip_leading_semicolon "{name}"' FORMAT_STR_REMOVE_TRAILING_SEPARATOR = \ 'call:_ament_prefix_bat_strip_trailing_semicolon "{name}"' else: assert False, 'Unknown primary extension: ' + args.primary_extension packages = get_packages(Path(__file__).parent) ordered_packages = order_packages(packages) for pkg_name in ordered_packages: if _include_comments(): print( FORMAT_STR_COMMENT_LINE.format_map( {'comment': 'Package: ' + pkg_name})) prefix = os.path.abspath(os.path.dirname(__file__)) for line in get_commands( pkg_name, prefix, args.primary_extension, args.additional_extension ): print(line) for line in _remove_ending_separators(): print(line) def get_packages(prefix_path): """ Find packages based on ament resource files created during installation. :param Path prefix_path: The install prefix path of all packages :returns: A mapping from the package name to the set of runtime dependencies :rtype: dict """ packages = {} # since importing ament_index_python isn't feasible here the following # constant must match ament_index_python.constants.RESOURCE_INDEX_SUBFOLDER subdirectory = 'share/ament_index/resource_index/packages' # return if workspace is empty if not (prefix_path / subdirectory).is_dir(): return packages # find all files in the subdirectory for p in (prefix_path / subdirectory).iterdir(): if not p.is_file(): continue if p.name.startswith('.'): continue add_package_runtime_dependencies(p, packages) # remove unknown dependencies pkg_names = set(packages.keys()) for k in packages.keys(): packages[k] = {d for d in packages[k] if d in pkg_names} return packages def add_package_runtime_dependencies(path, packages): """ Check the path and if it exists extract the packages runtime dependencies. :param Path path: The resource file containing the runtime dependencies :param dict packages: A mapping from package names to the sets of runtime dependencies to add to """ dependencies = set() marker_file = path.parents[1] / 'package_run_dependencies' / path.name if marker_file.exists(): content = marker_file.read_text() dependencies = set(content.split(';') if content else []) packages[marker_file.name] = dependencies def order_packages(packages): """ Order packages topologically. :param dict packages: A mapping from package name to the set of runtime dependencies :returns: The package names :rtype: list """ # select packages with no dependencies in alphabetical order to_be_ordered = list(packages.keys()) ordered = [] while to_be_ordered: pkg_names_without_deps = [ name for name in to_be_ordered if not packages[name]] if not pkg_names_without_deps: reduce_cycle_set(packages) raise RuntimeError( 'Circular dependency between: ' + ', '.join(sorted(packages))) pkg_names_without_deps.sort() pkg_name = pkg_names_without_deps[0] to_be_ordered.remove(pkg_name) ordered.append(pkg_name) # remove item from dependency lists for k in list(packages.keys()): if pkg_name in packages[k]: packages[k].remove(pkg_name) return ordered def reduce_cycle_set(packages): """ Reduce the set of packages to the ones part of the circular dependency. :param dict packages: A mapping from package name to the set of runtime dependencies which is modified in place """ last_depended = None while len(packages) > 0: # get all remaining dependencies depended = set() for pkg_name, dependencies in packages.items(): depended = depended.union(dependencies) # remove all packages which are not dependent on for name in list(packages.keys()): if name not in depended: del packages[name] if last_depended: # if remaining packages haven't changed return them if last_depended == depended: return packages.keys() # otherwise reduce again last_depended = depended def _include_comments(): # skipping comment lines when AMENT_TRACE_SETUP_FILES is not set speeds up # the processing especially on Windows return bool(os.environ.get('AMENT_TRACE_SETUP_FILES')) def get_commands(pkg_name, prefix, primary_extension, additional_extension): commands = [] package_dsv_path = os.path.join(prefix, 'share', pkg_name, 'package.dsv') if os.path.exists(package_dsv_path): commands += process_dsv_file( package_dsv_path, prefix, primary_extension, additional_extension) else: for ext in ( [additional_extension] if additional_extension else [] ) + [primary_extension]: package_ext_path = os.path.join( prefix, 'share', pkg_name, 'local_setup.' + ext) if os.path.exists(package_ext_path): commands += [ FORMAT_STR_INVOKE_SCRIPT.format_map({ 'prefix': prefix, 'script_path': package_ext_path})] break return commands def process_dsv_file( dsv_path, prefix, primary_extension=None, additional_extension=None ): commands = [] if _include_comments(): commands.append( FORMAT_STR_COMMENT_LINE.format_map({'comment': dsv_path})) with open(dsv_path, 'r') as h: content = h.read() lines = content.splitlines() basenames = OrderedDict() for i, line in enumerate(lines): # skip over empty or whitespace-only lines if not line.strip(): continue try: type_, remainder = line.split(';', 1) except ValueError: raise RuntimeError( "Line %d in '%s' doesn't contain a semicolon separating the " 'type from the arguments' % (i + 1, dsv_path)) if type_ != DSV_TYPE_SOURCE: # handle non-source lines try: commands += handle_dsv_types_except_source( type_, remainder, prefix) except RuntimeError as e: raise RuntimeError( "Line %d in '%s' %s" % (i + 1, dsv_path, e)) from e else: # group remaining source lines by basename path_without_ext, ext = os.path.splitext(remainder) assert ext.startswith('.') ext = ext[1:] if ext in (primary_extension, additional_extension): if path_without_ext not in basenames: basenames[path_without_ext] = set() basenames[path_without_ext].add(ext) # add the dsv extension to each basename if the file exists for basename, extensions in basenames.items(): if not os.path.isabs(basename): basename = os.path.join(prefix, basename) if os.path.exists(basename + '.dsv'): extensions.add('dsv') for basename, extensions in basenames.items(): if not os.path.isabs(basename): basename = os.path.join(prefix, basename) if 'dsv' in extensions: # process dsv files recursively commands += process_dsv_file( basename + '.dsv', prefix, primary_extension=primary_extension, additional_extension=additional_extension) elif primary_extension in extensions and len(extensions) == 1: # source primary-only files commands += [ FORMAT_STR_INVOKE_SCRIPT.format_map({ 'prefix': prefix, 'script_path': basename + '.' + primary_extension})] elif additional_extension in extensions: # source non-primary files commands += [ FORMAT_STR_INVOKE_SCRIPT.format_map({ 'prefix': prefix, 'script_path': basename + '.' + additional_extension})] return commands def handle_dsv_types_except_source(type_, remainder, prefix): commands = [] if type_ in (DSV_TYPE_SET, DSV_TYPE_SET_IF_UNSET): try: env_name, value = remainder.split(';', 1) except ValueError: raise RuntimeError( "doesn't contain a semicolon separating the environment name " 'from the value') try_prefixed_value = os.path.join(prefix, value) if value else prefix if os.path.exists(try_prefixed_value): value = try_prefixed_value if type_ == DSV_TYPE_SET: commands += _set(env_name, value) elif type_ == DSV_TYPE_SET_IF_UNSET: commands += _set_if_unset(env_name, value) else: assert False elif type_ in ( DSV_TYPE_APPEND_NON_DUPLICATE, DSV_TYPE_PREPEND_NON_DUPLICATE, DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS ): try: env_name_and_values = remainder.split(';') except ValueError: raise RuntimeError( "doesn't contain a semicolon separating the environment name " 'from the values') env_name = env_name_and_values[0] values = env_name_and_values[1:] for value in values: if not value: value = prefix elif not os.path.isabs(value): value = os.path.join(prefix, value) if ( type_ == DSV_TYPE_PREPEND_NON_DUPLICATE_IF_EXISTS and not os.path.exists(value) ): if _include_comments(): comment = f'skip extending {env_name} with not existing ' \ f'path: {value}' commands.append( FORMAT_STR_COMMENT_LINE.format_map({'comment': comment})) elif type_ == DSV_TYPE_APPEND_NON_DUPLICATE: commands += _append_unique_value(env_name, value) else: commands += _prepend_unique_value(env_name, value) else: raise RuntimeError( 'contains an unknown environment hook type: ' + type_) return commands env_state = {} def _append_unique_value(name, value): global env_state if name not in env_state: if os.environ.get(name): env_state[name] = set(os.environ[name].split(os.pathsep)) else: env_state[name] = set() # append even if the variable has not been set yet, in case a shell script sets the # same variable without the knowledge of this Python script. # later _remove_ending_separators() will cleanup any unintentional trailing separator extend = FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) + os.pathsep line = FORMAT_STR_SET_ENV_VAR.format_map( {'name': name, 'value': extend + value}) if value not in env_state[name]: env_state[name].add(value) else: if not _include_comments(): return [] line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) return [line] def _prepend_unique_value(name, value): global env_state if name not in env_state: if os.environ.get(name): env_state[name] = set(os.environ[name].split(os.pathsep)) else: env_state[name] = set() # prepend even if the variable has not been set yet, in case a shell script sets the # same variable without the knowledge of this Python script. # later _remove_ending_separators() will cleanup any unintentional trailing separator extend = os.pathsep + FORMAT_STR_USE_ENV_VAR.format_map({'name': name}) line = FORMAT_STR_SET_ENV_VAR.format_map( {'name': name, 'value': value + extend}) if value not in env_state[name]: env_state[name].add(value) else: if not _include_comments(): return [] line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) return [line] def _remove_ending_separators(): global env_state commands = [] for name in env_state: # skip variables that already had values before this script started prepending if name in os.environ: continue commands += [ FORMAT_STR_REMOVE_LEADING_SEPARATOR.format_map({'name': name}), FORMAT_STR_REMOVE_TRAILING_SEPARATOR.format_map({'name': name})] return commands def _set(name, value): global env_state env_state[name] = value line = FORMAT_STR_SET_ENV_VAR.format_map( {'name': name, 'value': value}) return [line] def _set_if_unset(name, value): global env_state line = FORMAT_STR_SET_ENV_VAR.format_map( {'name': name, 'value': value}) if env_state.get(name, os.environ.get(name)): line = FORMAT_STR_COMMENT_LINE.format_map({'comment': line}) return [line] if __name__ == '__main__': # pragma: no cover try: rc = main() except RuntimeError as e: print(str(e), file=sys.stderr) rc = 1 sys.exit(rc) ament_package-0.14.0/ament_package/template/prefix_level/local_setup.bash000066400000000000000000000005651417160472100266130ustar00rootroot00000000000000# copied from ament_package/template/prefix_level/local_setup.bash AMENT_SHELL=bash # source local_setup.sh from same directory as this file AMENT_CURRENT_PREFIX=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" && pwd) # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$AMENT_CURRENT_PREFIX/local_setup.sh\"" fi . "$AMENT_CURRENT_PREFIX/local_setup.sh" ament_package-0.14.0/ament_package/template/prefix_level/local_setup.bat.in000066400000000000000000000051751417160472100270530ustar00rootroot00000000000000:: generated from ament_package/template/prefix_level/local_setup.bat.in @echo off :: get and run all commands in topological order call:_ament_run_ordered_commands "%~dp0" goto:eof :: Run the commands in topological order :: first argument: the base path to look for packages :_ament_run_ordered_commands setlocal enabledelayedexpansion :: check environment variable for custom Python executable if "%AMENT_PYTHON_EXECUTABLE%" NEQ "" ( if not exist "%AMENT_PYTHON_EXECUTABLE%" ( echo error: AMENT_PYTHON_EXECUTABLE '%AMENT_PYTHON_EXECUTABLE%' doesn't exist exit /b 1 ) set "_ament_python_executable=%AMENT_PYTHON_EXECUTABLE%" ) else ( :: use the Python executable known at configure time set "_ament_python_executable=@ament_package_PYTHON_EXECUTABLE@" :: if it doesn't exist try a fall back if not exist "!_ament_python_executable!" ( python --version > NUL 2> NUL if errorlevel 1 ( echo error: unable to find python executable exit /b 1 ) set "_ament_python_executable=python" ) ) endlocal & ( set "_ament_python_executable=%_ament_python_executable%" ) :: escape potential closing parenthesis which would break the for loop set "ament_python_executable=%ament_python_executable:)=^)%" for /f "delims=" %%c in ('""%_ament_python_executable%" "%~1_local_setup_util.py" bat"') do ( if "%AMENT_TRACE_SETUP_FILES%" NEQ "" ( echo %%c ) :: only invoke non-comment lines echo %%c | findstr /r "^::" >nul 2>&1 if errorlevel 1 ( call %%c ) ) set _ament_python_executable= goto:eof :: call the specified batch file and output the name when tracing is requested :: first argument: the batch file :_ament_prefix_bat_call_script if exist "%~1" ( if "%AMENT_TRACE_SETUP_FILES%" NEQ "" echo call "%~1" call "%~1%" ) else ( echo not found: "%~1" 1>&2 ) goto:eof :: strip a leading semicolon from an environment variable if applicable :: first argument: the environment variable name :_ament_prefix_bat_strip_leading_semicolon setlocal enabledelayedexpansion set "name=%~1" set "value=!%name%!" if "%value:~0,1%"==";" set "value=%value:~1%" :: set result variable in parent scope endlocal & ( set "%~1=%value%" ) goto:eof :: strip a trailing semicolon from an environment variable if applicable :: first argument: the environment variable name :_ament_prefix_bat_strip_trailing_semicolon setlocal enabledelayedexpansion set "name=%~1" set "value=!%name%!" if "%value:~-1%"==";" set "value=%value:~0,-1%" :: set result variable in parent scope endlocal & ( set "%~1=%value%" ) goto:eof ament_package-0.14.0/ament_package/template/prefix_level/local_setup.sh.in000066400000000000000000000075261417160472100267210ustar00rootroot00000000000000# generated from ament_package/template/prefix_level/local_setup.sh.in # since a plain shell script can't determine its own path when being sourced # either use the provided AMENT_CURRENT_PREFIX # or fall back to the build time prefix (if it exists) _ament_prefix_sh_AMENT_CURRENT_PREFIX="@CMAKE_INSTALL_PREFIX@" if [ -z "$AMENT_CURRENT_PREFIX" ]; then if [ ! -d "$_ament_prefix_sh_AMENT_CURRENT_PREFIX" ]; then echo "The build time path \"$_ament_prefix_sh_AMENT_CURRENT_PREFIX\" doesn't exist. Either source a script for a different shell or set the environment variable \"AMENT_CURRENT_PREFIX\" explicitly." 1>&2 unset _ament_prefix_sh_AMENT_CURRENT_PREFIX return 1 fi else _ament_prefix_sh_AMENT_CURRENT_PREFIX="$AMENT_CURRENT_PREFIX" fi # set type of shell if not already set : ${AMENT_SHELL:=sh} # use the Python executable known at configure time _ament_python_executable="@ament_package_PYTHON_EXECUTABLE@" # allow overriding it with a custom location if [ -n "$AMENT_PYTHON_EXECUTABLE" ]; then _ament_python_executable="$AMENT_PYTHON_EXECUTABLE" fi # if the Python executable doesn't exist try another fall back if [ ! -f "$_ament_python_executable" ]; then if /usr/bin/env python3 --version > /dev/null then _ament_python_executable=`/usr/bin/env python3 -c "import sys; print(sys.executable)"` else echo error: unable to find fallback python3 executable return 1 fi fi # function to source another script with conditional trace output # first argument: the path of the script _ament_prefix_sh_source_script() { if [ -f "$1" ]; then if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$1\"" fi . "$1" else echo "not found: \"$1\"" 1>&2 fi } # function to prepend non-duplicate values to environment variables # using colons as separators and avoiding trailing separators ament_prepend_unique_value() { # arguments _listname="$1" _value="$2" #echo "listname $_listname" #eval echo "list value \$$_listname" #echo "value $_value" # check if the list contains the value eval _values=\"\$$_listname\" _duplicate= _ament_prepend_unique_value_IFS=$IFS IFS=":" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _values fi for _item in $_values; do # ignore empty strings if [ -z "$_item" ]; then continue fi if [ "$_item" = "$_value" ]; then _duplicate=1 fi done unset _item # prepend only non-duplicates if [ -z "$_duplicate" ]; then # avoid trailing separator if [ -z "$_values" ]; then eval export $_listname=\"$_value\" #eval echo "set list \$$_listname" else # field separator must not be a colon unset IFS eval export $_listname=\"$_value:\$$_listname\" #eval echo "prepend list \$$_listname" fi fi IFS=$_ament_prepend_unique_value_IFS unset _ament_prepend_unique_value_IFS unset _duplicate unset _values unset _value unset _listname } # get all commands in topological order _ament_additional_extension="" if [ "$AMENT_SHELL" != "sh" ]; then _ament_additional_extension="${AMENT_SHELL}" fi _ament_ordered_commands="$($_ament_python_executable "$_ament_prefix_sh_AMENT_CURRENT_PREFIX/_local_setup_util.py" sh $_ament_additional_extension)" unset _ament_additional_extension unset _ament_python_executable if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "_ament_prefix_sh_source_script() { if [ -f \"\$1\" ]; then if [ -n \"\$AMENT_TRACE_SETUP_FILES\" ]; then echo \"# . \\\"\$1\\\"\" fi . \"\$1\" else echo \"not found: \\\"\$1\\\"\" 1>&2 fi }" echo "# Execute generated script:" echo "# <<<" echo "${_ament_ordered_commands}" echo "# >>>" echo "unset _ament_prefix_sh_source_script" fi eval "${_ament_ordered_commands}" unset _ament_ordered_commands unset _ament_prefix_sh_source_script unset _ament_prefix_sh_AMENT_CURRENT_PREFIX ament_package-0.14.0/ament_package/template/prefix_level/local_setup.zsh000066400000000000000000000005731417160472100265010ustar00rootroot00000000000000# copied from ament_package/template/prefix_level/local_setup.zsh AMENT_SHELL=zsh # source local_setup.sh from same directory as this file AMENT_CURRENT_PREFIX=$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd) # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$AMENT_CURRENT_PREFIX/local_setup.sh\"" fi . "$AMENT_CURRENT_PREFIX/local_setup.sh" ament_package-0.14.0/ament_package/template/prefix_level/setup.bash000066400000000000000000000005351417160472100254360ustar00rootroot00000000000000# copied from ament_package/template/prefix_level/setup.bash AMENT_SHELL=bash # source setup.sh from same directory as this file AMENT_CURRENT_PREFIX=$(builtin cd "`dirname "${BASH_SOURCE[0]}"`" && pwd) # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$AMENT_CURRENT_PREFIX/setup.sh\"" fi . "$AMENT_CURRENT_PREFIX/setup.sh" ament_package-0.14.0/ament_package/template/prefix_level/setup.bat.in000066400000000000000000000070251417160472100256750ustar00rootroot00000000000000:: generated from ament_package/template/prefix_level/setup.bat.in @echo off :: get the directory of this file without trailing backslash set "_current_prefix_path=%~dp0" if %_current_prefix_path:~-1%==\ set _current_prefix_path=%_current_prefix_path:~0,-1% :: find parent prefix path files for all packages under the current prefix call:list_files _resource_names "%_current_prefix_path%\share\ament_index\resource_index\parent_prefix_path" :: get the unique parent prefix path in reverse order call:get_prefix_path _unique_reverse_prefix_path "%_current_prefix_path%" "%_resource_names%" set "_resource_names=" :: append this directory to the prefix path call:ament_append_unique_value _unique_reverse_prefix_path "%_current_prefix_path%" set "_current_prefix_path=" :: source local_setup.bat file for each prefix path for %%p in ("%_unique_reverse_prefix_path:;=";"%") do ( call:call_file "%%~p\local_setup.bat" ) set "_unique_reverse_prefix_path=" :: end of script goto:eof :: List the files in a directory in alphabetical order. :: first argument: the name of the result variable :: second argument: the directory :list_files setlocal enabledelayedexpansion set "files=" for /f %%f in ('dir /b "%~2"') do ( if "!files!" NEQ "" set "files=!files!;" set "files=!files!%%~f" ) endlocal & ( :: set result variable in parent scope set "%~1=%files%" ) goto:eof :: Iterate over all parent_prefix_path files and :: get the unique parent prefix path in reverse order. :: first argument: the name of the result variable :: second parameter: the prefix path names :: third parameter: the resource names :get_prefix_path setlocal enabledelayedexpansion set "prefix_path=" set "resource_names=%~3" if "%resource_names%" NEQ "" ( for %%a in ("%resource_names:;=";"%") do ( :: reset variable otherwise it keeps its previous value if the file is empty set "reverse_ppp=" for /f "tokens=1 delims=" %%p in (%~2\share\ament_index\resource_index\parent_prefix_path\%%~a) do ( if "!reverse_ppp!" NEQ "" set "reverse_ppp=;!reverse_ppp!" :: replace placeholder of current prefix if "%%~p" EQU "{prefix}" ( set "p=%~2" ) set "reverse_ppp=%%~p!reverse_ppp!" ) :: append unique prefix path for %%p in ("!reverse_ppp:;=";"!") do ( call:ament_append_unique_value prefix_path "%%~p" ) ) ) endlocal & ( :: set result variable in parent scope set "%~1=%prefix_path%" ) goto:eof :: Append non-duplicate values to environment variables :: using semicolons as separators and avoiding trailing separators. :: first argument: the name of the result variable :: second argument: the value :ament_append_unique_value setlocal enabledelayedexpansion :: arguments set "listname=%~1" set "value=%~2" :: expand the list variable set "list=!%listname%!" :: check if the list contains the value set "is_duplicate=" if "%list%" NEQ "" ( for %%v in ("%list:;=";"%") do ( if "%%~v" == "%value%" set "is_duplicate=1" ) ) :: if it is not a duplicate append it if "%is_duplicate%" == "" ( :: if not empty, append a semi-colon if "!list!" NEQ "" set "list=!list!;" :: append the value set "list=!list!%value%" ) endlocal & ( :: set result variable in parent scope set "%~1=%list%" ) goto:eof :: Call the specified batch file and output the name when tracing is requested. :: first argument: the batch file :call_file if "%AMENT_TRACE_SETUP_FILES%" NEQ "" echo call "%~1" if exist "%~1" call "%~1%" goto:eof ament_package-0.14.0/ament_package/template/prefix_level/setup.sh.in000066400000000000000000000102741417160472100255410ustar00rootroot00000000000000# generated from ament_package/template/prefix_level/setup.sh.in # since this file is sourced use either the provided AMENT_CURRENT_PREFIX # or fall back to the destination set at configure time : ${AMENT_CURRENT_PREFIX:=@CMAKE_INSTALL_PREFIX@} # set type of shell if not already set : ${AMENT_SHELL:=sh} # function to append non-duplicate values to environment variables # using colons as separators and avoiding leading separators ament_append_unique_value() { # arguments _listname=$1 _value=$2 #echo "listname $_listname" #eval echo "list value \$$_listname" #echo "value $_value" # check if the list contains the value eval _values=\$$_listname _duplicate= _ament_append_unique_value_IFS=$IFS IFS=":" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _values fi for _item in $_values; do # ignore empty strings if [ -z "$_item" ]; then continue fi if [ $_item = $_value ]; then _duplicate=1 fi done unset _item # append only non-duplicates if [ -z "$_duplicate" ]; then # avoid leading separator if [ -z "$_values" ]; then eval $_listname=\"$_value\" #eval echo "set list \$$_listname" else # field separator must not be a colon unset IFS eval $_listname=\"\$$_listname:$_value\" #eval echo "append list \$$_listname" fi fi IFS=$_ament_append_unique_value_IFS unset _ament_append_unique_value_IFS unset _duplicate unset _values unset _value unset _listname } # iterate over all parent_prefix_path files _prefix_setup_IFS=$IFS IFS=" " # this variable contains the concatenated prefix paths in reverse order _UNIQUE_PREFIX_PATH="" # this check is used to skip parent prefix path in the Debian package if [ -z "@SKIP_PARENT_PREFIX_PATH@" ]; then # find parent prefix path files for all packages under the current prefix _RESOURCES="$(\find "$AMENT_CURRENT_PREFIX/share/ament_index/resource_index/parent_prefix_path" -mindepth 1 -maxdepth 1 2> /dev/null | \sort)" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _RESOURCES fi for _resource in $_RESOURCES; do # read the content of the parent_prefix_path file _PARENT_PREFIX_PATH="$(\cat "$_resource")" # reverse the list _REVERSED_PARENT_PREFIX_PATH="" IFS=":" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _PARENT_PREFIX_PATH fi for _path in $_PARENT_PREFIX_PATH; do # replace placeholder of current prefix if [ "$_path" = "{prefix}" ]; then _path="$AMENT_CURRENT_PREFIX" fi # avoid leading separator if [ -z "$_REVERSED_PARENT_PREFIX_PATH" ]; then _REVERSED_PARENT_PREFIX_PATH=$_path else _REVERSED_PARENT_PREFIX_PATH=$_path:$_REVERSED_PARENT_PREFIX_PATH fi done unset _PARENT_PREFIX_PATH # collect all unique parent prefix path if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _REVERSED_PARENT_PREFIX_PATH fi for _path in $_REVERSED_PARENT_PREFIX_PATH; do ament_append_unique_value _UNIQUE_PREFIX_PATH "$_path" done unset _REVERSED_PARENT_PREFIX_PATH done unset _resource unset _RESOURCES fi # append this directory to the prefix path ament_append_unique_value _UNIQUE_PREFIX_PATH "$AMENT_CURRENT_PREFIX" unset AMENT_CURRENT_PREFIX # store AMENT_SHELL to restore it after each prefix _prefix_setup_AMENT_SHELL=$AMENT_SHELL # source local_setup.EXT or local_setup.sh file for each prefix path IFS=":" if [ "$AMENT_SHELL" = "zsh" ]; then ament_zsh_to_array _UNIQUE_PREFIX_PATH fi for _path in $_UNIQUE_PREFIX_PATH; do # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$_path/local_setup.$AMENT_SHELL\"" fi if [ -f "$_path/local_setup.$AMENT_SHELL" ]; then if [ "$AMENT_SHELL" = "sh" ]; then # provide AMENT_CURRENT_PREFIX to .sh files AMENT_CURRENT_PREFIX=$_path fi # restore IFS before sourcing other files IFS=$_prefix_setup_IFS . "$_path/local_setup.$AMENT_SHELL" # restore AMENT_SHELL after each prefix-level local_setup file AMENT_SHELL=$_prefix_setup_AMENT_SHELL fi done unset _path IFS=$_prefix_setup_IFS unset _prefix_setup_IFS unset _prefix_setup_AMENT_SHELL unset _UNIQUE_PREFIX_PATH unset AMENT_SHELL ament_package-0.14.0/ament_package/template/prefix_level/setup.zsh000066400000000000000000000011561417160472100253250ustar00rootroot00000000000000# copied from ament_package/template/prefix_level/setup.zsh AMENT_SHELL=zsh # source setup.sh from same directory as this file AMENT_CURRENT_PREFIX=$(builtin cd -q "`dirname "${(%):-%N}"`" > /dev/null && pwd) # function to convert array-like strings into arrays # to wordaround SH_WORD_SPLIT not being set ament_zsh_to_array() { local _listname=$1 local _dollar="$" local _split="{=" local _to_array="(\"$_dollar$_split$_listname}\")" eval $_listname=$_to_array } # trace output if [ -n "$AMENT_TRACE_SETUP_FILES" ]; then echo "# . \"$AMENT_CURRENT_PREFIX/setup.sh\"" fi . "$AMENT_CURRENT_PREFIX/setup.sh" ament_package-0.14.0/ament_package/templates.py000066400000000000000000000100421417160472100215020ustar00rootroot00000000000000# Copyright 2014 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import re try: import importlib.resources as importlib_resources except ModuleNotFoundError: import importlib_resources IS_WINDOWS = os.name == 'nt' def get_environment_hook_template_path(name): with importlib_resources.path('ament_package.template.environment_hook', name) as path: return str(path) def get_package_level_template_names(all_platforms=False): names = ['local_setup.%s.in' % ext for ext in [ 'bash', 'bat', 'sh', 'zsh', ]] if not all_platforms: names = [name for name in names if _is_platform_specific_extension(name)] return names def get_package_level_template_path(name): with importlib_resources.path('ament_package.template.package_level', name) as path: return str(path) def get_prefix_level_template_names(*, all_platforms=False): extensions = [ 'bash', 'bat.in', 'sh.in', 'zsh', ] names = ['local_setup.%s' % ext for ext in extensions] + \ ['setup.%s' % ext for ext in extensions] + \ ['_local_setup_util.py'] if not all_platforms: names = [name for name in names if _is_platform_specific_extension(name)] return names def get_prefix_level_template_path(name): with importlib_resources.path('ament_package.template.prefix_level', name) as path: return str(path) def get_isolated_prefix_level_template_names(*, all_platforms=False): extensions = [ 'bash', 'bat.in', 'sh.in', 'zsh', ] names = ['local_setup.%s' % ext for ext in extensions] + \ ['_order_isolated_packages.py'] # + ['setup.%s' % ext for ext in extensions] if not all_platforms: names = [name for name in names if _is_platform_specific_extension(name)] return names def get_isolated_prefix_level_template_path(name): with importlib_resources.path('ament_package.template.isolated_prefix_level', name) as path: return str(path) def configure_file(template_file, environment): """ Evaluate a .in template file used in CMake with configure_file. :param template_file: path to the template, ``str`` :param environment: dictionary of placeholders to substitute, ``dict`` :returns: string with evaluates template :raises: KeyError for placeholders in the template which are not in the environment """ with open(template_file, 'r') as f: template = f.read() return configure_string(template, environment) def configure_string(template, environment): """ Substitute variables enclosed by @ characters. :param template: the template, ``str`` :param environment: dictionary of placeholders to substitute, ``dict`` :returns: string with evaluates template :raises: KeyError for placeholders in the template which are not in the environment """ def substitute(match): var = match.group(0)[1:-1] if var in environment: return environment[var] return '' return re.sub(r'\@[a-zA-Z0-9_]+\@', substitute, template) def _is_platform_specific_extension(filename): if filename.endswith('.in'): filename = filename[:-3] if not IS_WINDOWS and filename.endswith('.bat'): # On non-Windows system, ignore .bat return False if IS_WINDOWS and os.path.splitext(filename)[1] not in ['.bat', '.py']: # On Windows, ignore anything other than .bat and .py return False return True ament_package-0.14.0/package.xml000066400000000000000000000015201417160472100164710ustar00rootroot00000000000000 ament_package 0.14.0 The parser for the manifest files in the ament buildsystem. Audrow Nash Apache License 2.0 Dirk Thomas Mabel Zhang python3-importlib-metadata python3-importlib-resources python3-setuptools python3-flake8 python3-pytest ament_python ament_package-0.14.0/pytest.ini000066400000000000000000000002071417160472100164060ustar00rootroot00000000000000[pytest] markers = flake8: marks tests checking for flake8 compliance linter: marks tests as linter checks junit_family=xunit2 ament_package-0.14.0/resource/000077500000000000000000000000001417160472100162055ustar00rootroot00000000000000ament_package-0.14.0/resource/ament_package000066400000000000000000000000001417160472100206750ustar00rootroot00000000000000ament_package-0.14.0/setup.py000066400000000000000000000026421417160472100160740ustar00rootroot00000000000000from setuptools import find_packages from setuptools import setup package_name = 'ament_package' setup( name=package_name, version='0.14.0', packages=find_packages(exclude=['test']), data_files=[ ('share/' + package_name, ['package.xml']), ('share/ament_index/resource_index/packages', ['resource/' + package_name]), ], zip_safe=True, author='Dirk Thomas', author_email='dthomas@osrfoundation.org', maintainer='Audrow Nash', maintainer_email='audrow@openrobotics.org', url='https://github.com/ament/ament_package/wiki', download_url='https://github.com/ament/ament_package/releases', keywords=['ROS'], classifiers=[ 'Intended Audience :: Developers', 'License :: OSI Approved :: Apache Software License', 'Programming Language :: Python', 'Topic :: Software Development', ], description='Ament is a build system for federated packages.', long_description="""\ Ament defines metainformation for packages, their dependencies, and provides tooling to build these federated packages together.""", license='Apache License, Version 2.0', tests_require=['flake8', 'pytest'], package_data={ 'ament_package': [ 'template/environment_hook/*', 'template/isolated_prefix_level/*', 'template/package_level/*', 'template/prefix_level/*', ], }, ) ament_package-0.14.0/test/000077500000000000000000000000001417160472100153355ustar00rootroot00000000000000ament_package-0.14.0/test/__init__.py000066400000000000000000000012361417160472100174500ustar00rootroot00000000000000# Copyright 2014 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import os import sys sys.path.insert(0, os.path.join('..', 'src')) ament_package-0.14.0/test/test_flake8.py000066400000000000000000000016541417160472100201260ustar00rootroot00000000000000# Copyright 2016 Open Source Robotics Foundation, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. from flake8.api.legacy import get_style_guide import pytest @pytest.mark.flake8 @pytest.mark.linter def test_flake8(): # Configure flake8 using the .flake8 file in the root of this repository. style = get_style_guide() results = style.check_files() assert results.total_errors == 0, 'Found code style errors / warnings'