Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support option for environment activation #52

Open
esloch opened this issue Jul 6, 2023 · 3 comments
Open

Support option for environment activation #52

esloch opened this issue Jul 6, 2023 · 3 comments
Assignees
Labels
Milestone

Comments

@esloch
Copy link
Contributor

esloch commented Jul 6, 2023

We need to add support for conda environment activation that will activate the environment beforehand before executing the environment.

for now, let's just support conda.

version: 1.0
env-file: .env
virtual-environment:
  application: conda
  name: my-env
groups:
  php:
    targets:
      print:
        help: print 1
        run: |
           print('1')

this option should be defined just in the global scope.
we need to investigate it later if we would like to have it for group and target scope as well.

for now, we don't need to implement source, but it would be nice to have that, so it could create an environment in the case it doesn't exist.

@esloch esloch self-assigned this Jul 6, 2023
@xmnlab xmnlab added this to the OSL-C2023-01 milestone Nov 3, 2023
@xmnlab xmnlab added the size:medium <=16h label Nov 3, 2023
@xmnlab
Copy link
Member

xmnlab commented Jan 15, 2024

before this line https://github.com/osl-incubator/makim/blob/main/src/makim/core.py#L94C1-L107C1

we could have something like this:

        venv = self.global_data.get('virtual-environment'. {})
        venv_app = venv.get({'application', ''})
        venv_name = venv.get({'name', ''})

        self.shell_app(
            *self.shell_args,
            f"{venv_app} activate {venv_name}",
            _in=sys.stdin,
            _out=sys.stdout,
            _err=sys.stderr,
            _bg=False,
            _bg_exc=False,
            _no_err=True,
            _env=os.environ,
            _new_session=False,
        )

@abhijeetSaroha
Copy link
Collaborator

        self.shell_app(
            *self.shell_args,
            f"{venv_app} activate {venv_name}",
            _in=sys.stdin,
            _out=sys.stdout,
            _err=sys.stderr,
            _bg=False,
            _bg_exc=False,
            _no_err=True,
            _env=os.environ,
            _new_session=False,
)

It doesn't work, gives no such file or directory error, when try to activate the environment.
I think because that's the the place for filepath not for the shell command.

@xmnlab
Copy link
Member

xmnlab commented Jan 17, 2024

I see . but that is the general idea ... you can try different things there
this is the page for the sh library https://github.com/amoffat/sh
so maybe instead of self.shell_app .. it could be something like (for example)

sh_venv = getattr(sh, venv_app)

sh_venv(
            f"activate {venv_name}",
            _in=sys.stdin,
            _out=sys.stdout,
            _err=sys.stderr,
            _bg=False,
            _bg_exc=False,
            _no_err=True,
            _env=os.environ,
            _new_session=False,
)

but cretes a jupyter notebook and play a bit with that
try to explore different things and approaches

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants