Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update testing README #96

Merged
merged 9 commits into from
Nov 7, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ git clone https://github.com/UCL/Blender_Randomiser.git
- This will zip the `randomiser` subdirectory, open the `sample.blend` file with Blender, and use Blender's Python interpreter to execute the `install_and_enable_addons.py` script.
- The `install_and_enable_addons.py` script installs and enables any add-ons that are passed as command line arguments (add-ons can be passed as a path to a single Python file, or as a zip file)

> [!NOTE] `source ~/.bash_profile` is used in the bash script to create an alias for blender with the following line in the bash_profile:
> [!NOTE]
> `source ~/.bash_profile` is used in the bash script to create an alias for blender with the following line in the bash_profile:
> `alias blender=/Applications/Blender.app/Contents/MacOS/Blender`

> **Advanced Usage**
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -69,21 +70,28 @@ Alternatively, install [manually](/docs/Install_addon_manually.md) via Blender s
> Only relevant if you are wanting to run the tests.
> The tests make use of the [pytest-blender plugin](https://github.com/mondeja/pytest-blender#pytest-blender), which has `pytest` and other packages as dependencies (e.g. `pytest-cov`). These need to be installed in the site-packages directory of Blender's Python. The pytest-blender repo provides some guidance for this [here](https://github.com/mondeja/pytest-blender#usage). It is important to make sure you use Blender's Python interpreter and Blender's pip when installing `pytest` and its dependencies. Below are some tips on how to do this in Linux and MacOS.
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved

> **Linux**
> An easy way to install these dependencies correctly in Linux is to run the following code in [Blender's Python scripting window](https://docs.blender.org/api/current/info_quickstart.html):
> `import pip `
`pip.main(["install", "pytest", "--user"])`
`pip.main(["install", "pytest-cov", "--user"])`
`pip.main(["install", "pytest-blender", "--user"])`


> [!CAUTION]
> **MacOS**
> Installing Blender in an isolated environment may be preferable. We occasionally found some issues with the `pytest` installation for Blender, where it seemed that running pytest from a different environment would use the `pytest` installed in the Blender environment. To troubleshoot this, it may be useful to run `which pytest`from the active environment: if all is working fine, that should point to the `pytest` of the active environment. One can also force to run the `pytest` installation of the active environment by running `python -m pytest`.
> The following steps were needed to install these dependencies correctly on MacOS:
> - `get-pip.py` downloaded (this step may not be needed since newer versions of Blender have pip installed already in the Blender python)
> - Changing Mac permissions to grant full disk access from where you're running pytest i.e. VS code or terminal
> - `/Applications/Blender.app/Contents/Resources/3.4/python/bin/python3.10 -m pip install pytest -t "/Applications/Blender.app/Contents/Resources/3.4/python/lib/python3.10/site-packages"` the target flag -t makes sure that the installation ends up in the correct place
**Linux**

An easy way to install these dependencies correctly in Linux is to run the following code in [Blender's Python scripting window](https://docs.blender.org/api/current/info_quickstart.html):
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved
```
import pip
pip.main(["install", "pytest", "--user"])
pip.main(["install", "pytest-cov", "--user"])
pip.main(["install", "pytest-blender", "--user"])
```
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved


**MacOS**

The following steps were needed to install these dependencies correctly on MacOS:
```
pip install pytest-blender
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved
pip install pytest
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved
blender_python="$(pytest-blender)"
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved
$blender_python -m ensurepip
$blender_python -m pip install . pytest
pytest --blender-executable /Applications/Blender.app/Contents/MacOS/Blender
ruaridhg marked this conversation as resolved.
Show resolved Hide resolved
```

## Contributions

Expand Down
Loading