Page MenuHome

Add-ons: Exclude contrib for beta, rc and release builds
ClosedPublic

Authored by Thomas Dinges (dingto) on Dec 9 2022, 4:42 PM.

Details

Summary
  • Make it clearer that contrib isn't shipped with releases, by already excluding it in beta
  • Hide the "Testing" enum item in that case

Diff Detail

Event Timeline

Thomas Dinges (dingto) requested review of this revision.Dec 9 2022, 4:42 PM
Thomas Dinges (dingto) created this revision.
Campbell Barton (campbellbarton) requested changes to this revision.Dec 12 2022, 11:16 AM

Since this doesn't change at run-time, a static value can be assigned.

Example noted inline.

release/scripts/startup/bl_ui/__init__.py
153–155
This revision now requires changes to proceed.Dec 12 2022, 11:16 AM
Sybren A. Stüvel (sybren) added inline comments.
release/scripts/startup/bl_ui/__init__.py
153–155

I would keep the code simpler, as Thomas has things now. The suggested code this has so much nesting it becomes harder to read & understand.

157

I find the 'set of strings' notation a lot easier to read. What does 1 even mean here?

release/scripts/startup/bl_ui/__init__.py
153–155

PS: if you want to have this a "static" property, the addon_support_items() function can just be defined at the module level (and named _addon_support_items() to indicate it's "private") and used to determine the enum items just once.

Update patch to avoid the extra function as Campbell suggested. This way the defalt set of strings can be kept.

@Sybren A. Stüvel (sybren) I used the integer, as Blender complained about the set of strings, if the items are defined within a function.

Thomas Dinges (dingto) edited the summary of this revision. (Show Details)Dec 12 2022, 12:02 PM

I'm not a huge fan of the "let's concatenate things, but concatenate an empty tuple if we shouldn't" approach.

Something like this seems a bit clearer to me. It also avoids the ugly (subjective, I know) tuple-of-one notation.

@staticmethod
def _addon_support_items():
    """Return the addon support levels suitable for this Blender build."""

    items = [
        ('OFFICIAL', "Official", "Officially supported"),
        ('COMMUNITY', "Community", "Maintained by community developers"),
    ]
    if bpy.app.version_cycle == 'rc':
        items.append(('TESTING', "Testing", "Newly contributed scripts (excluded from release builds)"))
    return items

WindowManager.addon_support = EnumProperty(
    items=_addon_support_items(),
    name="Support",
    description="Display support level",
    default={'OFFICIAL', 'COMMUNITY'},
    options={'ENUM_FLAG'},
)

Update patch to avoid the extra function as Campbell suggested. This way the defalt set of strings can be kept.

This doesn't have anything to do with using a function. It has to do with how the function is used ;-)

@Sybren A. Stüvel (sybren) I used the integer, as Blender complained about the set of strings, if the items are defined within a function.

Ugh.

I don't mind, so fine with the static function approach. :)

release/scripts/startup/bl_ui/__init__.py
97–98

My bad, remove the @staticmethod. I typed it too quickly and mixed up "indentation because in a class" and "indentation because in a function" ;-)

Remove unnescecary decorator.

This revision is now accepted and ready to land.Dec 13 2022, 11:04 AM