Skip to content
Snippets Groups Projects
Commit 3eeba14d authored by Amir MOHAMMADI's avatar Amir MOHAMMADI
Browse files

Merge branch 'dev-install' into 'master'

Ask for conda env name explicitly in bdt dev install

See merge request !297
parents f92a8f51 346a2bb8
No related branches found
No related tags found
1 merge request!297Ask for conda env name explicitly in bdt dev install
Pipeline #62347 passed
......@@ -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"""
......
......@@ -47,7 +47,7 @@ assume you have ``bob.devtools`` installed on a conda environment named ``bdt``
.. code-block:: sh
$ bdt dev install . # calls pip with correct arguments
$ bdt dev install -n dev . # calls pip with correct arguments
$ python
for example:
......@@ -179,7 +179,7 @@ The last step is to install the package:
$ cd bob.io.base #if that is not the case
$ conda activate dev #if that is not the case
$ bdt dev install .
$ bdt dev install -n dev .
To run the test suite:
......@@ -240,7 +240,7 @@ and install ``bob.extension`` as following:
.. code-block:: sh
$ bdt dev checkout --use-ssh --subfolder src bob.extension
$ bdt dev install src/bob.extension
$ bdt dev install -n dev src/bob.extension
.. _bob.devtools.create_package:
......@@ -269,7 +269,7 @@ start developing your package.
$ cd bob.project.awesome
$ bdt dev create --stable -vv awesome-project #here we used the stable channels to make the conda environment.
$ conda activate awesome-project
$ bdt dev install .
$ bdt dev install -n awesome-project .
Developing existing bob packages along with your new package
......@@ -283,7 +283,7 @@ You need to checkout and install these packages:
.. code-block:: sh
$ bdt dev checkout --use-ssh --subfolder src bob.extension bob.io.base
$ bdt dev install src/bob.extension src/bob.io.base # the order of installing dependencies matters!
$ bdt dev install -n awesome-project src/bob.extension src/bob.io.base # the order of installing dependencies matters!
When you build your new package, it is customary to checkout the dependent
packages (in this example ``bob.extension`` and ``bob.io.base``) in the ``src``
......@@ -298,6 +298,6 @@ your environment. You can find these dependencies by checking
.. code-block:: sh
$ mamba install gcc_linux-64 gxx_linux-64 libblitz
$ bdt dev install src/bob.extension src/bob.io.base # the order of installing dependencies matters!
$ bdt dev install -n awesome-project src/bob.extension src/bob.io.base # the order of installing dependencies matters!
.. include:: links.rst
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment