diff --git a/doc/conf.py b/doc/conf.py index cf978e0..81fa3db 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -22,7 +22,7 @@ author = "Dominic Kempf" # The full version, including alpha/beta/rc tags -release = "1.0.0" +release = "1.1.0" # -- General configuration --------------------------------------------------- diff --git a/setup.py b/setup.py index f4514d8..f9d43eb 100644 --- a/setup.py +++ b/setup.py @@ -10,7 +10,7 @@ setup( name="sphinx_lfs_content", - version="1.0.1", + version="1.1.0", author="Dominic Kempf", author_email="dominic.kempf@iwr.uni-heidelberg.de", description="Ensure existence of LFS content in your LFS builds", diff --git a/sphinx_lfs_content/__init__.py b/sphinx_lfs_content/__init__.py index d3120a6..80aad3a 100644 --- a/sphinx_lfs_content/__init__.py +++ b/sphinx_lfs_content/__init__.py @@ -13,36 +13,34 @@ def lfs_setup(_, config): - # If we already have git-lfs, we do nothing - if shutil.which("git-lfs"): - return - - # Download the latest git-lfs tarball and check its checksum - git_lfs_content = requests.get(GIT_LFS_FILE).content - checksum = hashlib.sha256(git_lfs_content).hexdigest() - if checksum != GIT_LFS_CHECKSUM: - raise ValueError("CheckSum of git-lfs tarball was incorrect!") - - # Create a temporary directory to install git-lfs into - with tempfile.TemporaryDirectory() as tmp_dir: - # Write it to file (can this be short cut and merged with unpacking?) - with open(os.path.join(tmp_dir, "git-lfs.tar.gz"), "wb") as tar: - tar.write(git_lfs_content) - - # Unpack the tarball - with tarfile.open(os.path.join(tmp_dir, "git-lfs.tar.gz"), "r:gz") as tar: - tar.extractall(path=tmp_dir) - - # Setup a modified environment that has the temporary directory in PATH - # This works around a bug in git-lfs where git-lfs is called recursively, - # but the inner calls rely on git-lfs being in PATH. - env = os.environ - env["PATH"] = os.environ["PATH"] + os.path.pathsep + tmp_dir - - # Fetch the LFS content of the repository - subprocess.check_call("git-lfs install".split(), env=env) - subprocess.check_call("git-lfs fetch".split(), env=env) - subprocess.check_call("git-lfs checkout".split(), env=env) + # If we already have git-lfs, we do not need to set it up + if shutil.which("git-lfs") is None: + # Download the latest git-lfs tarball and check its checksum + git_lfs_content = requests.get(GIT_LFS_FILE).content + checksum = hashlib.sha256(git_lfs_content).hexdigest() + if checksum != GIT_LFS_CHECKSUM: + raise ValueError("CheckSum of git-lfs tarball was incorrect!") + + # Create a temporary directory to install git-lfs into + with tempfile.TemporaryDirectory() as tmp_dir: + # Write it to file (can this be short cut and merged with unpacking?) + with open(os.path.join(tmp_dir, "git-lfs.tar.gz"), "wb") as tar: + tar.write(git_lfs_content) + + # Unpack the tarball + with tarfile.open(os.path.join(tmp_dir, "git-lfs.tar.gz"), "r:gz") as tar: + tar.extractall(path=tmp_dir) + + # Setup a modified environment that has the temporary directory in PATH + # This works around a bug in git-lfs where git-lfs is called recursively, + # but the inner calls rely on git-lfs being in PATH. + env = os.environ + env["PATH"] = os.environ["PATH"] + os.path.pathsep + tmp_dir + + # Fetch the LFS content of the repository + subprocess.check_call("git-lfs install".split(), env=env) + subprocess.check_call("git-lfs fetch".split(), env=env) + subprocess.check_call("git-lfs checkout".split(), env=env) # Execute all of the given post commands for cmd in config.lfs_content_post_commands: @@ -53,4 +51,4 @@ def setup(app): app.add_config_value("lfs_content_post_commands", [], rebuild="") app.connect("config-inited", lfs_setup) - return {"version": "1.0.1", "parallel_read_safe": True} + return {"version": "1.1.0", "parallel_read_safe": True}