Fix several issues with building static media files.
Review Request #12413 — Created June 24, 2022 and submitted — Latest diff uploaded
We had issues that popped up with building of static media files. These
didn't prevent building static media, but mostly because we're lucky.The first issue is that
FORCE_BUILD_MEDIA
wasn't being respected. We
were setting that usingos.putenv()
inbuild-media.py
, but
settings.py
was getting an empty string out when usingos.getenv()
.When calling
os.putenv()
, we don't actually modify the current
process, just subprocesses. The correct API to use is justos.environ
,
which stores the variable in the local process's environment and wraps
os.putenv()
for subprocesses.This has been updated to just use
os.environ
in all cases.Another is that we had conflicts when building files. Both
AppDirectoriesFinder
andFileSystemFinder
would find the exact same
static media files, and this would log complaints about duplicates.
Likely this isn't new behavior, but the logging is new.The reason for the conflict is that we defined specific directories
containing static media files to process (forrb
,djblets
, and
lib
), where thedjblets
version was also found in thedjblets
app
andrb
andlib
were found in thereviewboard
app (both in
static/
directories).We need
reviewboard
anddjblets
apps to be inINSTALLED_APPS
,
since we reference templates and other state from there. Given that we
need these, and both containstatic/
directories, we can get by with
justAppDirectoriesFinder
. There's no need to keepFileSystemFinder
anymore, or maintain a list ofSTATICFILES_DIRS
.
Tested a complete static files rebuild with both finders, without
FileSystemFinder
, and withoutAppDirectoriesFinder
. Backed up each
version and compared directory contents.Removing
FileSystemFinder
had no effect on the contents of the directory,
but it did remove the errors.Removing
AppDirectoriesFinder
caused a change in what files we collected,
ruling that out as an option.Successfully built packages, ran the server without any static media issues,
and ran unit tests.