blenderproc.python.utility.SetupUtility module¶
-
class
blenderproc.python.utility.SetupUtility.
SetupUtility
[source]¶ Bases:
object
-
static
_ensure_pip
(python_bin, packages_path, packages_import_path, pre_python_package_path, force_update=False)[source]¶ Make sure pip is installed and read in the already installed packages
Parameters: - python_bin (
str
) – Path to python binary. - packages_path (
str
) – Path where our pip packages should be installed - packages_import_path (
str
) – Path to site-packages in packages_path which contains the installed packages - pre_python_package_path (
str
) – Path that contains blender’s default pip packages - force_update (
bool
) – If True, the installed-packages-cache will be ignored and will be recollected based on the actually installed packages.
- python_bin (
-
static
_pip_install_packages
(required_packages, python_bin, packages_path, reinstall_packages=False, dry_run=False, use_custom_package_path=True)[source]¶ Installs the list of given pip packages in the given python environment.
Parameters: - required_packages – A list of pip packages that should be installed. The version number can be specified via the usual == notation.
- python_bin – Path to python binary.
- packages_path – Path where our pip packages should be installed
- reinstall_packages (
bool
) – Set to true, if all python packages should be reinstalled. - dry_run (
bool
) – If true, nothing will be installed and it will only be checked whether there are any potential packages to update/install. - use_custom_package_path (
bool
) – If True, the python packages are installed into a custom folder, separate from blenders own python packages.
Returns: Returns True, if any packages were update/installed or - if dry_run=True - if there are any potential packages to update/install.
-
static
check_if_setup_utilities_are_at_the_top
(path_to_run_file)[source]¶ Checks if the given python scripts has at the top an import to SetupUtility, if not an exception is thrown. With an explanation that each python script has to start with SetupUtility.
Parameters: path_to_run_file ( str
) – path to the used python script
-
static
clean_installed_packages_cache
(blender_path, major_version)[source]¶ Removes the json file containing a list of all installed pip packages (if it exists).
Parameters: - blender_path – The path to the blender main folder.
- major_version – The major version string of the blender installation.
-
static
determine_python_paths
(blender_path, major_version)[source]¶ Determines python binary, custom pip packages and the blender pip packages path.
Parameters: Return type: Returns: - The path to the python binary of the blender installation
- The path to the directory containing custom pip packages installed by BlenderProc
- The path to the directory containing pip packages installed by blender.
-
static
determine_temp_dir
(given_temp_dir)[source]¶ Finds and creates a temporary directory.
On linux the temp dir is per default placed in /dev/shm or /tmp. The name of the created temp dir contains a uuid, so multiple BlenderProc processes can run on one system.
Parameters: given_temp_dir ( str
) – A directory inside which the temp dir should be createdReturn type: str
Returns: The path to the created temp dir.
-
static
extract_file
(output_dir, file, mode='ZIP')[source]¶ Extract all members from the archive into output_dir.
Parameters:
-
static
extract_from_response
(output_dir, response)[source]¶ Extract all members from the archive to output_dir
Parameters: - output_dir (
str
) – the dir to zip file extract to - response (
Response
) – the response to a requested url that contains a zip file
- output_dir (
-
installed_packages
= {'gitpython': '3.1.18', 'h5py': '3.6.0', 'human-body-prior': None, 'imageio': '2.9.0', 'jinja2': '3.0.0', 'm2r2': '0.2.7', 'matplotlib': '3.5.1', 'mistune': '0.8.4', 'mkdocs': '1.2.3', 'numpy': None, 'opencv-contrib-python': '4.5.5.64', 'pillow': '8.3.2', 'pip': '22.1.2', 'pypng': '0.0.20', 'python-dateutil': '2.8.2', 'pytz': '2021.1', 'pyyaml': '5.1.2', 'scikit-image': '0.19.2', 'scikit-learn': '1.0.2', 'scipy': '1.7.3', 'setuptools': '58.1.0', 'smplx': None, 'sphinx': '1.8.5', 'sphinx-autodoc-typehints': '1.6.0', 'sphinx-rtd-theme': '0.4.3', 'wheel': None}¶
-
main_setup_called
= True¶
-
package_list_is_from_cache
= True¶
-
static
setup
(user_required_packages=None, blender_path=None, major_version=None, reinstall_packages=False, debug_args=None)[source]¶ Sets up the python environment.
- Makes sure all required pip packages are installed
- Prepares the given sys.argv
Parameters: - user_required_packages (
Optional
[List
[str
]]) – A list of python packages that are additionally necessary to execute the python script. - blender_path (
Optional
[str
]) – The path to the blender installation. If None, it is determined automatically based on the current python env. - major_version (
Optional
[str
]) – The version number of the blender installation. If None, it is determined automatically based on the current python env. - reinstall_packages (
bool
) – Set to true, if all python packages should be reinstalled. - debug_args (
Optional
[List
[str
]]) – Can be used to overwrite sys.argv in debug mode.
-
static
setup_pip
(user_required_packages=None, blender_path=None, major_version=None, reinstall_packages=False, use_custom_package_path=True, install_default_packages=True)[source]¶ Makes sure the given user required and the general required python packages are installed in the blender proc env
At the first run all installed packages are collected via pip freeze. If a pip packages is already installed, it is skipped.
Parameters: - user_required_packages (
Optional
[List
[str
]]) – A list of pip packages that should be installed. The version number can be specified via the usual == notation. - blender_path (
Optional
[str
]) – The path to the blender installation. - major_version (
Optional
[str
]) – The version number of the blender installation. - reinstall_packages (
bool
) – Set to true, if all python packages should be reinstalled. - use_custom_package_path (
bool
) – If True, the python packages are installed into a custom folder, separate from blenders own python packages. - install_default_packages (
bool
) – If True, general required python packages are made sure to be installed.
Return type: Returns: Returns the path to the directory which contains all custom installed pip packages.
- user_required_packages (
-
static
setup_utility_paths
(temp_dir)[source]¶ Set utility paths: Temp dir and working dir.
Parameters: temp_dir ( str
) – Path to temporary directory where Blender saves output. Default is shared memory.
-
static