Use a static tmp dir for user manual builds

This commit is contained in:
Kovid Goyal 2025-06-20 10:28:23 +05:30
parent 07274c3ffa
commit f8deedd4c8
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 11 additions and 6 deletions

View File

@ -296,3 +296,9 @@ def installer_names(include_source=True):
yield f'{base}-{__version__}-{arch}.txz'
if include_source:
yield f'{base}-{__version__}.tar.xz'
@lru_cache
def manual_build_dir():
# cant use tempfile.gettempdir() as calibre.startup overrides it
return os.path.join('/tmp', 'user-manual-build')

View File

@ -11,10 +11,9 @@ import os
import shutil
import subprocess
import sys
import tempfile
import time
from setup import Command, __version__, installer_names, require_clean_git, require_git_master
from setup import Command, __version__, installer_names, manual_build_dir, require_clean_git, require_git_master
from setup.parallel_build import create_job, parallel_build
@ -180,7 +179,7 @@ class Manual(Command):
)
def run(self, opts):
tdir = self.j(tempfile.gettempdir(), 'user-manual-build')
tdir = manual_build_dir()
if os.path.exists(tdir):
shutil.rmtree(tdir)
os.mkdir(tdir)

View File

@ -15,7 +15,7 @@ import subprocess
import sys
import time
from subprocess import check_call
from tempfile import NamedTemporaryFile, gettempdir, mkdtemp
from tempfile import NamedTemporaryFile, mkdtemp
from zipfile import ZipFile
from polyglot.builtins import iteritems
@ -25,7 +25,7 @@ if __name__ == '__main__':
d = os.path.dirname
sys.path.insert(0, d(d(os.path.abspath(__file__))))
from setup import Command, __appname__, __version__, installer_names
from setup import Command, __appname__, __version__, installer_names, manual_build_dir
DOWNLOADS = '/srv/main/downloads'
HTML2LRF = 'calibre/ebooks/lrf/html/demo'
@ -343,7 +343,7 @@ class UploadUserManual(Command): # {{{
for x in glob.glob(self.j(path, '*')):
self.build_plugin_example(x)
srcdir = self.j(gettempdir(), 'user-manual-build', 'en', 'html') + '/'
srcdir = self.j(manual_build_dir(), 'en', 'html') + '/'
check_call(
' '.join(
['rsync', '-zz', '-rl', '--info=progress2', srcdir, 'main:/srv/manual/']