Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
f-eisele authored and debauer committed May 29, 2024
1 parent 8647077 commit 4815378
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 98 deletions.
Empty file removed dummy.sh
Empty file.
179 changes: 90 additions & 89 deletions poetry.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ importlib-resources = { version = "^5.12.0", python = "<3.9" }
requests = "^2.31.0"

rosdep = "^0.22.0"
lark = "^1.1.9"

[tool.poetry.group.dev.dependencies]
ruff = "^0.1.5"
Expand Down
1 change: 1 addition & 0 deletions src/robenv/environment/distro.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ class DistroConfig(NamedTuple):
"share",
"src",
"tools",
"local",
),
builder_tool_variable_name="AMENT_CURRENT_PREFIX",
meta_package_prevent_overwrite=(
Expand Down
4 changes: 1 addition & 3 deletions src/robenv/environment/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,8 @@ def remove_installed(self, name: PackageName) -> None:
class RobEnv:
def __init__(self) -> None:
self.path = locate(DEFAULT_ROBENV_NAME)
# TODO(Moritz): /opt/ros/noetic is only correct if venv was created with default ros-path
# https://dmz-gitlab.honda-ri.de/SSE/robenv/-/issues/28
self._settings = RobEnvSettings.read(self.path)
self.shell = RobEnvShell(self.path / f"opt/ros/{self._settings.ros_distro}/setup.sh")
self.shell = RobEnvShell(self.path / "activate")
self._rosdep: Rosdep | None = None

@property
Expand Down
4 changes: 2 additions & 2 deletions src/robenv/environment/shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def run(
return run_command(self.command_in_env(command), events=events, cwd=cwd)

def command_in_env(self, command: str) -> str:
return f"bash -c 'source {Path('robenv/activate').absolute()} && {command}'"
return f"bash -c 'source {self._activate_script} && {command}'"

def spawn(self) -> int:
shell = self._get_shell()
Expand Down Expand Up @@ -96,6 +96,6 @@ def _get_shell(self) -> pexpect.spawn:
["-i"],
dimensions=(terminal.lines, terminal.columns),
)
shell.sendline("source robenv/activate")
shell.sendline(f"source {self._activate_script}")

return shell
2 changes: 1 addition & 1 deletion src/robenv/ros_package/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def _make_makefile(self, package: ROSPackage) -> None:
)
.replace(
f"/opt/ros/{distro}/setup.sh",
f"{self._robenv.path!s}/opt/ros/{distro}/setup.sh",
f"{self._robenv.path!s}/activate",
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/robenv/templates/activate.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

. "${robenv_path}/opt/ros/${ros_distro}/setup.$$(basename -- "$$SHELL")"
. "${robenv_path}/opt/ros/${ros_distro}/setup.sh"

export PATH="${robenv_ros_path}/bin:${robenv_path}/usr/bin:$$PATH"
export PKG_CONFIG_PATH="$$PKG_CONFIG_PATH:${robenv_ros_path}/lib/pkgconfig"
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/environment/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_get_shell__spawns_zsh_shell(
)
assert shell is pexpect_mock.spawn.return_value
shell.sendline.assert_called_once_with(
f"source {activate_script.with_suffix('.zsh')}",
f"source {activate_script}",
)


Expand All @@ -154,5 +154,5 @@ def test_get_shell__spawns_bash_shell(
)
assert shell is pexpect_mock.spawn.return_value
shell.sendline.assert_called_once_with(
f"source {activate_script.with_suffix('.bash')}",
f"source {activate_script}",
)

0 comments on commit 4815378

Please sign in to comment.