Extensions: Support platforms for command-line + Cleanup #122229

Open
Dalai Felinto wants to merge 3 commits from dfelinto/blender:extension-platform into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

To be committed as individual commits:

  • Extensions: Include platforms on the server-generate index.json
  • Extensions: Support multiple versions/platforms on the same server .json
  • Cleanup commit.

"The same extension can be listed on the same json as long as they have
different versions or their platforms don't overlap."

To be committed as individual commits: * Extensions: Include platforms on the server-generate index.json * Extensions: Support multiple versions/platforms on the same server .json * Cleanup commit. "The same extension can be listed on the same json as long as they have different versions or their platforms don't overlap."
Dalai Felinto added 1 commit 2024-05-24 17:41:45 +02:00
Dalai Felinto added this to the Python API project 2024-05-24 17:41:50 +02:00
Dalai Felinto requested review from Campbell Barton 2024-05-24 17:41:59 +02:00
Dalai Felinto force-pushed extension-platform from b98d6b68f9 to 6783338b7b 2024-05-24 20:25:58 +02:00 Compare
Campbell Barton requested changes 2024-05-28 07:24:09 +02:00
@ -218,2 +218,4 @@
# Generic Functions
class Platforms:

I'd rather not define a class for this, it seems like this can remain a plain data type (list of strings) which is validated using a validate function.

Although I'd need to check on changing this as I'm not totally clear on what problems defining this class solves.

I'd rather not define a class for this, it seems like this can remain a plain data type (list of strings) which is validated using a validate function. Although I'd need to check on changing this as I'm not totally clear on what problems defining this class solves.
@ -219,1 +219,4 @@
class Platforms:
_all_platforms = {

This list should note how the ID's are created, I'd assume it's:

"{:s}-{:s}".format(platform.system().lower(), platform.machine())

... but worth including for reference when we add new platforms.


_all_platforms (leading underscore) is meant for private class members, when this is being referenced outside of it's own methods.

I'd suggest to make this uppercase global PLATFORMS_KNOWN and declare at the top of the file - similar to URL_KNOWN_PREFIX.

This list should note how the ID's are created, I'd assume it's: `"{:s}-{:s}".format(platform.system().lower(), platform.machine())` ... but worth including for reference when we add new platforms. ---- `_all_platforms` (leading underscore) is meant for private class members, when this is being referenced outside of it's own methods. I'd suggest to make this uppercase global `PLATFORMS_KNOWN` and declare at the top of the file - similar to `URL_KNOWN_PREFIX`.
@ -220,0 +238,4 @@
for platform in self._platforms:
if platform in self._all_platforms:
continue
print(f"Error: platform {platform} not valid!")

Printing is not allowed (this will raise an exception), if there is a warning or error, it needs to be forwarded as a warning/error typed message to the process that invokes it, this way Blender receives all warnings/errors properly.

In this case the print can just be removed as validation will warn.

Printing is not allowed (this will raise an exception), if there is a warning or error, it needs to be forwarded as a warning/error typed message to the process that invokes it, this way Blender receives all warnings/errors properly. In this case the print can just be removed as validation will warn.
@ -1261,0 +1305,4 @@
_ = strict
# Always strict for now as it doesn't seem as there are repositories using invalid values.
strict = True
if strict:

We could be more relaxed about this:

For example: only check the values are unique and include a "-" separator.

I don't see a reason a FreeBSD user would be prevented from making and using their own extensions because we chose to hard code supported strings.

We could be more relaxed about this: For example: only check the values are unique and include a "-" separator. I don't see a reason a FreeBSD user would be prevented from making and using their own extensions because we chose to hard code supported strings.
Author
Owner

ok, I see your point. as long as it follows the "-" separated schema it should be fine.

ok, I see your point. as long as it follows the "-" separated schema it should be fine.
@ -2031,0 +2093,4 @@
# * platform
is_duplicated = False
version = manifest_dict['version']

As I understood it, multiple versions of the same package should only be supported when they support non-overlapping Blender versions or platforms.

In this case we would not check the version at all, and instead check the blender version ranges don't overlap.


Note that I think it would be reasonable to leave the version checks out of this PR entirely.

As I understood it, multiple versions of the same package should _only_ be supported when they support non-overlapping Blender versions or platforms. In this case we would not check the `version` at all, and instead check the blender version ranges don't overlap. ---- Note that I think it would be reasonable to leave the version checks out of this PR entirely.
Author
Owner

Right. In this case I think the logic should be:

  • If the name is not unique:
    • make sure the blender_version_min range is unique; or
    • make sure the platforms are not overlapping

In the ideal world, we could even show only the latest version if there is still a clash (using semver comparison).

Right. In this case I think the logic should be: * If the name is not unique: * make sure the blender_version_min range is unique; or * make sure the platforms are not overlapping In the ideal world, we could even show only the latest version if there is still a clash (using semver comparison).
@ -2031,0 +2096,4 @@
version = manifest_dict['version']
platforms = Platforms(manifest_dict)
for extension_iter in (ext for ext in repo_data if ext["id"] == manifest_dict["id"]):

Looping over all extensions to check for a match isn't great, to simplify review I think it's fine to change the lookups in a separate commit though.

Looping over all extensions to check for a match isn't great, to simplify review I think it's fine to change the lookups in a separate commit though.
Author
Owner

This PR has 3 separate commits, aimed originally at being committed separately.

This PR has 3 separate commits, aimed originally at being committed separately.
@ -0,0 +33,4 @@
class TestPlatform(unittest.TestCase):
@staticmethod
def _get_manifest(arguments: List) -> dict:

picky: -> dict -> Dict[str, Any]

picky: `-> dict` -> `Dict[str, Any]`
Author
Owner

Replied to your points. Feel free to take over

Replied to your points. Feel free to take over
This pull request has changes conflicting with the target branch.
  • scripts/addons_core/bl_pkg/Makefile
  • scripts/addons_core/bl_pkg/cli/blender_ext.py

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u extension-platform:dfelinto-extension-platform
git checkout dfelinto-extension-platform
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#122229
No description provided.