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

Pre/Post install commands to run #1146

Closed
vigneshmanick opened this issue Apr 9, 2024 · 3 comments
Closed

Pre/Post install commands to run #1146

vigneshmanick opened this issue Apr 9, 2024 · 3 comments
Labels
✨ enhancement Feature request

Comments

@vigneshmanick
Copy link
Contributor

Problem description

Pre/Post install scripts to run

When creating an environment i would like to be able to execute some tasks pre and post install (pixi install) .

For example, consider the following project

[project]
name = "project-name"
channels = ["conda-forge"]
platforms = ["linux-64"]

[dependencies]
python = "*"
nodejs = "*"

Now after this projct is created and installed, it requires additional nodejs dependencies which can only be installed via npm command. e.g npm install sax and before installation via npm the contents of a folder should have clean git history

This could be achieved by using the tasks section by using fixed keywords for depends_on. For example, pre-install and post-install

[tasks]
cleanup = {cmd= "git clean -xdff", depends_on="pre-install", cwd="npm_proj"}
npm-deps= { cmd="npm install sax", depends_on="post-install", cwd="npm_proj"}

The same will also work when the tasks are defined on a feature level

[feature.node.tasks]
cleanup = {cmd= "git clean -xdff", depends_on="pre-install", cwd="npm_proj"}
npm-deps= { cmd="npm install sax", depends_on="post-install", cwd="npm_proj"}

[environments]
node= ["node"]
@vigneshmanick vigneshmanick added the ✨ enhancement Feature request label Apr 9, 2024
@ruben-arts
Copy link
Contributor

It is possible to create something like this already with the inclusion of the caching feature.

If you setup a npm project using the package.json you could do something like this:

[project]
name = "project-name"
channels = ["conda-forge"]
platforms = ["linux-64"]

[dependencies]
python = "*"
nodejs = "*"

[tasks]
npm-deps= { cmd="npm install", cwd="npm_proj", inputs = ["package.json"]}
other_tasks = { cmd = "echo task", depends_on = "npm-deps"}
{
  "name": "npm_proj",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "me",
  "license": "ISC",
  "dependencies": {
    "sax": "^1.3.0"
  }
}

But I see this is not a full solution to your request as it could be a bit verbose with a ton of tasks.

@vigneshmanick
Copy link
Contributor Author

yes caching works partly as you have mentioned and also these tasks should be run manually. When they are dependent on the inbuilt commands then pixi takes care of that by itself automatically.

@ruben-arts
Copy link
Contributor

Closing in favor of #1183

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

No branches or pull requests

2 participants