mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-27 17:54:32 +03:00
cache winbuild
This commit is contained in:
parent
d6be1331ce
commit
e11612f589
38
.github/workflows/test-windows.yml
vendored
38
.github/workflows/test-windows.yml
vendored
|
@ -36,7 +36,7 @@ jobs:
|
||||||
path: winbuild\depends
|
path: winbuild\depends
|
||||||
|
|
||||||
- name: Cache pip
|
- name: Cache pip
|
||||||
uses: actions/cache@v1
|
uses: actions/cache@v2
|
||||||
with:
|
with:
|
||||||
path: ~\AppData\Local\pip\Cache
|
path: ~\AppData\Local\pip\Cache
|
||||||
key:
|
key:
|
||||||
|
@ -58,7 +58,7 @@ jobs:
|
||||||
- name: pip install wheel pytest pytest-cov
|
- name: pip install wheel pytest pytest-cov
|
||||||
run: python -m pip install wheel pytest pytest-cov
|
run: python -m pip install wheel pytest pytest-cov
|
||||||
|
|
||||||
- name: Prepare dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
7z x winbuild\depends\nasm-2.14.02-win64.zip "-o$env:RUNNER_WORKSPACE\"
|
7z x winbuild\depends\nasm-2.14.02-win64.zip "-o$env:RUNNER_WORKSPACE\"
|
||||||
Write-Host "::add-path::$env:RUNNER_WORKSPACE\nasm-2.14.02"
|
Write-Host "::add-path::$env:RUNNER_WORKSPACE\nasm-2.14.02"
|
||||||
|
@ -67,38 +67,66 @@ jobs:
|
||||||
Write-Host "::add-path::C:\Program Files (x86)\gs\gs9.50\bin"
|
Write-Host "::add-path::C:\Program Files (x86)\gs\gs9.50\bin"
|
||||||
|
|
||||||
xcopy /s winbuild\depends\test_images\* Tests\images\
|
xcopy /s winbuild\depends\test_images\* Tests\images\
|
||||||
|
shell: pwsh
|
||||||
|
|
||||||
& python.exe winbuild\build_prepare.py -v --python=$env:pythonLocation
|
- name: Cache build
|
||||||
|
id: build-cache
|
||||||
|
uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: winbuild\build
|
||||||
|
key:
|
||||||
|
${{ hashFiles('winbuild\build_prepare.py') }}-${{ hashFiles('.github\workflows\test-windows.yml') }}-${{ env.pythonLocation }}
|
||||||
|
|
||||||
|
- name: Prepare build
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
|
run: |
|
||||||
|
& python.exe winbuild\build_prepare.py -v --python=$env:pythonLocation --srcdir
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
- name: Build dependencies / libjpeg-turbo
|
- name: Build dependencies / libjpeg-turbo
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_libjpeg.cmd"
|
run: "& winbuild\\build\\build_dep_libjpeg.cmd"
|
||||||
- name: Build dependencies / zlib
|
- name: Build dependencies / zlib
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_zlib.cmd"
|
run: "& winbuild\\build\\build_dep_zlib.cmd"
|
||||||
- name: Build dependencies / LibTiff
|
- name: Build dependencies / LibTiff
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_libtiff.cmd"
|
run: "& winbuild\\build\\build_dep_libtiff.cmd"
|
||||||
- name: Build dependencies / WebP
|
- name: Build dependencies / WebP
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_libwebp.cmd"
|
run: "& winbuild\\build\\build_dep_libwebp.cmd"
|
||||||
- name: Build dependencies / FreeType
|
- name: Build dependencies / FreeType
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_freetype.cmd"
|
run: "& winbuild\\build\\build_dep_freetype.cmd"
|
||||||
- name: Build dependencies / LCMS2
|
- name: Build dependencies / LCMS2
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_lcms2.cmd"
|
run: "& winbuild\\build\\build_dep_lcms2.cmd"
|
||||||
- name: Build dependencies / OpenJPEG
|
- name: Build dependencies / OpenJPEG
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_openjpeg.cmd"
|
run: "& winbuild\\build\\build_dep_openjpeg.cmd"
|
||||||
|
|
||||||
# GPL licensed; skip if building wheels
|
# GPL licensed; skip if building wheels
|
||||||
- name: Build dependencies / libimagequant
|
- name: Build dependencies / libimagequant
|
||||||
if: "github.event_name != 'push'"
|
if: false
|
||||||
run: "& winbuild\\build\\build_dep_libimagequant.cmd"
|
run: "& winbuild\\build\\build_dep_libimagequant.cmd"
|
||||||
|
|
||||||
# Raqm dependencies
|
# Raqm dependencies
|
||||||
- name: Build dependencies / HarfBuzz
|
- name: Build dependencies / HarfBuzz
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_harfbuzz.cmd"
|
run: "& winbuild\\build\\build_dep_harfbuzz.cmd"
|
||||||
- name: Build dependencies / FriBidi
|
- name: Build dependencies / FriBidi
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_fribidi.cmd"
|
run: "& winbuild\\build\\build_dep_fribidi.cmd"
|
||||||
- name: Build dependencies / Raqm
|
- name: Build dependencies / Raqm
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
run: "& winbuild\\build\\build_dep_libraqm.cmd"
|
run: "& winbuild\\build\\build_dep_libraqm.cmd"
|
||||||
|
|
||||||
|
# trim ~150MB x 9
|
||||||
|
- name: Optimize build cache
|
||||||
|
if: steps.build-cache.outputs.cache-hit != 'true'
|
||||||
|
run: rmdir /S /Q winbuild\build\src
|
||||||
|
shell: cmd
|
||||||
|
|
||||||
- name: Build Pillow
|
- name: Build Pillow
|
||||||
run: |
|
run: |
|
||||||
& winbuild\build\build_pillow.cmd install
|
& winbuild\build\build_pillow.cmd install
|
||||||
|
@ -143,14 +171,12 @@ jobs:
|
||||||
|
|
||||||
- name: Build wheel
|
- name: Build wheel
|
||||||
id: wheel
|
id: wheel
|
||||||
if: "github.event_name == 'push'"
|
|
||||||
run: |
|
run: |
|
||||||
for /f "tokens=3 delims=/" %%a in ("${{ github.ref }}") do echo ::set-output name=dist::dist-%%a
|
for /f "tokens=3 delims=/" %%a in ("${{ github.ref }}") do echo ::set-output name=dist::dist-%%a
|
||||||
winbuild\\build\\build_pillow.cmd bdist_wheel"
|
winbuild\\build\\build_pillow.cmd bdist_wheel"
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v2
|
- uses: actions/upload-artifact@v2
|
||||||
if: "github.event_name == 'push'"
|
|
||||||
with:
|
with:
|
||||||
name: ${{ steps.wheel.outputs.dist }}
|
name: ${{ steps.wheel.outputs.dist }}
|
||||||
path: dist\*.whl
|
path: dist\*.whl
|
||||||
|
|
|
@ -378,10 +378,10 @@ def extract_dep(url, filename):
|
||||||
print("Extracting " + filename)
|
print("Extracting " + filename)
|
||||||
if filename.endswith(".zip"):
|
if filename.endswith(".zip"):
|
||||||
with zipfile.ZipFile(file) as zf:
|
with zipfile.ZipFile(file) as zf:
|
||||||
zf.extractall(build_dir)
|
zf.extractall(sources_dir)
|
||||||
elif filename.endswith(".tar.gz") or filename.endswith(".tgz"):
|
elif filename.endswith(".tar.gz") or filename.endswith(".tgz"):
|
||||||
with tarfile.open(file, "r:gz") as tgz:
|
with tarfile.open(file, "r:gz") as tgz:
|
||||||
tgz.extractall(build_dir)
|
tgz.extractall(sources_dir)
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Unknown archive type: " + filename)
|
raise RuntimeError("Unknown archive type: " + filename)
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ def build_dep(name):
|
||||||
extract_dep(dep["url"], dep["filename"])
|
extract_dep(dep["url"], dep["filename"])
|
||||||
|
|
||||||
for patch_file, patch_list in dep.get("patch", {}).items():
|
for patch_file, patch_list in dep.get("patch", {}).items():
|
||||||
patch_file = os.path.join(build_dir, dir, patch_file.format(**prefs))
|
patch_file = os.path.join(sources_dir, dir, patch_file.format(**prefs))
|
||||||
with open(patch_file, "r") as f:
|
with open(patch_file, "r") as f:
|
||||||
text = f.read()
|
text = f.read()
|
||||||
for patch_from, patch_to in patch_list.items():
|
for patch_from, patch_to in patch_list.items():
|
||||||
|
@ -429,7 +429,7 @@ def build_dep(name):
|
||||||
"@echo " + ("=" * 70),
|
"@echo " + ("=" * 70),
|
||||||
"@echo ==== {:<60} ====".format(banner),
|
"@echo ==== {:<60} ====".format(banner),
|
||||||
"@echo " + ("=" * 70),
|
"@echo " + ("=" * 70),
|
||||||
"cd /D %s" % os.path.join(build_dir, dir),
|
"cd /D %s" % os.path.join(sources_dir, dir),
|
||||||
*prefs["header"],
|
*prefs["header"],
|
||||||
*dep.get("build", []),
|
*dep.get("build", []),
|
||||||
*get_footer(dep),
|
*get_footer(dep),
|
||||||
|
@ -477,6 +477,7 @@ if __name__ == "__main__":
|
||||||
"ARCHITECTURE", "x86" if struct.calcsize("P") == 4 else "x64"
|
"ARCHITECTURE", "x86" if struct.calcsize("P") == 4 else "x64"
|
||||||
)
|
)
|
||||||
build_dir = os.environ.get("PILLOW_BUILD", os.path.join(winbuild_dir, "build"))
|
build_dir = os.environ.get("PILLOW_BUILD", os.path.join(winbuild_dir, "build"))
|
||||||
|
sources_dir = ""
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if arg == "-v":
|
if arg == "-v":
|
||||||
verbose = True
|
verbose = True
|
||||||
|
@ -494,6 +495,8 @@ if __name__ == "__main__":
|
||||||
architecture = arg[15:]
|
architecture = arg[15:]
|
||||||
elif arg.startswith("--dir="):
|
elif arg.startswith("--dir="):
|
||||||
build_dir = arg[6:]
|
build_dir = arg[6:]
|
||||||
|
elif arg == "--srcdir":
|
||||||
|
sources_dir = os.path.sep + "src"
|
||||||
else:
|
else:
|
||||||
raise ValueError("Unknown parameter: " + arg)
|
raise ValueError("Unknown parameter: " + arg)
|
||||||
|
|
||||||
|
@ -524,10 +527,13 @@ if __name__ == "__main__":
|
||||||
lib_dir = os.path.join(build_dir, "lib")
|
lib_dir = os.path.join(build_dir, "lib")
|
||||||
# build directory for *.bin files
|
# build directory for *.bin files
|
||||||
bin_dir = os.path.join(build_dir, "bin")
|
bin_dir = os.path.join(build_dir, "bin")
|
||||||
|
# directory for storing project files
|
||||||
|
sources_dir = build_dir + sources_dir
|
||||||
|
|
||||||
shutil.rmtree(build_dir, ignore_errors=True)
|
shutil.rmtree(build_dir, ignore_errors=True)
|
||||||
for path in [build_dir, inc_dir, lib_dir, bin_dir]:
|
os.makedirs(build_dir, exist_ok=False)
|
||||||
os.makedirs(path)
|
for path in [inc_dir, lib_dir, bin_dir, sources_dir]:
|
||||||
|
os.makedirs(path, exist_ok=True)
|
||||||
|
|
||||||
prefs = {
|
prefs = {
|
||||||
# Python paths / preferences
|
# Python paths / preferences
|
||||||
|
@ -543,6 +549,7 @@ if __name__ == "__main__":
|
||||||
"inc_dir": inc_dir,
|
"inc_dir": inc_dir,
|
||||||
"lib_dir": lib_dir,
|
"lib_dir": lib_dir,
|
||||||
"bin_dir": bin_dir,
|
"bin_dir": bin_dir,
|
||||||
|
"src_dir": sources_dir,
|
||||||
# Compilers / Tools
|
# Compilers / Tools
|
||||||
**msvs,
|
**msvs,
|
||||||
"cmake": "cmake.exe", # TODO find CMAKE automatically
|
"cmake": "cmake.exe", # TODO find CMAKE automatically
|
||||||
|
|
Loading…
Reference in New Issue
Block a user