Skip to content

Commit e7e0c3f

Browse files
committed
add clear option
1 parent 6767f64 commit e7e0c3f

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/compas_rhino/install_with_pip.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pathlib
22
import random
3+
import shutil
34
import string
45
import subprocess
56

@@ -38,11 +39,13 @@ def ensure_site_env(name: str) -> str:
3839
@click.option("--env", default="default", help="Name of the site env, without the random suffix...")
3940
@click.option("--upgrade/--no-upgrade", default=False)
4041
@click.option("--deps/--no-deps", default=True)
42+
@click.option("--clear/--no-clear", default=False)
4143
def install_package(
4244
package: str,
4345
env: str = "default",
4446
upgrade: bool = False,
4547
deps: bool = True,
48+
clear: bool = False,
4649
):
4750
"""Install a package with Rhino's CPython pip.
4851
@@ -86,7 +89,18 @@ def install_package(
8689
elif package == "..":
8790
package = str(pathlib.Path().cwd().parent)
8891

89-
target = site_envs / ensure_site_env(env or "default")
92+
env = env or "default"
93+
94+
if clear:
95+
try:
96+
fullname = find_full_env_name(env)
97+
except ValueError:
98+
pass
99+
else:
100+
target = site_envs / fullname
101+
shutil.rmtree(target, ignore_errors=True)
102+
103+
target = site_envs / ensure_site_env(env)
90104
target.mkdir(exist_ok=True)
91105

92106
args = [

0 commit comments

Comments
 (0)