djblets.extensions.packaging¶
Support for packaging extensions.
Changed in version 5.0: This has been split into sub-modules. Consumers should update any older
imports for this module to instead import from
djblets.extensions.packaging.setuptools_backend
.
- class BuildPy(*args, **kwargs)¶
Bases:
ClassMovedMixin
,BuildPy
Setuptools command for building Python files.
This is meant as a replacement for the standard
build_py
command that will trigger a build of static media files.Deprecated since version 5.0: This has been moved to
djblets.extensions.packaging. setuptools_backend.BuildPy
. The legacy import will be removed in Djblets 7.- __annotations__ = {}¶
- class BuildStaticFiles(*args, **kwargs)¶
Bases:
ClassMovedMixin
,BuildStaticFiles
Builds static files for the extension.
This will build the static media files used by the extension. JavaScript bundles will be minified and versioned. CSS bundles will be processed through LessCSS (if using
.less
files), minified and versioned.This must be subclassed by the project offering the extension support. The subclass must provide the
extension_entrypoint_group
anddjango_settings_module parameters
.Deprecated since version 5.0: This has been moved to
djblets.extensions.packaging. setuptools_backend.BuildStaticFiles
. The legacy import will be removed in Djblets 7.- npm_install(package_spec: Optional[str] = None) None ¶
Install a package via npm.
This will first determine if npm is available, and then attempt to install the given package.
Deprecated since version 5.0: This will be removed in Djblets 7. Please see
StaticMediaBuilder
for build customization.- Parameters:
package_spec (
str
, optional) – The package specification (name and optional version range) to install. If not specified, this will use the default behavior of readingpackage.json
.
- get_lessc_global_vars() dict[str, Any] ¶
Return a dictionary of LessCSS global variables and their values.
This can be implemented by subclasses to provide global variables for .less files for processing.
By default, this defines two variables:
STATIC_ROOT
andDEBUG
.STATIC_ROOT
is set to/static/
. Any imports using@{STATIC_ROOT}
will effectively look up the requested file in<import_path>/@{STATIC_ROOT}
. This assumes that the project serving the static files keeps them instatic/appname/
.Projects using less.js for the runtime can then define
STATIC_ROOT
tosettings.STATIC_URL
, ensuring lookups work for development and packaged extensions.DEBUG
is set to false. Runtimes using less.js can set this tosettings.DEBUG
for templates. This can be useful for LessCSS guards.Deprecated since version 5.0: This will be removed in Djblets 7. Please see
StaticMediaBuilder
for build customization.- Returns:
A dictionary mapping variable names to values.
- Return type:
- __annotations__ = {}¶
- build_extension_cmdclass(build_static_files_cls: type[djblets.extensions.packaging.BuildStaticFiles]) dict[str, type] ¶
Build a Setuptools cmdclass for building extensions.
This is passed a subclass of
BuildStaticFiles
, and returns something that can be passed tosetup()
.Deprecated since version 5.0: This has been moved to
djblets.extensions.packaging. setuptools_backend.build_extension_cmdclass
. The legacy import will be removed in Djblets 7.- Parameters:
build_static_files_cls (
type
) – The subclass ofBuildStaticFiles
.- Returns:
The resulting Setuptools command classes to use.
- Return type: