Skip to content

Commit d91c5a4

Browse files
committed
docs and rename
1 parent 495ff06 commit d91c5a4

File tree

2 files changed

+101
-3
lines changed

2 files changed

+101
-3
lines changed

docs/userguide/cad.rhino8.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,52 @@ To create an editable install, you should update `pip` itself, first.
6868
$ ~/.rhinocode/py39-rh8/python3.9 -m pip install -e .
6969
7070
71+
Experimental Method
72+
===================
73+
74+
COMPAS now makes the `install_in_rhino` command line utility available to simplify the installation of Python packages in Rhino 8 CPython.
75+
This utility is available after installing the main `compas` package:
76+
77+
Install any Python package from PyPI
78+
79+
.. code-block:: bash
80+
81+
install_in_rhino requests numpy
82+
83+
Install from the current directory
84+
85+
.. code-block:: bash
86+
87+
install_in_rhino .
88+
89+
Install from a local path
90+
91+
.. code-block:: bash
92+
93+
install_in_rhino path/to/package
94+
95+
Install from a requirements file
96+
97+
.. code-block:: bash
98+
99+
install_in_rhino -r requirements.txt
100+
101+
Install in a specific site environment.
102+
103+
.. code-block:: bash
104+
105+
install_in_rhino compas --env compas-dev
106+
107+
Clear the site environment before installing
108+
109+
.. code-block:: bash
110+
111+
install_in_rhino compas --env compas-dev --clear
112+
113+
114+
For more information, see :func:`compas_rhino.install_with_pip.install_in_rhino_with_pip`.
115+
116+
71117
Verification
72118
============
73119

src/compas_rhino/install_with_pip.py

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,63 @@ def ensure_site_env(name: str) -> str:
3333
return fullname
3434

3535

36-
def install_package(
36+
def install_in_rhino_with_pip(
3737
packages: list[str],
3838
requirements: Optional[str] = None,
3939
env: str = "default",
4040
upgrade: bool = False,
4141
deps: bool = True,
4242
clear: bool = False,
4343
):
44-
"""Install a package with Rhino's CPython pip."""
44+
"""Install a package with Rhino's CPython pip.
45+
46+
Parameters
47+
----------
48+
packages : list of str
49+
The package(s) to install (PyPI names or local package paths).
50+
requirements : str, optional
51+
Path to a requirements file.
52+
env : str, optional
53+
Name of the site env, without the random suffix.
54+
upgrade : bool, optional
55+
Attempt to upgrade packages already installed.
56+
deps : bool, optional
57+
If False, do not install dependencies.
58+
clear : bool, optional
59+
If True, clear the environment before installing.
60+
61+
Returns
62+
-------
63+
int
64+
The return code from the pip install command.
65+
66+
Raises
67+
------
68+
ValueError
69+
If both packages and requirements are provided, or if neither are provided.
70+
71+
Examples
72+
--------
73+
>>> install_in_rhino_with_pip(packages=["requests"], env="myenv", upgrade=True)
74+
>>> install_in_rhino_with_pip(requirements="requirements.txt", env="myenv")
75+
>>> install_in_rhino_with_pip(packages=["."], env="myenv")
76+
>>> install_in_rhino_with_pip(packages=[".."], env="myenv")
77+
78+
Notes
79+
-----
80+
This function is made available as a command line script under the name `install_in_rhino`.
81+
On the command line you can use the following syntax
82+
83+
.. code-block:: bash
84+
85+
install_in_rhino requests numpy
86+
install_in_rhino -r requirements.txt --env myenv --upgrade
87+
install_in_rhino . --env myenv
88+
install_in_rhino .. --env myenv
89+
install_in_rhino -r requirements.txt --env myenv --no-deps
90+
install_in_rhino requests --env myenv --clear
91+
92+
"""
4593

4694
if requirements and packages:
4795
raise ValueError("You must provide either packages or a requirements file, not both.")
@@ -103,7 +151,7 @@ def main():
103151
parser.set_defaults(deps=True)
104152
args = parser.parse_args()
105153

106-
install_package(
154+
install_in_rhino_with_pip(
107155
packages=args.packages,
108156
requirements=args.requirements,
109157
env=args.env,
@@ -113,5 +161,9 @@ def main():
113161
)
114162

115163

164+
# =============================================================================
165+
# Main
166+
# =============================================================================
167+
116168
if __name__ == "__main__":
117169
main()

0 commit comments

Comments
 (0)