From 9024c3ec98cc6bdc5c62f17d9fe18b041a7487f4 Mon Sep 17 00:00:00 2001 From: idle sign Date: Sat, 5 Oct 2019 19:11:16 +0700 Subject: [PATCH] Initialize 'runtime' dir. --- tests/test_commands.py | 5 +++++ webscaff/commands/proj/utils.py | 3 ++- webscaff/overrides.py | 15 +++++++++++++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/test_commands.py b/tests/test_commands.py index 489a1bf..0799e92 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -22,8 +22,13 @@ def test_bootstrap(self, run_command_mock, monkeypatch): 'test -e "$(echo /srv/mydemo/venv)"', 'cd /srv/mydemo/mydemo', 'pip3 install -e .', + 'pip3 install wheel', 'pip3 install -r requirements.txt', 'ln -sf /srv/mydemo/venv/bin/mydemo /usr/bin/mydemo', + 'mkdir -p /srv/mydemo/runtime', + 'chown -R mydemo:mydemo /srv/mydemo/runtime', + 'setfacl -Rm "g:mydemo:rwX,d:g:mydemo:rwX" /srv/mydemo/runtime', + 'test -e "$(echo /srv/mydemo/runtime/environ)"', 'test -e "$(echo /srv/mydemo/runtime/environ)"', 'egrep "^production$" "/srv/mydemo/runtime/environ"', 'pg_config --version', diff --git a/webscaff/commands/proj/utils.py b/webscaff/commands/proj/utils.py index a13df7d..f5e8b50 100644 --- a/webscaff/commands/proj/utils.py +++ b/webscaff/commands/proj/utils.py @@ -34,11 +34,12 @@ def bootstrap(ctx): with ctx.cd(ctx.paths.remote.project.base): pip.install(ctx, package='.', editable=True) + pip.install(ctx, package='wheel') pip.install(ctx, from_req=True) fs.symlink_entypoint(ctx) - fs.upload_configs(ctx) + fs.create_dir(ctx, ctx.paths.remote.project.runtime.root) fs.create_environ_file(ctx) pg.bootstrap(ctx) diff --git a/webscaff/overrides.py b/webscaff/overrides.py index 39f92e7..7f3c42f 100644 --- a/webscaff/overrides.py +++ b/webscaff/overrides.py @@ -53,12 +53,22 @@ def contribute_missing(self): self.paths.remote.cache = '%s/cache_%s' % (self.paths.remote.temp, project_name) remote_runtime = paths.runtime - remote_runtime_dir = home_remote / 'runtime' + remote_runtime_root = home_remote / 'runtime' + + if paths.runtime.root: + remote_runtime_root = Path(paths.runtime.root) + + else: + paths.runtime.root = str(remote_runtime_root) # Set defaults for runtime subdirectories. for runtime_dir_name in remote_runtime._config.keys(): + + if runtime_dir_name == 'root': + continue + if getattr(remote_runtime, runtime_dir_name, None) is None: - setattr(remote_runtime, runtime_dir_name, str(remote_runtime_dir / runtime_dir_name)) + setattr(remote_runtime, runtime_dir_name, str(remote_runtime_root / runtime_dir_name)) # Local paths: paths = self.paths.local.project @@ -105,6 +115,7 @@ def global_defaults(): 'home': None, 'base': None, 'runtime': { + 'root': None, # Runtime root. 'static': None, # Django static directory 'media': None, # Django media directory 'certbot': None, # Certbot webroot dir