-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
67 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters