Skip to content

Commit

Permalink
#7
Browse files Browse the repository at this point in the history
  • Loading branch information
sapetnioc committed Jun 7, 2024
1 parent 0a8099d commit 8e8b5ab
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 57 deletions.
4 changes: 2 additions & 2 deletions activate.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export PYTHONPATH="$PIXI_PROJECT_ROOT/python:$PIXI_PROJECT_ROOT/soma-forge/python":$PYTHONPATH
export PATH="$PIXI_PROJECT_ROOT/bin:$PIXI_PROJECT_ROOT/soma-forge/bin:$PATH"
export PYTHONPATH="$PIXI_PROJECT_ROOT/python:$PYTHONPATH
export PATH="$PIXI_PROJECT_ROOT/bin:$PATH"
115 changes: 61 additions & 54 deletions bin/neuro-forge
Original file line number Diff line number Diff line change
@@ -1,69 +1,76 @@
#!/usr/bin/env python

import fire
import click
from itertools import chain
import os
from pathlib import Path
import shutil
from subprocess import check_call


class Commands:
@staticmethod
def init(channel_dir: str):
"""Initialise a new channel directory"""
# Create an empty channel
channel_dir = Path(channel_dir).absolute()
if not channel_dir.exists():
check_call(
[
"datalad",
"create",
"--description",
"Neuro-forge channel : https://brainvisa.info/neuro-forge",
str(channel_dir),
]
)
save_datalad = True
else:
save_datalad = False
(channel_dir / "noarch").mkdir(exist_ok=True)
(channel_dir / "linux-64").mkdir(exist_ok=True)
check_call(["conda", "index", channel_dir])
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
def main():
pass

# Create base packages
neuro_forge = Path(__file__).parent.parent
for recipe_dir in chain(
[neuro_forge / "soma-forge"], (neuro_forge / "recipes").iterdir()
):
if not (recipe_dir / "recipe.yaml").exists():
continue
command = [
"env",
f"HOME={channel_dir}",
"rattler-build",
"build",
"-r",
str(recipe_dir),
"--output-dir",

@main.command()
@click.argument("channel_dir", type=click.Path())
def init(channel_dir):
"""Initialise a new channel directory
CHANNEL_DIR directory where packages are going to be created
"""
# Create an empty channel
channel_dir = Path(channel_dir).absolute()
if not channel_dir.exists():
check_call(
[
"datalad",
"create",
"--description",
"Neuro-forge channel : https://brainvisa.info/neuro-forge",
str(channel_dir),
]
variants = recipe_dir / "variants.yaml"
if variants.exists():
command.extend(["-m", str(variants)])
check_call(command)
)
save_datalad = True
else:
save_datalad = False
(channel_dir / "noarch").mkdir(exist_ok=True)
(channel_dir / "linux-64").mkdir(exist_ok=True)
check_call(["conda", "index", channel_dir])

# Create base packages
neuro_forge = Path(__file__).parent.parent
for recipe_dir in chain(
[neuro_forge / "soma-forge"], (neuro_forge / "recipes").iterdir()
):
if not (recipe_dir / "recipe.yaml").exists():
continue
command = [
"env",
f"HOME={channel_dir}",
"rattler-build",
"build",
"-r",
str(recipe_dir),
"--output-dir",
str(channel_dir),
]
variants = recipe_dir / "variants.yaml"
if variants.exists():
command.extend(["-m", str(variants)])
check_call(command)

# Cleanup and create channel index
for i in ("bld", "src_cache", ".rattler", ".cache"):
to_delete = channel_dir / i
if to_delete.exists():
shutil.rmtree(to_delete)
check_call(["conda", "index", channel_dir])
if save_datalad:
check_call(
["datalad", "save", "-m", "Created initial packages", str(channel_dir)]
)
# Cleanup and create channel index
for i in ("bld", "src_cache", ".rattler", ".cache"):
to_delete = channel_dir / i
if to_delete.exists():
shutil.rmtree(to_delete)
check_call(["conda", "index", channel_dir])
if save_datalad:
check_call(
["datalad", "save", "-m", "Created initial packages", str(channel_dir)]
)


if __name__ == "__main__":
fire.Fire(Commands)
main()
5 changes: 4 additions & 1 deletion pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ scripts = ["activate.sh"]
[tasks]

[dependencies]
python = "*"
python = "> 2"
conda-build = "*"
rattler-build = "*"
fire = "*"
click = "*"
rich = "*"
git = "*"
gitpython = "*"
pip = "*"
toml = "*"
pyaml = "*"
Expand Down

0 comments on commit 8e8b5ab

Please sign in to comment.