diff options
author | Owl <isaclien9752@gmail.com> | 2025-08-23 17:13:49 -0400 |
---|---|---|
committer | Owl <isaclien9752@gmail.com> | 2025-08-23 17:13:49 -0400 |
commit | 4bc406964fd6809e8e77b7bb0c5317f5cb94a1a8 (patch) | |
tree | 502ef662bd15ea0045b941786ff27a236c23f760 | |
parent | 0ab9e972cb4a4128c2041f6da580a72515b3db64 (diff) | |
download | blenxy-4bc406964fd6809e8e77b7bb0c5317f5cb94a1a8.tar.gz blenxy-4bc406964fd6809e8e77b7bb0c5317f5cb94a1a8.zip |
ensure numpy updates
-rw-r--r-- | file_ops.py | 13 | ||||
-rw-r--r-- | required_modules.py | 15 |
2 files changed, 23 insertions, 5 deletions
diff --git a/file_ops.py b/file_ops.py index b9b3f6f..b482b88 100644 --- a/file_ops.py +++ b/file_ops.py @@ -237,3 +237,16 @@ def get_file_size(path): if (is_file(path) == False): return 0 return os.path.getsize(get_path_str(path)) + +# function to rename a folder or a file +def rename(current_name, new_name): + # check params + if (f_exists(current_name) == False + or f_exists(new_name) == True): + return False + # reformat the strings + current_name = get_path_str(current_name) + new_name = get_path_str(new_name) + #call os.rename() + os.rename(current_name, new_name) + return True diff --git a/required_modules.py b/required_modules.py index 069a1b7..8aecc7d 100644 --- a/required_modules.py +++ b/required_modules.py @@ -1,7 +1,6 @@ -import bpy +import bpy, numpy from subprocess import run from . import file_ops -import numpy # get python's binary path (literally my saviour) py_bin = bpy.app.binary_path_python @@ -20,9 +19,11 @@ except: # hecking install pip (ensurepip) + required modules run([py_bin, "-B", "-m", "ensurepip"]) # update basic modules then download new modules - # before that, rename the numpy folder to be able to update numpy run(pip_install + upd_mods) - run(pip_install + new_mods) + run(pip_install + new_mods) + # rename numpy's installation folder (cannot delete the folder in windows) + file_ops.rename(numpy.__path__[0], numpy.__path__[0] + "_bad") + run(pip_install + ["numpy==1.18.5"]) # install a newer version print("First exit!") bpy.ops.wm.quit_blender() exit(0) @@ -33,6 +34,10 @@ print("lxml %s is installed!" % (lxml.__version__)) # for those who have installed blenxy before, update numpy # hacky way to do it but it is the only way that works if (numpy.__version__ != "1.18.5"): - file_ops.rm_folder(numpy.__path__[0]) # remove the installation folder + # rename numpy's installation folder (cannot delete the folder in windows) + file_ops.rename(numpy.__path__[0], numpy.__path__[0] + "_bad") run(pip_install + ["numpy==1.18.5"]) # install a newer version + print("Second exit!") + bpy.ops.wm.quit_blender() + exit(0) print("numpy %s is installed!" % (numpy.__version__)) |