Skip to content

Commit

Permalink
Add override for rosdep sources cache path
Browse files Browse the repository at this point in the history
See #108 and #109 for the corresponding discussion
  • Loading branch information
roehling committed Jan 3, 2023
1 parent 912d311 commit 4b3538a
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
11 changes: 11 additions & 0 deletions catkin_lint.pod
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ B<catkin_lint> [B<--config> I<FILE>] [B<--quiet> | B<--no-quiet>]
[B<--pkg> I<PKG>] [B<--skip-pkg> I<PKG>]
[B<--package-path> I<PATH>] [B<--skip-path> I<MATCH>]
[B<--rosdistro> I<DISTRO>] [B<--offline>] [B<--no-offline>]
[B<--rosdep-cache-path> I<PATH>]
[B<--resolve-env> | B<--no-resolve-env>]
[B<--output> I<FORMAT> | B<--text> | B<--explain> | B<--xml> | B<--json>]
[B<--color> I<MODE>]
Expand Down Expand Up @@ -155,6 +156,11 @@ packages which can be found locally through the B<ROS> package search path.

Allow metadata queries to the B<ROS> package index. This is the default.

=item B<--rosdep-cache-path> I<PATH>

Override the default location of the rosdep sources cache. This option has the same
effect as setting the B<ROSDEP_CACHE_PATH> environment variable.

=item B<--resolve-env>

Resolve environment variables B<$ENV{}> in CMake scripts. By default, B<catkin_lint> will treat
Expand Down Expand Up @@ -317,6 +323,11 @@ By default, this value is taken from the B<ROS_DISTRO> environment variable.
B<catkin_lint> will use this to query the B<ROS> database for packages which are not
locally installed.

=item B<rosdep_cache_path> = I<PATH>

Override the default location of the rosdep sources cache. This option has the same
effect as setting the B<ROSDEP_CACHE_PATH> environment variable.

=item B<severity_level> = B<0> E<verbar> B<1> E<verbar> B<2>

Choose the severity level for diagnostic output. Level 0 displays errors only,
Expand Down
11 changes: 11 additions & 0 deletions gh-pages/docs/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ of a script.
\[**--pkg** _PKG_\] \[**--skip-pkg** _PKG_\]
\[**--package-path** _PATH_\] \[**--skip-path** _MATCH_\]
\[**--rosdistro** _DISTRO_\] \[**--offline**\] \[**--no-offline**\]
\[**--rosdep-cache-path** _PATH_\]
\[**--resolve-env** | **--no-resolve-env**\]
\[**--output** _FORMAT_ | **--text** | **--explain** | **--xml** | **--json**\]
\[**--color** _MODE_\]
Expand Down Expand Up @@ -104,6 +105,11 @@ of a script.

Allow metadata queries to the **ROS** package index. This is the default.

- **--rosdep-cache-path** _PATH_

Override the default location of the rosdep sources cache. This option has the same
effect as setting the **ROSDEP_CACHE_PATH** environment variable.

- **--resolve-env**

Resolve environment variables **$ENV{}** in CMake scripts. By default, **catkin\_lint** will treat
Expand Down Expand Up @@ -236,6 +242,11 @@ The main section is called `[catkin_lint]` and will take the following
**catkin\_lint** will use this to query the **ROS** database for packages which are not
locally installed.

- **rosdep\_cache\_path** = _PATH_

Override the default location of the rosdep sources cache. This option has the same
effect as setting the **ROSDEP_CACHE_PATH** environment variable.

- **severity\_level** = **0** | **1** | **2**

Choose the [severity level](index.md#diagnostic-levels) for diagnostic output.
Expand Down
5 changes: 5 additions & 0 deletions src/catkin_lint/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ def prepare_arguments(parser):
parser.add_argument("--skip-path", metavar="PATH", action="append", default=[], help="skip testing any package in a path that contains PATH (can be used multiple times)")
parser.add_argument("--package-path", metavar="PATH", help="additional package path (separate multiple locations with '%s') [*]" % os.pathsep)
parser.add_argument("--rosdistro", metavar="DISTRO", help="override ROS distribution (default: ROS_DISTRO environment variable) [*]")
parser.add_argument("--rosdep-cache-path", metavar="PATH", help="override rosdep sources cache location [*]")
m = parser.add_mutually_exclusive_group()
m.add_argument("--resolve-env", action="store_true", default=None, help="resolve $ENV{} references from environment variables [*]")
m.add_argument("--no-resolve-env", action="store_false", help="override resolve_env=yes option from configuration file")
Expand Down Expand Up @@ -166,6 +167,8 @@ def run_linter(args):
config["catkin_lint"] = {}
if args.rosdistro:
config["catkin_lint"]["rosdistro"] = args.rosdistro
if args.rosdep_cache_path:
config["catkin_lint"]["rosdep_cache_path"] = args.rosdep_cache_path
if args.package_path:
config["catkin_lint"]["package_path"] = args.package_path
if args.color:
Expand Down Expand Up @@ -212,6 +215,8 @@ def run_linter(args):
pkgs_to_check = []
if "rosdistro" in config["catkin_lint"]:
os.environ["ROS_DISTRO"] = config["catkin_lint"]["rosdistro"]
if "rosdep_cache_path" in config["catkin_lint"]:
os.environ["ROSDEP_CACHE_PATH"] = config["catkin_lint"]["rosdep_cache_path"]
quiet = config["catkin_lint"].getboolean("quiet", False)
env = CatkinEnvironment(
os_env=os.environ if config["catkin_lint"].getboolean("resolve_env", False) else None,
Expand Down
2 changes: 1 addition & 1 deletion src/catkin_lint/ros.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_rosdep(quiet):
from rosdep2.rospkg_loader import DEFAULT_VIEW_KEY
from rosdep2.sources_list import SourcesListLoader
dummy = DummyRospkg()
sources_loader = SourcesListLoader.create_default()
sources_loader = SourcesListLoader.create_default(sources_cache_dir=os.environ.get("ROSDEP_CACHE_PATH", None))
lookup = RosdepLookup.create_from_rospkg(rospack=dummy, rosstack=dummy, sources_loader=sources_loader)
return Rosdep(view=lookup.get_rosdep_view(DEFAULT_VIEW_KEY), quiet=quiet)

Expand Down

0 comments on commit 4b3538a

Please sign in to comment.