2024-03-20 12:55:40 +01:00
|
|
|
from pathlib import Path
|
|
|
|
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
from . import info
|
|
|
|
from .nodeps.utils import simple_logger
|
2024-03-20 12:55:40 +01:00
|
|
|
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
simple_logger.sync_bootstrap_logging(
|
|
|
|
console_level=info.BOOTSTRAP_LOG_LEVEL,
|
|
|
|
)
|
2024-03-20 12:55:40 +01:00
|
|
|
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
from . import nodeps, preferences, registration # noqa: E402
|
|
|
|
from .nodeps.utils import pydeps # noqa: E402
|
|
|
|
|
|
|
|
log = simple_logger.get(__name__)
|
2024-02-06 21:44:43 +01:00
|
|
|
|
|
|
|
####################
|
2024-03-20 12:55:40 +01:00
|
|
|
# - Addon Information
|
2024-02-06 21:44:43 +01:00
|
|
|
####################
|
2024-03-20 12:55:40 +01:00
|
|
|
# The following parameters are replaced when packing the addon ZIP
|
|
|
|
## - description
|
|
|
|
## - version
|
|
|
|
bl_info = {
|
|
|
|
'name': 'Maxwell PDE Sim and Viz',
|
|
|
|
'blender': (4, 1, 0),
|
|
|
|
'category': 'Node',
|
|
|
|
'description': 'Placeholder',
|
|
|
|
'author': 'Sofus Albert Høgsbro Rose',
|
|
|
|
'version': (0, 0, 0),
|
|
|
|
'wiki_url': 'https://git.sofus.io/dtu-courses/bsc_thesis',
|
|
|
|
'tracker_url': 'https://git.sofus.io/dtu-courses/bsc_thesis/issues',
|
|
|
|
}
|
|
|
|
## bl_info MUST readable via. ast.parse
|
|
|
|
## See scripts/pack.py::BL_INFO_REPLACEMENTS for active replacements
|
|
|
|
## The mechanism is a 'dumb' - output of 'ruff fmt' MUST be basis for replacing
|
|
|
|
|
|
|
|
|
2024-02-06 21:44:43 +01:00
|
|
|
####################
|
2024-03-20 12:55:40 +01:00
|
|
|
# - Load and Register Addon
|
2024-02-06 21:44:43 +01:00
|
|
|
####################
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
log.info('Loading Before-Deps BL_REGISTER')
|
2024-03-20 12:55:40 +01:00
|
|
|
BL_REGISTER__BEFORE_DEPS = [
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
*nodeps.operators.BL_REGISTER,
|
2024-03-20 12:55:40 +01:00
|
|
|
*preferences.BL_REGISTER,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def BL_REGISTER__AFTER_DEPS(path_deps: Path):
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
log.info('Loading After-Deps BL_REGISTER')
|
2024-03-20 12:55:40 +01:00
|
|
|
with pydeps.importable_addon_deps(path_deps):
|
|
|
|
from . import node_trees, operators
|
|
|
|
return [
|
|
|
|
*operators.BL_REGISTER,
|
|
|
|
*node_trees.BL_REGISTER,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
log.info('Loading Before-Deps BL_KEYMAP_ITEM_DEFS')
|
|
|
|
BL_KEYMAP_ITEM_DEFS__BEFORE_DEPS = [
|
|
|
|
*nodeps.operators.BL_KEYMAP_ITEM_DEFS,
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def BL_KEYMAP_ITEM_DEFS__AFTER_DEPS(path_deps: Path):
|
|
|
|
log.info('Loading After-Deps BL_KEYMAP_ITEM_DEFS')
|
2024-03-20 12:55:40 +01:00
|
|
|
with pydeps.importable_addon_deps(path_deps):
|
2024-02-06 21:44:43 +01:00
|
|
|
from . import operators
|
2024-03-20 12:55:40 +01:00
|
|
|
return [
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
*operators.BL_KEYMAP_ITEM_DEFS,
|
2024-03-20 12:55:40 +01:00
|
|
|
]
|
2024-02-06 21:44:43 +01:00
|
|
|
|
|
|
|
|
|
|
|
####################
|
|
|
|
# - Registration
|
|
|
|
####################
|
|
|
|
def register():
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
"""Register the Blender addon."""
|
|
|
|
log.info('Starting %s Registration', info.ADDON_NAME)
|
|
|
|
|
2024-03-20 12:55:40 +01:00
|
|
|
# Register Barebones Addon for Dependency Installation
|
|
|
|
registration.register_classes(BL_REGISTER__BEFORE_DEPS)
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
registration.register_keymap_items(BL_KEYMAP_ITEM_DEFS__BEFORE_DEPS)
|
2024-03-20 12:55:40 +01:00
|
|
|
|
|
|
|
# Retrieve PyDeps Path from Addon Preferences
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
if (addon_prefs := info.addon_prefs()) is None:
|
|
|
|
unregister()
|
|
|
|
msg = f'Addon preferences not found; aborting registration of {info.ADDON_NAME}'
|
|
|
|
raise RuntimeError(msg)
|
|
|
|
log.debug('Found Addon Preferences')
|
|
|
|
|
|
|
|
# Retrieve PyDeps Path
|
|
|
|
path_pydeps = addon_prefs.pydeps_path
|
|
|
|
log.info('Loaded PyDeps Path from Addon Prefs: %s', path_pydeps)
|
2024-03-20 12:55:40 +01:00
|
|
|
|
|
|
|
if pydeps.check_pydeps(path_pydeps):
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
log.info('PyDeps Satisfied: Loading Addon %s', info.ADDON_NAME)
|
|
|
|
registration.register_classes(BL_REGISTER__AFTER_DEPS(path_pydeps))
|
|
|
|
registration.register_keymap_items(BL_KEYMAP_ITEM_DEFS__AFTER_DEPS(path_pydeps))
|
2024-03-20 12:55:40 +01:00
|
|
|
else:
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
log.info(
|
|
|
|
'PyDeps Invalid: Delaying Addon Registration of %s',
|
|
|
|
info.ADDON_NAME,
|
|
|
|
)
|
2024-03-20 12:55:40 +01:00
|
|
|
registration.delay_registration(
|
|
|
|
registration.EVENT__DEPS_SATISFIED,
|
|
|
|
classes_cb=BL_REGISTER__AFTER_DEPS,
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
keymap_item_defs_cb=BL_KEYMAP_ITEM_DEFS__AFTER_DEPS,
|
2024-03-10 11:56:37 +01:00
|
|
|
)
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
## TODO: bpy Popup to Deal w/Dependency Errors
|
2024-03-20 12:55:40 +01:00
|
|
|
|
|
|
|
|
2024-02-06 21:44:43 +01:00
|
|
|
def unregister():
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
"""Unregister the Blender addon."""
|
|
|
|
log.info('Starting %s Unregister', info.ADDON_NAME)
|
2024-03-20 12:55:40 +01:00
|
|
|
registration.unregister_classes()
|
|
|
|
registration.unregister_keymap_items()
|
feat: Working logging, before- and after-deps.
We have a far more sane approach to nodeps now, which
allows us to essentially have two loggers - one that is
very useful, pretty, and clear, but requires a 'rich'
dependency, and one that is simple.
In this spirit, we factored out services/ too.
We can also set the initial console log level now when
packing the .zip.
There's still work to do with the actual flow for deps
installing / uninstalling.
But it should be far more robust now.
Finally, we have a barebones working `quartodoc`-based docs site.
It's super clever; see <https://github.com/machow/quartodoc>.
As it's "just" a quarto project with some python autodiscovery,
fleshing it out with ex. math, images, diagrams, and so forth
should be exceptionally easy.
As we develop, various linter-guided fixes are being realized.
This will be a long process, best done as we spiff everything up
in preparation for general release.
2024-03-21 18:45:38 +01:00
|
|
|
log.info('Finished %s Unregister', info.ADDON_NAME)
|