-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support distributing as Blender extension
- Loading branch information
Showing
11 changed files
with
142 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,48 @@ | ||
import platform | ||
import os | ||
|
||
bl_info = { | ||
"name": "Plumber", | ||
"author": "Lassi Säike", | ||
"version": (1, 1, 1), | ||
"blender": (2, 90, 0), | ||
"location": "File > Import -> Plumber", | ||
"description": "Imports Source Engine assets.", | ||
"warning": "", | ||
"tracker_url": "https://github.com/lasa01/plumber", | ||
"category": "Import-Export", | ||
} | ||
|
||
version = bl_info["version"] | ||
version_pre = bl_info["warning"] | ||
|
||
version_str = ".".join(map(str, version)) | ||
|
||
if version_pre != "": | ||
version_str += f"-{version_pre}" | ||
|
||
# check if imported by setup.py or actually running in Blender | ||
try: | ||
from bpy.app import version as bpy_version | ||
except ImportError: | ||
bpy_version = None | ||
|
||
if bpy_version is not None: | ||
is_windows = platform.system() == "Windows" | ||
|
||
def register(): | ||
if is_windows: | ||
# Check if the extension module was renamed on the last unregister, | ||
# and either rename it back or delete it if the addon was updated with a newer extension module | ||
ext_path = os.path.join(os.path.dirname(__file__), "plumber.pyd") | ||
unloaded_ext_path = os.path.join( | ||
os.path.dirname(os.path.dirname(__file__)), "plumber.pyd.unloaded" | ||
) | ||
|
||
if os.path.isfile(unloaded_ext_path): | ||
if os.path.isfile(ext_path): | ||
try: | ||
os.remove(unloaded_ext_path) | ||
except OSError: | ||
print( | ||
"[Plumber] [WARN] old files remaining, restart Blender to finish post-update clean up" | ||
) | ||
else: | ||
os.rename(unloaded_ext_path, ext_path) | ||
|
||
from . import addon | ||
|
||
addon.register() | ||
|
||
def unregister(): | ||
from . import addon | ||
|
||
addon.unregister() | ||
|
||
if is_windows: | ||
# Rename the extension module to allow updating the addon without restarting Blender, | ||
# since the extension module will stay open and can't be overwritten even if the addon is unloaded | ||
ext_path = os.path.join(os.path.dirname(__file__), "plumber.pyd") | ||
unloaded_ext_path = os.path.join( | ||
os.path.dirname(os.path.dirname(__file__)), "plumber.pyd.unloaded" | ||
) | ||
|
||
try: | ||
os.rename(ext_path, unloaded_ext_path) | ||
except OSError: | ||
pass | ||
is_windows = platform.system() == "Windows" | ||
|
||
|
||
def register(): | ||
if is_windows: | ||
# Check if the extension module was renamed on the last unregister, | ||
# and either rename it back or delete it if the addon was updated with a newer extension module | ||
ext_path = os.path.join(os.path.dirname(__file__), "plumber.pyd") | ||
unloaded_ext_path = os.path.join( | ||
os.path.dirname(os.path.dirname(__file__)), "plumber.pyd.unloaded" | ||
) | ||
|
||
if os.path.isfile(unloaded_ext_path): | ||
if os.path.isfile(ext_path): | ||
try: | ||
os.remove(unloaded_ext_path) | ||
except OSError: | ||
print( | ||
"[Plumber] [WARN] old files remaining, restart Blender to finish post-update clean up" | ||
) | ||
else: | ||
os.rename(unloaded_ext_path, ext_path) | ||
|
||
from . import addon | ||
|
||
addon.register() | ||
|
||
|
||
def unregister(): | ||
from . import addon | ||
|
||
addon.unregister() | ||
|
||
if is_windows: | ||
# Rename the extension module to allow updating the addon without restarting Blender, | ||
# since the extension module will stay open and can't be overwritten even if the addon is unloaded | ||
ext_path = os.path.join(os.path.dirname(__file__), "plumber.pyd") | ||
unloaded_ext_path = os.path.join( | ||
os.path.dirname(os.path.dirname(__file__)), "plumber.pyd.unloaded" | ||
) | ||
|
||
try: | ||
os.rename(ext_path, unloaded_ext_path) | ||
except OSError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
schema_version = "1.0.0" | ||
|
||
id = "plumber" | ||
version = "1.1.1" | ||
name = "Plumber" | ||
tagline = "Imports Source 1 engine maps, models, materials and textures" | ||
maintainer = "Lassi Säike <[email protected]>" | ||
type = "add-on" | ||
website = "https://github.com/lasa01/Plumber" | ||
tags = ["Import-Export"] | ||
blender_version_min = "4.2.0" | ||
license = ["SPDX:GPL-3.0-or-later"] | ||
platforms = ["windows-x64", "macos-x64", "macos-arm64", "linux-x64"] | ||
|
||
[permissions] | ||
files = "Import/extract assets from/to disk, detect installed games" | ||
|
||
[build] | ||
paths_exclude_pattern = ["__pycache__/", "/.git/", "/*.zip", "/*.pyi"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
[build-system] | ||
requires = ["setuptools", "setuptools-rust", "blender.distutils"] | ||
requires = ["setuptools", "setuptools-rust", "toml"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
fake-bpy-module-2.82 | ||
setuptools | ||
setuptools-rust | ||
blender.distutils | ||
black | ||
toml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters