Skip to content

Commit

Permalink
Prevent from failing if there is no environment file (jupyterlite#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinRenou authored Jan 24, 2024
1 parent 01c78d2 commit 5d8c08f
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions jupyterlite_xeus/add_on.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,20 +114,21 @@ def post_build(self, manager):

def create_prefix(self):
# read the environment file
env_name = "xeus-env"
root_prefix = Path(self.cwd.name) / "env"
env_file = Path(self.manager.lite_dir) / self.environment_file

# open the env yaml file
with open(env_file, "r") as file:
yaml_content = yaml.safe_load(file)
# open the env yaml file if it's provided
if env_file.exists():
with open(env_file, "r") as file:
yaml_content = yaml.safe_load(file)

env_name = yaml_content.get("name", "xeus-env")
env_prefix = root_prefix / "envs" / env_name
self.prefix = str(env_prefix)
env_name = yaml_content.get("name", "xeus-env")

env_prefix = root_prefix / "envs" / env_name
self.prefix = str(env_prefix)

if env_file.exists():
create_conda_env_from_env_file(root_prefix, yaml_content, env_file.parent)
# this is atm for debugging
else:
create_conda_env_from_specs(
env_name=env_name,
Expand Down

0 comments on commit 5d8c08f

Please sign in to comment.