From f4ff299e4e073b71495a3e2a385fa96d65fb6f80 Mon Sep 17 00:00:00 2001 From: Owl Date: Wed, 27 Aug 2025 23:54:31 -0400 Subject: rotations people, rotations... --- __init__.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to '__init__.py') diff --git a/__init__.py b/__init__.py index 5b0949c..3eebb3f 100644 --- a/__init__.py +++ b/__init__.py @@ -6,6 +6,7 @@ # that the python interpreter must have built in import bpy, importlib, sys, subprocess, os, shutil import math, mathutils, warnings, struct, site +from . import file_ops # elemental python modules blenxy needs # that the python interpreter probably does not have built in/needs to be updated @@ -14,12 +15,31 @@ new_modules = ["lxml", "numpy"] # check which of the new modules needs to be installed def new_mod_check(mod_names): + # variable to return rtn = [] + + # traverse into all the new_modules for mod_name in mod_names: + # skip numpy if the numpy_bad folder was created + if (mod_name == "numpy"): + for path in site.getsitepackages(): + if ("2.79" in path): + numpy_path = path + "/numpy" + numpy_bad_path = path + "/numpy_bad" + # rename the existing numpy folder to numpy bad and install newer numpy + if (file_ops.f_exists(numpy_bad_path) == False): + file_ops.rename(numpy_path, numpy_bad_path) + rtn.append("numpy") + break + continue + + # try importing the module try: importlib.import_module(mod_name) except: rtn.append(mod_name) + + # done! return rtn # install given modules with pip but be sure to have pip first @@ -42,14 +62,6 @@ def new_mod_install(mod_names): # install the rest of the modules if (mod_names != []): for mod_name in mod_names: - if (mod_name == "numpy"): # specific to the numpy module - # get the numpy package path - numpy_path = None - for path in site.getsitepackages(): - if ("2.79" in path): - numpy_path = path + "/numpy" - break - os.rename(numpy_path, numpy_path + "_bad") # normal module installation subprocess.run(pip_install + [mod_name]) return True -- cgit v1.2.3-70-g09d2