moonrepo / moon

A build system and monorepo management tool for the web ecosystem, written in Rust.
https://moonrepo.dev/moon
MIT License
2.93k stars 161 forks source link

[feature] Run tasks in Python virtual environment #1658

Open sharpepd opened 2 months ago

sharpepd commented 2 months ago

Is your feature request related to a problem? Please describe.

I am new to moon, but I really like what I see! I am looking to use it primarily as a task runner.

But the tasks we want to run will be primarily provided via pip (python packages). Therefore, to ensure we have a consistent python environment, I need tasks to run in a virtual environment.

I would like to do this in a way that there is a task that creates the virtual environment with the required pip dependencies and then subsequent tasks operate in this environment (or can be specified to)

Describe the solution you'd like

I would like one of the following:

Describe alternatives you've considered

My experiments so far, suggest this is not possible, without some kind of wrapper around my commands. E.g. a cmd script that first activates the virtual environment before running the actual command.

I have played with generating a .env file and using that in the envFile option of tasks, but the issue is that the envFile seems to be read before the file is generated by the task that generates it. So, I would have to run the setup task first and then run the other tasks, but it would be nice to be able to do it all in one step, i.e via a dep.

Additional context

Note that the virtual environment I am creating is created in the workspace (usually /.venv).

I am guessing something like this may be needed for the Python language support as well. But I am not talking about a Python project here, just a project wanting to use commands installed via pip.

milesj commented 4 days ago

v1.30 now supports Python. Would love to hear your feedback!