Skip to content

Commit b268a6b

Browse files
committed
better installation instructions
1 parent 33e09f5 commit b268a6b

File tree

7 files changed

+134
-103
lines changed

7 files changed

+134
-103
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
### Added
1111

12+
* Added Blender paths for Windows.
13+
* Added `compas_rhino.print_python_path`.
14+
* Added `compas_blender.print_python_path`.
15+
1216
### Changed
1317

1418
### Removed

docs/userguide/cad.blender.rst

Lines changed: 35 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,24 +26,54 @@ The installation of COMPAS in Blender can be done in two ways:
2626
* by installing COMPAS in Blender's Python environment using ``pip``, or
2727
* by using the ``compas_blender.install`` command.
2828

29-
Using ``pip``
30-
-------------
29+
Using ``pip`` (recommended)
30+
---------------------------
3131

3232
Blender comes with its own Python installation.
3333
This procedure simply uses that Python installation and associated ``pip`` to install COMPAS.
34-
It doesn't require an existing COMPAS installation on your system.
34+
The location of the executable is different on different platforms.
35+
The default locations are:
3536

36-
You need to know the path to the Python executable that comes with Blender.
37-
On macOS, this is typically something like ``/Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10``.
37+
* Windows: ``C:\Program Files\Blender Foundation\Blender 4.0\4.0\python\bin\python.exe``
38+
* macOS: ``/Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10``
39+
* Linux: ``/usr/share/blender/4.0/python/bin/python3.10`` (i think :)
40+
41+
.. note::
42+
43+
If you already have an installation of COMPAS on your system, you can try finding the Rhino 8 Python executable by running the following in a terminal or command prompt:
44+
45+
.. code-block:: python
46+
47+
python -m compas_rhino.print_python_path
48+
49+
50+
Install from PyPI
51+
~~~~~~~~~~~~~~~~~
52+
53+
For example on Mac:
3854

3955
.. code-block:: bash
4056
4157
$ /Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10 -m pip install compas
4258
4359
60+
Install from Source
61+
~~~~~~~~~~~~~~~~~~~
62+
63+
.. code-block:: bash
64+
65+
$ cd path/to/compas
66+
$ /Applications/Blender.app/Contents/Resources/4.0/python/bin/python3.10 -m pip install -e .
67+
68+
4469
Using ``compas_blender.install``
4570
--------------------------------
4671

72+
.. warning::
73+
74+
This procedure will not install any of the dependencies required by COMPAS.
75+
They have to already be present in the Blender Python environment.
76+
4777
The ``compas_blender.install`` command installs COMPAS in Blender's Python ``site-packages`` folder
4878
by creating symlinks to COMPAS packages installed in an existing (``conda``) environment.
4979
Therefore, before running the command below, you should activate the environment in which you have installed COMPAS.
@@ -113,16 +143,3 @@ More info coming soon...
113143
blender_mesh = conversions.mesh_to_blender(mesh)
114144
115145
mesh = conversions.mesh_to_compas(blender_mesh)
116-
117-
118-
Data Exchange
119-
=============
120-
121-
122-
Remote Procedure Calls
123-
======================
124-
125-
126-
Known Issues
127-
============
128-

docs/userguide/cad.rhino.rst

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ are backwards compatible with Python 2.7 and written in pure Python,
99
such that they can be used in Rhino IronPython scripts (Rhino 7 and below),
1010
as well as in the new Rhino CPython scripts (Rhino 8).
1111

12+
Installation
13+
============
14+
1215
.. warning::
1316

1417
These instructions are for Rhino 6 and 7.
1518
For Rhino 8, please refer to :doc:`/userguide/cad.rhino8`.
1619

17-
Installation
18-
============
19-
2020
To use COMPAS in Rhino 6 or 7, you need to make Rhino aware of your COMPAS installation.
2121
This can be done with a simple command on the command line.
2222

@@ -38,13 +38,12 @@ Once the command terminates, you should see a message like this:
3838
3939
...
4040
41-
42-
The default Rhino version is 7.
43-
To install into Rhino 6, use the ``-v`` flag.
41+
The default Rhino version is 8.
42+
To install into Rhino 7, use the ``-v`` flag.
4443

4544
.. code-block:: bash
4645
47-
python -m compas_rhino.install -v 6.0
46+
python -m compas_rhino.install -v 7.0
4847
4948
Note that if COMPAS is installed in a ``conda`` environment, you need to activate it the environment before running the command.
5049

docs/userguide/cad.rhino8.rst

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -15,65 +15,39 @@ Working in Rhino 8
1515
Installation
1616
============
1717

18-
The installation of COMPAS in Rhino 8 can be done in two ways:
19-
20-
* by using the ``compas_rhino.install_with_pip`` command, or
21-
* by installing COMPAS in Rhino 8's Python environment using ``pip`` directly.
22-
23-
24-
Using ``pip``
25-
-------------
26-
2718
Rhino 8 comes with its own CPython executable (Python 3.9).
2819
This procedure simply uses that executable and its associated ``pip`` to install COMPAS.
2920
The location of the executable is different on different platforms.
3021

3122
* Windows: ``%USERPROFILE%\.rhinocode\py39-rh8\python.exe``
3223
* macOS: ``~/.rhinocode/py39-rh8/python3.9``
3324

34-
Install from PyPI
35-
~~~~~~~~~~~~~~~~~
36-
37-
For example on Mac:
38-
39-
.. code-block:: bash
40-
41-
$ ~/.rhinocode/py39-rh8/python3.9 -m pip install compas
42-
43-
44-
Install from Source
45-
~~~~~~~~~~~~~~~~~~~
46-
47-
.. code-block:: bash
48-
49-
$ cd path/to/compas
50-
$ ~/.rhinocode/py39-rh8/python3.9 -m pip install -e .
51-
25+
.. note::
5226

53-
Using ``compas_rhino.install_with_pip``
54-
---------------------------------------
27+
If you already have an installation of COMPAS on your system, you can try finding the Rhino 8 Python executable by running the following in a terminal or command prompt:
5528

56-
To simplify the above procedure, ``compas_rhino`` provides a convnience command.
29+
.. code-block:: bash
5730
58-
.. warning::
31+
python -m compas_rhino.print_python_path
5932
60-
This command is experimental and may not yet work properly on your system.
6133
6234
Install from PyPI
6335
~~~~~~~~~~~~~~~~~
6436

37+
For example on Mac:
38+
6539
.. code-block:: bash
6640
67-
$ python -m compas_rhino.install_with_pip compas
41+
$ ~/.rhinocode/py39-rh8/python3.9 -m pip install compas
6842
6943
7044
Install from Source
7145
~~~~~~~~~~~~~~~~~~~
7246

7347
.. code-block:: bash
7448
75-
$ cd /path/to/compas
76-
$ python -m compas_rhino.install_with_pip "-e ."
49+
$ cd path/to/compas
50+
$ ~/.rhinocode/py39-rh8/python3.9 -m pip install -e .
7751
7852
7953
Verification
@@ -87,40 +61,3 @@ In Rhino 8, open the Python editor (just type ``ScriptEditor``), open an new ``P
8761
print(compas.__version__)
8862
8963
If everything is installed correctly, this should print the version number of the installed COMPAS package.
90-
91-
92-
Visualisation
93-
=============
94-
95-
Visualisation of COMPAS objects in Rhino 8 is handled the same way as in other Rhino version, using viualisation scenes.
96-
For more information on visualisation scenes, see :doc:`/userguide/basics.visualisation`.
97-
98-
.. code-block:: python
99-
100-
import compas
101-
from compas.datastructures import Mesh
102-
from compas.scene import Scene
103-
104-
mesh = Mesh.from_obj(compas.get('tubemesh.obj'))
105-
106-
scene = Scene()
107-
scene.clear()
108-
scene.add(mesh)
109-
scene.draw()
110-
111-
112-
Conversions
113-
===========
114-
115-
116-
Data Exchange
117-
=============
118-
119-
120-
Remote Procedure Calls
121-
======================
122-
123-
124-
Known Issues
125-
============
126-

src/compas_blender/__init__.py

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,15 +142,33 @@ def _try_remove_bootstrapper(path):
142142
# =============================================================================
143143

144144

145-
def _get_default_blender_executable_path_mac():
145+
def _get_default_blender_executable_path(version):
146+
version = _check_blender_version(version)
147+
148+
if compas.OSX:
149+
path = _get_default_blender_executable_path_mac(version)
150+
elif compas.WINDOWS:
151+
path = _get_default_blender_executable_path_windows(version)
152+
elif compas.LINUX:
153+
path = _get_default_blender_executable_path_linux(version)
154+
else:
155+
raise Exception("Unsupported platform.")
156+
157+
if not os.path.exists(path):
158+
raise Exception("The default installation folder for Blender doesn't exist.")
159+
160+
return path
161+
162+
163+
def _get_default_blender_executable_path_mac(version):
146164
return "/Applications/Blender.app/Contents/MacOS/Blender"
147165

148166

149-
def _get_default_blender_executable_path_windows():
150-
raise NotImplementedError
167+
def _get_default_blender_executable_path_windows(version):
168+
return "C:\\Program Files\\Blender Foundation\\Blender {}".format(version)
151169

152170

153-
def _get_default_blender_executable_path_linux():
171+
def _get_default_blender_executable_path_linux(version):
154172
raise NotImplementedError
155173

156174

@@ -163,12 +181,30 @@ def _get_default_blender_executable_path_linux():
163181
# =============================================================================
164182

165183

184+
def _get_default_blender_python_path(version):
185+
version = _check_blender_version(version)
186+
187+
if compas.OSX:
188+
path = _get_default_blender_python_path_mac(version)
189+
elif compas.WINDOWS:
190+
path = _get_default_blender_python_path_windows(version)
191+
elif compas.LINUX:
192+
path = _get_default_blender_python_path_linux(version)
193+
else:
194+
raise Exception("Unsupported platform.")
195+
196+
if not os.path.exists(path):
197+
raise Exception("The default installation folder for Blender {} doesn't exist.".format(version))
198+
199+
return path
200+
201+
166202
def _get_default_blender_python_path_mac(version):
167203
return "/Applications/Blender.app/Contents/Resources/{}/python/bin/python3.10".format(version)
168204

169205

170206
def _get_default_blender_python_path_windows(version):
171-
raise NotImplementedError
207+
return "C:\\Program Files\\Blender Foundation\\Blender {}\\{}\\python\\bin\\python.exe".format(version, version)
172208

173209

174210
def _get_default_blender_python_path_linux(version):
@@ -207,7 +243,7 @@ def _get_default_blender_sitepackages_path_mac(version):
207243

208244

209245
def _get_default_blender_sitepackages_path_windows(version):
210-
raise NotImplementedError
246+
return "C:\\Program Files\\Blender Foundation\\Blender {}\\{}\\python\\lib\\site-packages".format(version, version)
211247

212248

213249
def _get_default_blender_sitepackages_path_linux(version):
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import compas_blender
2+
3+
4+
if __name__ == "__main__":
5+
import argparse
6+
7+
parser = argparse.ArgumentParser()
8+
9+
parser.add_argument(
10+
"-v",
11+
"--version",
12+
choices=compas_blender.SUPPORTED_VERSIONS,
13+
default=compas_blender.DEFAULT_VERSION,
14+
help="The version of Blender.",
15+
)
16+
17+
args = parser.parse_args()
18+
19+
print(compas_blender._get_default_blender_python_path(args.version))
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import compas_rhino
2+
3+
4+
if __name__ == "__main__":
5+
import argparse
6+
7+
parser = argparse.ArgumentParser()
8+
9+
parser.add_argument(
10+
"-v",
11+
"--version",
12+
choices=compas_rhino.SUPPORTED_VERSIONS,
13+
default=compas_rhino.DEFAULT_VERSION,
14+
help="The version of Rhino.",
15+
)
16+
17+
args = parser.parse_args()
18+
19+
print(compas_rhino._get_default_rhino_cpython_path(version=args.version))

0 commit comments

Comments
 (0)