mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-28 02:04:36 +03:00
clean msvs selection
This commit is contained in:
parent
9784874dc6
commit
aa4592c951
9
.github/workflows/test-windows.yml
vendored
9
.github/workflows/test-windows.yml
vendored
|
@ -58,7 +58,7 @@ jobs:
|
||||||
"%pythonLocation%\python.exe" -m pip install wheel pytest pytest-cov
|
"%pythonLocation%\python.exe" -m pip install wheel pytest pytest-cov
|
||||||
shell: cmd
|
shell: cmd
|
||||||
|
|
||||||
- name: Fetch dependencies
|
- name: Prepare dependencies
|
||||||
run: |
|
run: |
|
||||||
7z x ..\pillow-depends\nasm-2.14.02-win64.zip "-o$env:RUNNER_WORKSPACE\"
|
7z x ..\pillow-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"
|
||||||
|
@ -66,14 +66,13 @@ jobs:
|
||||||
..\pillow-depends\gs950w32.exe /S
|
..\pillow-depends\gs950w32.exe /S
|
||||||
Write-Host "::add-path::C:\Program Files (x86)\gs\gs9.50\bin"
|
Write-Host "::add-path::C:\Program Files (x86)\gs\gs9.50\bin"
|
||||||
|
|
||||||
$env:PYTHON=$env:pythonLocation
|
|
||||||
mkdir $env:GITHUB_WORKSPACE\winbuild\depends\
|
mkdir $env:GITHUB_WORKSPACE\winbuild\depends\
|
||||||
xcopy ..\pillow-depends\*.zip $env:GITHUB_WORKSPACE\winbuild\depends\
|
xcopy ..\pillow-depends\*.zip $env:GITHUB_WORKSPACE\winbuild\depends\
|
||||||
xcopy ..\pillow-depends\*.tar.gz $env:GITHUB_WORKSPACE\winbuild\depends\
|
xcopy ..\pillow-depends\*.tar.gz $env:GITHUB_WORKSPACE\winbuild\depends\
|
||||||
xcopy /s ..\pillow-depends\test_images\* $env:GITHUB_WORKSPACE\tests\images\
|
xcopy /s ..\pillow-depends\test_images\* $env:GITHUB_WORKSPACE\tests\images\
|
||||||
|
|
||||||
|
$env:PYTHON=$env:pythonLocation
|
||||||
cd $env:GITHUB_WORKSPACE/winbuild/
|
cd $env:GITHUB_WORKSPACE/winbuild/
|
||||||
# reg query "HKLM\Software\Microsoft\Microsoft SDKs\Windows" /s
|
|
||||||
ls 'C:\Program Files (x86)\Microsoft SDKs\Windows\'
|
|
||||||
& python.exe $env:GITHUB_WORKSPACE\winbuild\build_prepare.py
|
& python.exe $env:GITHUB_WORKSPACE\winbuild\build_prepare.py
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
||||||
|
@ -108,8 +107,6 @@ jobs:
|
||||||
- name: Build Pillow
|
- name: Build Pillow
|
||||||
run: |
|
run: |
|
||||||
cd $env:GITHUB_WORKSPACE
|
cd $env:GITHUB_WORKSPACE
|
||||||
# & winbuild\build_dep_tcl.cmd
|
|
||||||
# & winbuild\build_dep_tk.cmd
|
|
||||||
& winbuild\build_pillow.cmd install
|
& winbuild\build_pillow.cmd install
|
||||||
& $env:pythonLocation\python.exe selftest.py --installed
|
& $env:pythonLocation\python.exe selftest.py --installed
|
||||||
shell: pwsh
|
shell: pwsh
|
||||||
|
|
|
@ -9,21 +9,11 @@ from commands import *
|
||||||
|
|
||||||
SF_MIRROR = "http://iweb.dl.sourceforge.net"
|
SF_MIRROR = "http://iweb.dl.sourceforge.net"
|
||||||
|
|
||||||
# use PYTHON to select architecture
|
|
||||||
architectures = {
|
architectures = {
|
||||||
"x86": {"vcvars_arch": "x86", "msbuild_arch": "Win32"},
|
"x86": {"vcvars_arch": "x86", "msbuild_arch": "Win32"},
|
||||||
"x64": {"vcvars_arch": "x86_amd64", "msbuild_arch": "x64"},
|
"x64": {"vcvars_arch": "x86_amd64", "msbuild_arch": "x64"},
|
||||||
}
|
}
|
||||||
|
|
||||||
# select preferred compiler
|
|
||||||
pythons = {
|
|
||||||
"pypy3.6": {"vs_ver": "2015", "vcvars_ver": "14.0"},
|
|
||||||
"3.5": {"vs_ver": "2015", "vcvars_ver": "14.0"},
|
|
||||||
"3.6": {"vs_ver": "2017"},
|
|
||||||
"3.7": {"vs_ver": "2017"},
|
|
||||||
"3.8": {"vs_ver": "2017"}, # TODO check
|
|
||||||
}
|
|
||||||
|
|
||||||
header = [
|
header = [
|
||||||
cmd_set("BUILD", "{build_dir}"),
|
cmd_set("BUILD", "{build_dir}"),
|
||||||
cmd_set("INCLUDE", "{inc_dir}"),
|
cmd_set("INCLUDE", "{inc_dir}"),
|
||||||
|
@ -225,7 +215,7 @@ deps = {
|
||||||
|
|
||||||
|
|
||||||
# based on distutils._msvccompiler from CPython 3.7.4
|
# based on distutils._msvccompiler from CPython 3.7.4
|
||||||
def find_vs2017(config):
|
def find_msvs():
|
||||||
root = os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles")
|
root = os.environ.get("ProgramFiles(x86)") or os.environ.get("ProgramFiles")
|
||||||
if not root:
|
if not root:
|
||||||
print("Program Files not found")
|
print("Program Files not found")
|
||||||
|
@ -269,77 +259,25 @@ def find_vs2017(config):
|
||||||
# vs2017
|
# vs2017
|
||||||
msbuild = os.path.join(vspath, "MSBuild", "15.0", "Bin", "MSBuild.exe")
|
msbuild = os.path.join(vspath, "MSBuild", "15.0", "Bin", "MSBuild.exe")
|
||||||
if os.path.isfile(msbuild):
|
if os.path.isfile(msbuild):
|
||||||
# default_platform_toolset = "v140"
|
|
||||||
vs["msbuild"] = '"{}"'.format(msbuild)
|
vs["msbuild"] = '"{}"'.format(msbuild)
|
||||||
else:
|
else:
|
||||||
# vs2019
|
# vs2019
|
||||||
msbuild = os.path.join(vspath, "MSBuild", "Current", "Bin", "MSBuild.exe")
|
msbuild = os.path.join(vspath, "MSBuild", "Current", "Bin", "MSBuild.exe")
|
||||||
if os.path.isfile(msbuild):
|
if os.path.isfile(msbuild):
|
||||||
# default_platform_toolset = "v142"
|
|
||||||
vs["msbuild"] = '"{}"'.format(msbuild)
|
vs["msbuild"] = '"{}"'.format(msbuild)
|
||||||
else:
|
else:
|
||||||
print("Visual Studio MSBuild not found")
|
print("Visual Studio MSBuild not found")
|
||||||
return None
|
return None
|
||||||
# vs["header"].append(cmd_set("DefaultPlatformToolset", default_platform_toolset))
|
|
||||||
|
|
||||||
vcvarsall = os.path.join(vspath, "VC", "Auxiliary", "Build", "vcvarsall.bat")
|
vcvarsall = os.path.join(vspath, "VC", "Auxiliary", "Build", "vcvarsall.bat")
|
||||||
if not os.path.isfile(vcvarsall):
|
if not os.path.isfile(vcvarsall):
|
||||||
print("Visual Studio vcvarsall not found")
|
print("Visual Studio vcvarsall not found")
|
||||||
return None
|
return None
|
||||||
vcvars_ver = (
|
vs["header"].append('call "{}" {{vcvars_arch}}'.format(vcvarsall))
|
||||||
"-vcvars_ver={}".format(config["vcvars_ver"]) if "vcvars_ver" in config else ""
|
|
||||||
)
|
|
||||||
vs["header"].append('call "{}" {{vcvars_arch}} {}'.format(vcvarsall, vcvars_ver))
|
|
||||||
|
|
||||||
return vs
|
return vs
|
||||||
|
|
||||||
|
|
||||||
def find_sdk71a():
|
|
||||||
try:
|
|
||||||
print("trace: opening sdk key")
|
|
||||||
key = winreg.OpenKeyEx(
|
|
||||||
winreg.HKEY_LOCAL_MACHINE,
|
|
||||||
r"SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A",
|
|
||||||
access=winreg.KEY_READ | winreg.KEY_WOW64_32KEY,
|
|
||||||
)
|
|
||||||
print("trace: opened sdk key")
|
|
||||||
except OSError:
|
|
||||||
return None
|
|
||||||
print("trace: enumerating key")
|
|
||||||
with key:
|
|
||||||
for i in count():
|
|
||||||
try:
|
|
||||||
v_name, v_value, v_type = winreg.EnumValue(key, i)
|
|
||||||
print("trace: entry: {} {} = {}".format(v_type, v_name, v_value))
|
|
||||||
except OSError:
|
|
||||||
return None
|
|
||||||
if v_name == "InstallationFolder" and v_type == winreg.REG_SZ:
|
|
||||||
sdk_dir = v_value
|
|
||||||
print("trace: found dir: {}".format(sdk_dir))
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
print("trace: closed key")
|
|
||||||
|
|
||||||
if not os.path.isdir(sdk_dir):
|
|
||||||
return None
|
|
||||||
|
|
||||||
print("trace: creating dict")
|
|
||||||
|
|
||||||
sdk = {
|
|
||||||
"header": [
|
|
||||||
# for win32.mak
|
|
||||||
cmd_append("INCLUDE", os.path.join(sdk_dir, "Include")),
|
|
||||||
# for ghostscript
|
|
||||||
cmd_set("RCOMP", '"{}"'.format(os.path.join(sdk_dir, "Bin", "RC.EXE"))),
|
|
||||||
],
|
|
||||||
"sdk_dir": sdk_dir,
|
|
||||||
}
|
|
||||||
|
|
||||||
return sdk
|
|
||||||
|
|
||||||
|
|
||||||
def match(values, target):
|
def match(values, target):
|
||||||
for key, value in values.items():
|
for key, value in values.items():
|
||||||
if key in target:
|
if key in target:
|
||||||
|
@ -461,6 +399,8 @@ if __name__ == "__main__":
|
||||||
"PYTHON", os.path.dirname(os.path.realpath(sys.executable))
|
"PYTHON", os.path.dirname(os.path.realpath(sys.executable))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
print("Target Python: {}".format(python_dir))
|
||||||
|
|
||||||
# copy binaries to this directory
|
# copy binaries to this directory
|
||||||
path_dir = os.environ.get("PILLOW_BIN")
|
path_dir = os.environ.get("PILLOW_BIN")
|
||||||
|
|
||||||
|
@ -473,42 +413,26 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
architecture = arch_prefs["name"]
|
architecture = arch_prefs["name"]
|
||||||
|
|
||||||
# use PYTHON to select python version
|
print("Target Architecture: {}".format(architecture))
|
||||||
python_prefs = match(pythons, python_dir)
|
|
||||||
if python_prefs is None:
|
|
||||||
raise KeyError("Failed to determine Python version for {}".format(python_dir))
|
|
||||||
|
|
||||||
print(
|
msvs = find_msvs()
|
||||||
"Target: Python {python_version} {architecture} at: {python_dir}".format(
|
if msvs is None:
|
||||||
python_version=python_prefs["name"],
|
raise RuntimeError(
|
||||||
architecture=architecture,
|
"Visual Studio not found. Please install Visual Studio 2017 or newer."
|
||||||
python_dir=python_dir,
|
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
vs2017 = find_vs2017(python_prefs)
|
print("Found Visual Studio at: {}".format(msvs["vs_dir"]))
|
||||||
if vs2017 is None:
|
|
||||||
raise RuntimeError("Visual Studio 2017 not found")
|
|
||||||
|
|
||||||
print("Found Visual Studio at: {}".format(vs2017["vs_dir"]))
|
build_dir = os.path.join(script_dir, "build", architecture)
|
||||||
|
|
||||||
# sdk71a = find_sdk71a()
|
|
||||||
# if sdk71a is None:
|
|
||||||
# raise RuntimeError("Windows SDK v7.1A not found")
|
|
||||||
#
|
|
||||||
# print("Found Windows SDK 7.1A at: {}".format(sdk71a["sdk_dir"]))
|
|
||||||
|
|
||||||
build_dir = os.path.join(script_dir, "build", python_prefs["name"], architecture)
|
|
||||||
lib_dir = os.path.join(build_dir, "lib")
|
lib_dir = os.path.join(build_dir, "lib")
|
||||||
inc_dir = os.path.join(build_dir, "inc")
|
inc_dir = os.path.join(build_dir, "inc")
|
||||||
bin_dir = os.path.join(build_dir, "bin")
|
bin_dir = os.path.join(build_dir, "bin")
|
||||||
|
|
||||||
# shutil.rmtree(build_dir)
|
shutil.rmtree(build_dir, ignore_errors=True)
|
||||||
for path in [depends_dir, build_dir, lib_dir, inc_dir, bin_dir]:
|
for path in [depends_dir, build_dir, lib_dir, inc_dir, bin_dir]:
|
||||||
os.makedirs(path, exist_ok=True)
|
os.makedirs(path, exist_ok=True)
|
||||||
|
|
||||||
prefs = {
|
prefs = {
|
||||||
"python_version": python_prefs["name"],
|
|
||||||
"architecture": architecture,
|
"architecture": architecture,
|
||||||
"script_dir": script_dir,
|
"script_dir": script_dir,
|
||||||
"depends_dir": depends_dir,
|
"depends_dir": depends_dir,
|
||||||
|
@ -521,12 +445,9 @@ if __name__ == "__main__":
|
||||||
# TODO auto find:
|
# TODO auto find:
|
||||||
"cmake": "cmake.exe",
|
"cmake": "cmake.exe",
|
||||||
}
|
}
|
||||||
|
prefs.update(msvs)
|
||||||
dicts = [vs2017, arch_prefs, python_prefs]
|
prefs.update(arch_prefs)
|
||||||
for x in dicts:
|
prefs["header"] = sum([header, msvs["header"], ["@echo on"]], [])
|
||||||
prefs.update(x)
|
|
||||||
prefs["header"] = sum((x.get("header", []) for x in dicts), header) + ["@echo on"]
|
|
||||||
del prefs["name"]
|
|
||||||
|
|
||||||
build_dep_all()
|
build_dep_all()
|
||||||
build_pillow()
|
build_pillow()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user