Skip to content
Snippets Groups Projects

Ask for conda env name explicitly in bdt dev install

2 files
+ 53
26
Compare changes
  • Side-by-side
  • Inline

Files

+ 47
20
@@ -4,33 +4,51 @@ from click_plugins import with_plugins
from pkg_resources import iter_entry_points
@click.command(epilog="See bdt dev --help")
@click.command(epilog="See bdt dev --help for examples of this command.")
@click.option(
"-n",
"--env-name",
help="Name of the conda environment to use",
required=True,
)
@click.argument(
"folders",
nargs=-1,
type=click.Path(exists=True, file_okay=False, dir_okay=True),
)
def install(folders):
"""runs pip install -vvv --no-build-isolation --no-dependencies --editable <folder>"""
def install(env_name, folders):
"""runs:
pip install -vvv --no-build-isolation --no-dependencies --editable <folder>
inside the specified conda environment"""
import subprocess
for folder in folders:
# call pip
cmd = [
"conda",
"run",
"-n",
env_name,
"pip",
"install",
"-vvv",
"--no-build-isolation",
"--no-dependencies",
"--editable",
folder,
]
cmd = " ".join(cmd)
subprocess.check_call(
[
"pip",
"install",
"-vvv",
"--no-build-isolation",
"--no-dependencies",
"--editable",
folder,
]
cmd,
shell=True,
)
click.echo("Installed package using the command:", cmd)
@click.command(epilog="See bdt dev --help")
@click.command(epilog="See bdt dev --help for examples of this command.")
@click.argument("names", nargs=-1)
@click.option("--use-https/--use-ssh", is_flag=True, default=False)
@click.option(
@@ -38,7 +56,7 @@ def install(folders):
)
@click.pass_context
def checkout(ctx, names, use_https, subfolder):
"""git clones a Bob package."""
"""git clones a Bob package and installs the pre-commit hook if required."""
import os
import subprocess
@@ -67,9 +85,18 @@ def checkout(ctx, names, use_https, subfolder):
click.echo(
"Installing pre-commit hooks. Make sure you have pre-commit installed."
)
subprocess.check_call(["pre-commit", "install"], cwd=dest)
try:
subprocess.check_call(["pre-commit", "install"], cwd=dest)
except subprocess.CalledProcessError:
click.echo(
"pre-commit git hook installation failed. "
"Please make sure you have pre-commit installed "
"and its binary is in the PATH."
)
raise
# the group command must be at the end of this file for plugins to work.
@with_plugins(iter_entry_points("bdt.dev.cli"))
@click.group(
epilog="""Examples:
@@ -79,19 +106,19 @@ def checkout(ctx, names, use_https, subfolder):
bdt dev checkout bob.bio.face
cd bob.bio.face
bdt dev create --python 3.9 bobbioface
bdt dev install .
bdt dev install -n bobbioface .
\b
# later on, checkout and develop more packages
bdt dev checkout --subfolder src bob.bio.base
bdt dev install src/bob.bio.base
bdt dev install -n bobbioface src/bob.bio.base
\b
# develop a new project
bdt dev new -vv bob/bob.newpackage "John Doe" "joe@example.com"
# edit the conda/meta.yaml and requirements.txt files to add your dependencies
bdt dev create --python 3.9 bobnewpackage
bdt install ."""
bdt install -n bobnewpackage ."""
)
def dev():
"""Development scripts"""
Loading