@@ -38,11 +38,53 @@ def ensure_site_env(name: str) -> str:
3838@click .option ("--env" , default = "default" , help = "Name of the site env, without the random suffix..." )
3939@click .option ("--upgrade/--no-upgrade" , default = False )
4040@click .option ("--deps/--no-deps" , default = True )
41- def install_package (package , env , upgrade , deps ):
41+ def install_package (
42+ package : str ,
43+ env : str = "default" ,
44+ upgrade : bool = False ,
45+ deps : bool = True ,
46+ ):
47+ """Install a package with Rhino's CPython pip.
48+
49+ Parameters
50+ ----------
51+ package : str
52+ If a package name is provided, the package will be installed from PyPI.
53+ If `.` or `..` is specified, the package will be installed from the source in the current or parent folder, respectively.
54+ env : str, optional
55+ The name of the virtual (site) environment in Rhino, without the random suffix.
56+ If no environment name is provided, the default environment will be used.
57+ If the environment doesn't exist, it will be created automatically.
58+ upgrade : bool, optional
59+ Attempt to upgrade packages that were already installed.
60+ The default is False.
61+ deps : bool, optional
62+ Attempt to install the package dependencies.
63+ Default is True.
64+
65+ Returns
66+ -------
67+ str
68+ The output of the call to pip.
69+
70+ Examples
71+ --------
72+ When COMPAS is installed, the function is registered as an executable command with the name `install_in_rhino`.
73+
74+ $ cd path/to/local/compas/repo
75+ $ install_in_rhino .
76+
77+ $ cd path/to/local/compas/repo
78+ $ install_in_rhino . --env=compas-dev
79+
80+ $ cd path/to/local/compas/repo
81+ $ install_in_rhino . --env=compas-dev --upgrade --no-deps
82+
83+ """
4284 if package == "." :
43- package = pathlib .Path ().cwd ()
85+ package = str ( pathlib .Path ().cwd () )
4486 elif package == ".." :
45- package = pathlib .Path ().cwd ().parent
87+ package = str ( pathlib .Path ().cwd ().parent )
4688
4789 target = site_envs / ensure_site_env (env or "default" )
4890 target .mkdir (exist_ok = True )
0 commit comments