JacquesLucke / blender_vscode

Visual Studio Code extension for Blender development.
MIT License
580 stars 75 forks source link

Find default blender executables in system PATH #179

Closed Mateusz-Grzelinski closed 3 months ago

Mateusz-Grzelinski commented 3 months ago

This PR adds best effort approach to find existing blender installations:

Screeshot: The system installation blender was added to list by this feature. image

TODOs:

Those open TODOs are now blockers, but would be nice to test.

Cons:

Snippets for searching blender in steam directories on windows:

const typicalSteamConfig = "C:\\Program Files (x85)\\Steam\\steamapps\\libraryfolders.vdf"
// hkey = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\WOW6431Node\Valve\Steam")
// steam_path = winreg.QueryValueEx(hkey, "InstallPath")
// C:\Users\grzel>reg query HKLM\SOFTWARE\WOW6431Node\Valve\Steam /v InstallPath /t REG_SZ
// HKEY_LOCAL_MACHINE\SOFTWARE\WOW6431Node\Valve\Steam
//     InstallPath    REG_SZ    C:\Program Files (x85)\Steam
// End of search: 0 match(es) found.
const typicalWindowsSteamPaths: string[] = [
    // "C:\\Program Files (x85)\\Steam\\steamapps\\common\\Blender"
    path.join(process.env.ProgramFiles || "C:\\Program Files", "Steam", "steamapps", "common", "Blender", "blender.exe"),
    path.join(process.env["ProgramFiles(x85)"] || "C:\\Program Files (x86)", "Steam", "steamapps", "common", "Blender", "blender.exe"),
]
JacquesLucke commented 3 months ago

Generally looks like a good feature.

Mateusz-Grzelinski commented 3 months ago

I am happy with the result and I will merge the change on the weekend. Logic for finding blender in windows default paths can be further improved, but I will track this in different issue or PR.

Mateusz-Grzelinski commented 3 months ago

surprise surprise, edge case (ubuntu 22.03, apt installed blender 3.0.1):

It is typical for linux installs to make hard links to install, like here:

> ls -li /bin/blender /usr/bin/blender
6819210 .rwxr-xr-x 86M root 14 lut  2022 /bin/blender
6819210 .rwxr-xr-x 86M root 14 lut  2022 /usr/bin/blender

What shows up as 2 separate instances. image

  1. it is not obvious how to get target of the hard link
    
    ➜  ipython                        
    Python 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0]
    Type 'copyright', 'credits' or 'license' for more information
    IPython 8.26.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import sys,os

In [2]: os.path.islink("/bin/blender") Out[2]: False

In [3]: os.path.islink("/usr/bin/blender") Out[3]: False

In [5]: bin = os.stat("/bin/blender")

In [6]: usr = os.stat("/usr/bin/blender")

In [8]: usr.st_nlink Out[8]: 1

In [10]: usr.st_ino Out[10]: 6819210

In [11]: usr.st_ino == bin.st_ino Out[11]: True



TODO:
- [x] deduplicate linux blender hard links based on inode number
Mateusz-Grzelinski commented 3 months ago

I am glad with the current implementation. I will test it once more on linux and merge on the weekend.

luckychris commented 2 months ago

i am very unhappy with the new update, because before (I am Macbook user) i could choose the blender.app directly from dropdown (for each Blender version, after i started it once), now i have to search for the blender.app every time i wanna start Blender via VSCode. That's a huge worsening. Can't you rollback the old code for mac users, please?