Add flexible support for packaging static media for extensions.
Review Request #13662 — Created March 24, 2024 and submitted
The old Djblets extension packaging code made a number of assumptions
about how extension static media would be packaged. It had some
capabilities to override settings (such as providing custom LessCSS
global variables), but made assumptions on the environmental setup and
the usage of setuptools.This change redoes much of this, splitting
djblets.extensions.packaging
into submodules forstatic_media
and
setuptools_backend
.The
static_media
module contains two classes:
-
StaticMediaBuildContext
: Manages state and general configuration for
building static media. -
StaticMediaBuilder
: Sets up a Django and Pipeline environment and
initiates the build process.
This can then be driven by a packaging backend. The setuptools_backend
module contains the original functions and classes comprising the
setuptools-based backend, though wrapping the new static_media
classes. Subclasses can set a custom class for either of the
static_media
classes on the Setuptools backend in order to customize
behavior.
One of the features of the new backend is support for defining a
.npm-workspaces
directory, which contains symlinks to other trees that
may provide static media files that may be needed by the build system.
This defaults to a djblets
symlink, but subclasses can add additional
backends.
Down the road, the expectation is that we'll have better support for
using modern pyproject.toml
-configured build backends for
extensions, and this change would help get us there.
The original classes can still be imported and used as before, but are
now deprecated, with useful information on moving to the modern classes.
Unit tests pass.
Tested building
rbintegrations
with this change, both with legacy
usage in Review Board and with updated usage.
Summary | ID |
---|---|
b1c45f8afaa5eff976393a7ddca4d8d1cce02daa |
- Change Summary:
-
- Fixed a typing issue in the deprecation handling for LessCSS global variables.
- Fixed import ordering issues with typing.
- LessCSS import paths are now sorted.
- Removed unused imports.
- Commits:
-
Summary ID 97d6c307d7c555715c81aa0a9fe59a792355d2dc ef162c450c7a70256393f540c95bfbe3364781db
Checks run (2 succeeded)
- Change Summary:
-
Added a missing unit test file.
- Commits:
-
Summary ID ef162c450c7a70256393f540c95bfbe3364781db b1c45f8afaa5eff976393a7ddca4d8d1cce02daa - Diff:
-
Revision 3 (+3416 -1062)