From fe9a9dc1a3284231feee6a77161f0c9e6896323c Mon Sep 17 00:00:00 2001 From: NullSenseStudio <47096043+NullSenseStudio@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:01:15 -0400 Subject: [PATCH] zip during release workflow --- .github/workflows/package-release.yml | 6 ++++++ .gitignore | 1 + scripts/zip_dependencies.py | 26 ++++++++++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 scripts/zip_dependencies.py diff --git a/.github/workflows/package-release.yml b/.github/workflows/package-release.yml index 793fbcd6..66334766 100644 --- a/.github/workflows/package-release.yml +++ b/.github/workflows/package-release.yml @@ -45,6 +45,9 @@ jobs: shell: bash run: 'python -m pip install -r requirements/win-linux-cuda.txt --no-cache-dir --target .python_dependencies' working-directory: dream_textures + - name: Zip dependencies with long paths + shell: bash + run: 'python ./dream_textures/scripts/zip_dependencies.py' - name: Archive Release uses: thedoctor0/zip-release@main with: @@ -73,6 +76,9 @@ jobs: shell: bash run: 'python -m pip install -r requirements/win-dml.txt --no-cache-dir --target .python_dependencies' working-directory: dream_textures + - name: Zip dependencies with long paths + shell: bash + run: 'python ./dream_textures/scripts/zip_dependencies.py' - name: Archive Release uses: thedoctor0/zip-release@main with: diff --git a/.gitignore b/.gitignore index 98fd9f00..acf40e1e 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ __pycache__/ *.so # Distribution / packaging +.python_dependencies.zip .Python build/ develop-eggs/ diff --git a/scripts/zip_dependencies.py b/scripts/zip_dependencies.py new file mode 100644 index 00000000..4f3e8331 --- /dev/null +++ b/scripts/zip_dependencies.py @@ -0,0 +1,26 @@ +import shutil +import zipfile +from pathlib import Path + + +def main(): + root = Path(__file__).parent.parent + deps = root / '.python_dependencies' + deps_to_zip = [deps / 'transformers'] + + for dep in deps_to_zip: + if not dep.exists(): + raise FileNotFoundError(dep) + elif not dep.is_dir(): + raise EnvironmentError(f"not a directory {dep}") + + zip_deps_path = root / '.python_dependencies.zip' + zip_deps_path.unlink(True) + with zipfile.PyZipFile(str(zip_deps_path), mode='x') as zip_deps: + for dep in deps_to_zip: + zip_deps.writepy(str(dep)) + shutil.rmtree(str(dep)) + + +if __name__ == '__main__': + main()