Skip to content

Commit

Permalink
Update main scenario init for conda-forge packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoferigo committed Oct 18, 2021
1 parent b4e87a1 commit 188a2c4
Showing 1 changed file with 26 additions and 4 deletions.
30 changes: 26 additions & 4 deletions scenario/bindings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def supported_versions_specifier_set() -> packaging.specifiers.SpecifierSet:

class InstallMode(Enum):
User = auto()
CondaBuild = auto()
Developer = auto()


Expand All @@ -36,7 +37,17 @@ def detect_install_mode() -> InstallMode:
import scenario.bindings.core

install_prefix = scenario.bindings.core.get_install_prefix()
return InstallMode.User if install_prefix == "" else InstallMode.Developer

# In conda, there are null bytes terminating the returned string
install_prefix = install_prefix.replace("\x00", "")

if "$PREFIX" in install_prefix:
return InstallMode.CondaBuild

if install_prefix == "":
return InstallMode.User
else:
return InstallMode.Developer


def setup_gazebo_environment() -> None:
Expand All @@ -49,12 +60,23 @@ def setup_gazebo_environment() -> None:
if "IGN_GAZEBO_SYSTEM_PLUGIN_PATH" in os.environ:
ign_gazebo_system_plugin_path = os.environ.get("IGN_GAZEBO_SYSTEM_PLUGIN_PATH")

# Exporting this env variable is done by the conda "libscenario" package
if detect_install_mode() is InstallMode.CondaBuild:
return

# Add the plugins path
if detect_install_mode() == InstallMode.Developer:
install_prefix = Path(scenario.bindings.core.get_install_prefix())
else:
if detect_install_mode() is InstallMode.Developer:
install_prefix = scenario.bindings.core.get_install_prefix()

# In conda, there are null bytes terminating the returned string
install_prefix = Path(install_prefix.replace("\x00", ""))

elif detect_install_mode() is InstallMode.User:
install_prefix = Path(os.path.dirname(__file__))

else:
raise ValueError(detect_install_mode())

plugin_dir = install_prefix / "lib" / "scenario" / "plugins"
ign_gazebo_system_plugin_path += f":{str(plugin_dir)}"

Expand Down

0 comments on commit 188a2c4

Please sign in to comment.