From e5dfecf952ec19256315555e975ef42cc8dd399e Mon Sep 17 00:00:00 2001 From: EsGeh Date: Wed, 27 Nov 2019 12:13:26 +0100 Subject: [PATCH] simplify project initialisation by utilising the git_deps_py tool --- README.md | 2 ++ dependencies.conf | 17 +++++++++++++++ scripts/init.py | 54 +---------------------------------------------- 3 files changed, 20 insertions(+), 53 deletions(-) create mode 100644 dependencies.conf diff --git a/README.md b/README.md index 493d321..1631e46 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,11 @@ Installing and running the project without Docker or the scripts is possible, bu - Python 3 - Docker, Docker Compose +- [git_deps_py](https://github.molgen.mpg.de/EditionOpenAccess/git_deps_py) ## Initialise the Repository + $ git_deps_py $ ./scripts/init.py [--build] This will pull remote repositories and resources, initialize the database, etc. diff --git a/dependencies.conf b/dependencies.conf new file mode 100644 index 0000000..0f6a7fd --- /dev/null +++ b/dependencies.conf @@ -0,0 +1,17 @@ +# Dependencies + +[TEI] + +uri = https://github.com/TEIC/TEI.git +hash = 7fbbc7c5c2ba533dc70f561b27101dbfa7f519a0 + +[Stylesheets] + +uri = https://github.com/TEIC/stylesheets.git +hash = 2a01be46ee82fce5eba6074359b3d18db2222e0c + +[eoa-publication-model] + +uri = https://github.molgen.mpg.de/EditionOpenAccess/eoa-publication-model.git +hash = ea8a2eb99b22703f1ef92544352701f07c08d17e +# init not needed, since only example publication is needed diff --git a/scripts/init.py b/scripts/init.py index db60ef7..5f4cbff 100755 --- a/scripts/init.py +++ b/scripts/init.py @@ -59,44 +59,12 @@ def create_dirs( config ): target_is_directory = True, ) -def install_git_dep( - repo_name, - repo_uri, - repo_hash, - force = False, - init_script = None, -): - DEP_DIR = BASE_DIR / config['DEPENDENCIES_DIR'] - # remove repo, if necessary: - if force: - if (DEP_DIR / repo_name).exists(): - shutil.rmtree( DEP_DIR / repo_name ) - - if not((DEP_DIR / repo_name).exists()): - subprocess.check_call( - ["git", "clone", repo_uri, DEP_DIR / repo_name] - ) - subprocess.check_call( - ["git", "checkout", repo_hash], - cwd = DEP_DIR / repo_name - ) - if init_script is not None: - subprocess.check_call( - shlex.split( init_script ), - cwd = DEP_DIR / repo_name - ) - if __name__ == '__main__': from argparse import ArgumentParser parser = ArgumentParser( - description="initialize the repository: download git deps, create directories, etc" - ) - parser.add_argument( - "-d", "--force-deps", - action = "store_true", - help = "download dependencies, even if yet existing", + description="initialize the repository: create directories, etc" ) parser.add_argument( "--build", @@ -118,26 +86,6 @@ def install_git_dep( create_dirs( config ) - ## install git dependencies: - install_git_dep( - repo_name = "TEI", - repo_uri = "https://github.com/TEIC/TEI.git", - repo_hash = "7fbbc7c5c2ba533dc70f561b27101dbfa7f519a0", - force = args.force_deps, - ) - install_git_dep( - repo_name = "Stylesheets", - repo_uri = "https://github.com/TEIC/stylesheets.git", - repo_hash = "2a01be46ee82fce5eba6074359b3d18db2222e0c", - force = args.force_deps, - ) - install_git_dep( - repo_name = "eoa-publication-model", - repo_uri = "https://github.molgen.mpg.de/EditionOpenAccess/eoa-publication-model.git", - repo_hash = "ea8a2eb99b22703f1ef92544352701f07c08d17e", - force = args.force_deps, - ) - # rebuild docker image: if args.build: run(