-
Notifications
You must be signed in to change notification settings - Fork 194
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Lifecycle hooks #1183
Comments
I also just saw that this is mentioned as one of the requests in #1128 |
I was thinking about this a bit, do you think that instead of like a 'postinstall' we can create a trigger that uses the hash of a file to automatically trigger a task after a or a number of tasks. Think of having both a Python project that uses npm as well. You could make a "trigger" that triggers when the package.json changes after an install or maybe any other task. Might be more powerful than a postinstall. |
I think that it could a good addition to the idea. It definitely would make this a more complex feature to implement though. If it went that way I would think it could be some kind of configurable trigger, e.g. [tasks]
list-files = "ls -lah"
reset = "chartpress --reset"
[triggers]
post-install = ["list-files"]
[file-triggers]
"pixi.toml" = ["reset", "list-files"] |
What about adding it to the task definition: [tasks]
install-npm = { cmd = "npm install", trigger = "post-install", inputs = ["package.json", "src/javascript/*.js" } Where those triggers are predefined names that pixi looks for when it runs the install. These could be extended with more triggers, but I would like to add them based on use-case/on-request. This would allow you to do something similar to the life cycle scripts from npm but without predefined names for the tasks. |
Actually, the |
Having now tried a few different I've ended up with a pattern like this for a monorepo where i can't use [feature.pip.tasks.install-editable]
inputs = ["pyproject.toml", "contrib/*/pyproject.toml", "editable.txt"]
outputs = ["build/pip-freeze/$PIXI_ENVIRONMENT_NAME.txt"]
cmd = """
rm -f build/pip-freeze/$PIXI_ENVIRONMENT_NAME.txt
&& python -m pip install -vv --no-deps --no-build-isolation --ignore-installed -r editable.txt
&& mkdir -p build/pip-freeze
&& pip freeze > build/pip-freeze/$PIXI_ENVIRONMENT_NAME.txt""" ... and then have any downstream tasks This still gets a little annoying further down the line when the [feature.docs.tasks.report]
depends_on = [
"install-editable", # where the current -e will be right
{task="test", environment="some-env"},
{task="test", environment="some-other-env"},
]
inputs = [
"build/pip-freeze/$PIXI_ENVIRONMENT_NAME.txt",
"build/reports/some-env.txt",
"build/reports/some-other-env.txt"
] Running Alternately, as the task name regex is luckily already quite tight, a separator could be introduced: depends_on = ["install-editable", "some-env::test", "some-other-env::test"] Of course, if |
I have the need for this as well. I want to install a binary (that is not available in conda-forge/pypi) manually using curl into my environment/bin after pixi is finished building it. Reading this thread makes me think that triggering this automaticaly is not possible today? |
@nicornk if building is task, you can achieve this with a |
I was referring to calling „pixi install“. |
Ah I understand, that would be the requested feature indeed. |
This is basically one of my use-cases as well --- I want to install a Helm plugin after install, and to do the pre-commit startups and stuff like that. @tdejager maybe it could just be as simple as exposing the "install" as a task that can be depended on (possibly namespacing it to avoid collisions with user-named task |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Problem description
There was a brief proposal regarding lifecycle hooks in #524 but that issue was framed around Python dependencies. With the addition of the new
pypi-dependencies
the issue was more or less discarded. However there are other common use-cases for lifecycle hooks, especially when using pixi to setup development environments. Here's an example that will probably look familiar:Love this project, and always looking forward to the new features. The
pypi-dependencies
addition has seriously made life easier!The text was updated successfully, but these errors were encountered: