mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
docs, remove old files
This commit is contained in:
parent
c6a1c551d9
commit
d51380cccb
|
@ -1,205 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import getopt
|
||||
import os
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from config import (
|
||||
VIRT_BASE,
|
||||
X64_EXT,
|
||||
bit_from_env,
|
||||
compiler_from_env,
|
||||
compilers,
|
||||
pythons,
|
||||
pyversion_from_env,
|
||||
)
|
||||
|
||||
|
||||
def setup_vms():
|
||||
ret = []
|
||||
for py in pythons:
|
||||
for arch in ("", X64_EXT):
|
||||
ret.append(
|
||||
"virtualenv -p c:/Python%s%s/python.exe --clear %s%s%s"
|
||||
% (py, arch, VIRT_BASE, py, arch)
|
||||
)
|
||||
ret.append(
|
||||
r"%s%s%s\Scripts\pip.exe install pytest pytest-cov"
|
||||
% (VIRT_BASE, py, arch)
|
||||
)
|
||||
return "\n".join(ret)
|
||||
|
||||
|
||||
def run_script(params):
|
||||
(version, script) = params
|
||||
try:
|
||||
print("Running %s" % version)
|
||||
filename = "build_pillow_%s.cmd" % version
|
||||
with open(filename, "w") as f:
|
||||
f.write(script)
|
||||
|
||||
command = ["powershell", "./%s" % filename]
|
||||
proc = subprocess.Popen(
|
||||
command,
|
||||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
)
|
||||
(trace, stderr) = proc.communicate()
|
||||
status = proc.returncode
|
||||
print("-- stderr --")
|
||||
print(stderr.decode())
|
||||
print("-- stdout --")
|
||||
print(trace.decode())
|
||||
print("Done with {}: {}".format(version, status))
|
||||
return (version, status, trace, stderr)
|
||||
except Exception as msg:
|
||||
print("Error with {}: {}".format(version, str(msg)))
|
||||
return (version, -1, "", str(msg))
|
||||
|
||||
|
||||
def header(op):
|
||||
return r"""
|
||||
setlocal
|
||||
set MPLSRC=%%~dp0\..
|
||||
set INCLIB=%%~dp0\depends
|
||||
set BLDOPT=%s
|
||||
cd /D %%MPLSRC%%
|
||||
""" % (
|
||||
op
|
||||
)
|
||||
|
||||
|
||||
def footer():
|
||||
return """endlocal
|
||||
exit
|
||||
"""
|
||||
|
||||
|
||||
def vc_setup(compiler, bit):
|
||||
script = ""
|
||||
if compiler["vc_version"] == "2015":
|
||||
arch = "x86" if bit == 32 else "x86_amd64"
|
||||
script = (
|
||||
r"""
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %s
|
||||
echo on"""
|
||||
% arch
|
||||
)
|
||||
return script
|
||||
|
||||
|
||||
def build_one(py_ver, compiler, bit):
|
||||
# UNDONE virtual envs if we're not running on AppVeyor
|
||||
args = {}
|
||||
args.update(compiler)
|
||||
if "PYTHON" in os.environ:
|
||||
args["python_path"] = "%PYTHON%"
|
||||
else:
|
||||
args["python_path"] = "{}{}\\Scripts".format(VIRT_BASE, py_ver)
|
||||
|
||||
args["executable"] = "python.exe"
|
||||
if "EXECUTABLE" in os.environ:
|
||||
args["executable"] = "%EXECUTABLE%"
|
||||
|
||||
args["py_ver"] = py_ver
|
||||
args["tcl_ver"] = "86"
|
||||
|
||||
if compiler["vc_version"] == "2015":
|
||||
args["imaging_libs"] = " build_ext --add-imaging-libs=msvcrt"
|
||||
else:
|
||||
args["imaging_libs"] = ""
|
||||
|
||||
args["vc_setup"] = vc_setup(compiler, bit)
|
||||
|
||||
script = r"""
|
||||
setlocal EnableDelayedExpansion
|
||||
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
|
||||
set DISTUTILS_USE_SDK=1
|
||||
set LIB=%%LIB%%;%%INCLIB%%\%(inc_dir)s
|
||||
set INCLUDE=%%INCLUDE%%;%%INCLIB%%\%(inc_dir)s;%%INCLIB%%\tcl%(tcl_ver)s\include
|
||||
|
||||
setlocal
|
||||
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl%(vc_setup)s
|
||||
call %(python_path)s\%(executable)s setup.py %(imaging_libs)s %%BLDOPT%%
|
||||
call %(python_path)s\%(executable)s -c "from PIL import _webp;import os, shutil;shutil.copy(r'%%INCLIB%%\freetype.dll', os.path.dirname(_webp.__file__));"
|
||||
endlocal
|
||||
|
||||
endlocal
|
||||
""" # noqa: E501
|
||||
return script % args
|
||||
|
||||
|
||||
def clean():
|
||||
try:
|
||||
shutil.rmtree("../build")
|
||||
except Exception:
|
||||
# could already be removed
|
||||
pass
|
||||
run_script(("virtualenvs", setup_vms()))
|
||||
|
||||
|
||||
def main(op):
|
||||
scripts = []
|
||||
|
||||
for py_version, py_info in pythons.items():
|
||||
py_compilers = compilers[py_info["compiler"]][py_info["vc"]]
|
||||
scripts.append(
|
||||
(
|
||||
py_version,
|
||||
"\n".join(
|
||||
[header(op), build_one(py_version, py_compilers[32], 32), footer()]
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
scripts.append(
|
||||
(
|
||||
"{}{}".format(py_version, X64_EXT),
|
||||
"\n".join(
|
||||
[
|
||||
header(op),
|
||||
build_one("%sx64" % py_version, py_compilers[64], 64),
|
||||
footer(),
|
||||
]
|
||||
),
|
||||
)
|
||||
)
|
||||
|
||||
results = map(run_script, scripts)
|
||||
|
||||
for (version, status, trace, err) in results:
|
||||
print("Compiled {}: {}".format(version, status and "ERR" or "OK"))
|
||||
|
||||
|
||||
def run_one(op):
|
||||
|
||||
compiler = compiler_from_env()
|
||||
py_version = pyversion_from_env()
|
||||
bit = bit_from_env()
|
||||
|
||||
run_script(
|
||||
(
|
||||
py_version,
|
||||
"\n".join([header(op), build_one(py_version, compiler, bit), footer()]),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
opts, args = getopt.getopt(sys.argv[1:], "", ["clean", "wheel"])
|
||||
opts = dict(opts)
|
||||
|
||||
if "--clean" in opts:
|
||||
clean()
|
||||
|
||||
op = "install"
|
||||
if "--wheel" in opts:
|
||||
op = "bdist_wheel"
|
||||
|
||||
if "PYTHON" in os.environ:
|
||||
run_one(op)
|
||||
else:
|
||||
main(op)
|
|
@ -5,89 +5,99 @@ Building Pillow on Windows
|
|||
<../docs/installation.rst#windows-installation>`_ should
|
||||
be sufficient.
|
||||
|
||||
This page will describe a build setup to build Pillow against the
|
||||
supported Python versions in 32 and 64-bit modes, using freely
|
||||
available Microsoft compilers. This has been developed and tested
|
||||
against 64-bit Windows 7 Professional and Windows Server 2012
|
||||
64-bit version on Amazon EC2.
|
||||
This page describes the steps necessary to build Pillow using the same
|
||||
scripts used on GitHub Actions and AppVeyor CIs.
|
||||
|
||||
Prerequisites
|
||||
-------------
|
||||
|
||||
Extra Build Helpers
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
* Powershell (available by default on Windows Server)
|
||||
* GitHub client (provides git+bash shell)
|
||||
|
||||
Optional:
|
||||
* GPG (for checking signatures) (UNDONE -- Python signature checking)
|
||||
|
||||
|
||||
Pythons
|
||||
^^^^^^^
|
||||
|
||||
The build routines expect Python to be installed at C:\PythonXX for
|
||||
32-bit versions or C:\PythonXXx64 for the 64-bit versions.
|
||||
|
||||
Download Python 3.4, install it, and add it to the path. This is the
|
||||
Python that we will use to bootstrap the build process. (The download
|
||||
routines are using 3 features, and installing 3.4 gives us pip and
|
||||
virtualenv as well, reducing the number of packages that we need to
|
||||
install.)
|
||||
|
||||
Download the rest of the Pythons by opening a command window, changing
|
||||
to the ``winbuild`` directory, and running ``python
|
||||
get_pythons.py``.
|
||||
|
||||
UNDONE -- gpg verify the signatures (note that we can download from
|
||||
https)
|
||||
|
||||
Run each installer and set the proper path to the installation. Don't
|
||||
set any of them as the default Python, or add them to the path.
|
||||
Python
|
||||
^^^^^^
|
||||
|
||||
While the scripts can target any version of Python supported by Pillow,
|
||||
Python 3.6+ is required to generate valid build scripts.
|
||||
|
||||
Compilers
|
||||
^^^^^^^^^
|
||||
|
||||
Download and install:
|
||||
|
||||
* `Microsoft Windows SDK for Windows 7 and .NET Framework
|
||||
4 <https://www.microsoft.com/en-us/download/details.aspx?id=8279>`_
|
||||
* `Microsoft Visual Studio 2017 or newer (with C++ component)
|
||||
<https://visualstudio.microsoft.com/vs/older-downloads/>`_
|
||||
|
||||
* `CMake-2.8.10.2-win32-x86.exe
|
||||
<https://cmake.org/files/v2.8/cmake-2.8.10.2-win32-x86.exe>`_
|
||||
* `CMake 3.13 or newer
|
||||
<https://cmake.org/download/>`_
|
||||
|
||||
The samples and the .NET SDK portions aren't required, just the
|
||||
compilers and other tools. UNDONE -- check exact wording.
|
||||
* `NASM <https://www.nasm.us/pub/nasm/releasebuilds/?C=M;O=D>`_
|
||||
|
||||
Any version of Visual Studio 2017 or newer should be supported,
|
||||
including Visual Studio 2017 Community.
|
||||
|
||||
Paths to CMake and NASM must be added to the ``PATH`` environment variable.
|
||||
|
||||
Build configuration
|
||||
-------------------
|
||||
|
||||
The following environment variables, if set, will override the default
|
||||
behaviour of ``build_prepare.py``:
|
||||
|
||||
* ``PYTHON`` + ``EXECUTABLE`` point to the target version of Python.
|
||||
If ``PYTHON`` is unset, the version of Python used to run
|
||||
``build_prepare.py`` will be used. If only ``PYTHON`` is set,
|
||||
``EXECUTABLE`` defaults to ``python.exe``.
|
||||
* ``ARCHITECTURE`` is used to select a ``x86`` or ``x64`` build. By default,
|
||||
``x86`` is used, unless ``PYTHON`` contains ``x64``, in which case ``x64``
|
||||
is used.
|
||||
* ``PILLOW_BUILD`` can be used to override the ``winbuild\build`` directory
|
||||
path, used to store generated build scripts and compiled libraries.
|
||||
**Warning:** This directory is wiped when ``build_prepare.py`` is run.
|
||||
* ``PILLOW_DEPS`` points to the directory used to store downloaded
|
||||
dependencies. By default ``winbuild\depends`` is used.
|
||||
|
||||
Dependencies
|
||||
------------
|
||||
|
||||
The script 'build_dep.py' downloads and builds the dependencies. Open
|
||||
a command window, change directory into ``winbuild`` and run ``python
|
||||
build_dep.py``.
|
||||
Dependencies will be automatically downloaded by ``build_prepare.py``.
|
||||
By default, downloaded dependencies are stored in ``winbuild\depends``;
|
||||
set the ``PILLOW_DEPS`` environment variable to override this location.
|
||||
|
||||
This will download libjpeg, libtiff, libz, and freetype. It will then
|
||||
compile 32 and 64-bit versions of the libraries, with both versions of
|
||||
the compilers.
|
||||
|
||||
UNDONE -- lcms fails.
|
||||
UNDONE -- webp, jpeg2k not recognized
|
||||
To build all dependencies, run ``winbuild\build\build_dep_all.cmd``,
|
||||
or run the individual scripts to build each dependency separately.
|
||||
|
||||
Building Pillow
|
||||
---------------
|
||||
|
||||
Once the dependencies are built, run ``python build.py --clean`` to
|
||||
build and install Pillow in virtualenvs for each Python
|
||||
build. ``build.py --wheel`` will build wheels instead of
|
||||
installing into virtualenvs.
|
||||
|
||||
UNDONE -- suppressed output, what about failures.
|
||||
Once the dependencies are built, run
|
||||
``winbuild\build\build_pillow.cmd install`` to build and install
|
||||
Pillow for the selected version of Python.
|
||||
``winbuild\build\build_pillow.cmd bdist_wheel`` will build wheels
|
||||
instead of installing Pillow.
|
||||
|
||||
Testing Pillow
|
||||
--------------
|
||||
|
||||
Build and install Pillow, then run ``python test.py`` from the
|
||||
``winbuild`` directory.
|
||||
Some binary dependencies (e.g. ``libraqm.dll``) will be stored in the
|
||||
``winbuild\build\bin`` directory; this directory should be added to ``PATH``
|
||||
before running tests.
|
||||
|
||||
Build and install Pillow, then run ``python -m pytest Tests``
|
||||
from the root Pillow directory.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
The following is a simplified version of the script used on AppVeyor:
|
||||
|
||||
.. code-block::
|
||||
|
||||
set PYTHON=C:\Python35\bin
|
||||
cd /D C:\Pillow\winbuild
|
||||
C:\Python37\bin\python.exe build_prepare.py
|
||||
build\build_dep_all.cmd
|
||||
build\build_pillow.cmd install
|
||||
cd ..
|
||||
path C:\Pillow\winbuild\build\bin;%PATH%
|
||||
%PYTHON%\python.exe selftest.py
|
||||
%PYTHON%\python.exe -m pytest -vx --cov PIL --cov Tests --cov-report term --cov-report xml Tests
|
||||
build\build_pillow.cmd bdist_wheel
|
||||
|
|
|
@ -1,328 +0,0 @@
|
|||
import os
|
||||
|
||||
from build import vc_setup
|
||||
from config import all_compilers, bit_from_env, compiler_from_env, compilers, libs
|
||||
from fetch import fetch
|
||||
from untar import untar
|
||||
from unzip import unzip
|
||||
|
||||
|
||||
def _relpath(*args):
|
||||
return os.path.join(os.getcwd(), *args)
|
||||
|
||||
|
||||
build_dir = _relpath("build")
|
||||
inc_dir = _relpath("depends")
|
||||
|
||||
|
||||
def check_sig(filename, signame):
|
||||
# UNDONE -- need gpg
|
||||
return filename
|
||||
|
||||
|
||||
def mkdirs():
|
||||
try:
|
||||
os.mkdir(build_dir)
|
||||
except OSError:
|
||||
pass
|
||||
try:
|
||||
os.mkdir(inc_dir)
|
||||
except OSError:
|
||||
pass
|
||||
for compiler in all_compilers():
|
||||
try:
|
||||
os.mkdir(os.path.join(inc_dir, compiler["inc_dir"]))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def extract(src, dest):
|
||||
if ".zip" in src:
|
||||
return unzip(src, dest)
|
||||
if ".tar.gz" in src or ".tgz" in src:
|
||||
return untar(src, dest)
|
||||
|
||||
|
||||
def extract_libs():
|
||||
for name, lib in libs.items():
|
||||
filename = fetch(lib["url"])
|
||||
if name == "openjpeg":
|
||||
for compiler in all_compilers():
|
||||
if not os.path.exists(
|
||||
os.path.join(build_dir, lib["dir"] + compiler["inc_dir"])
|
||||
):
|
||||
extract(filename, build_dir)
|
||||
os.rename(
|
||||
os.path.join(build_dir, lib["dir"]),
|
||||
os.path.join(build_dir, lib["dir"] + compiler["inc_dir"]),
|
||||
)
|
||||
else:
|
||||
extract(filename, build_dir)
|
||||
|
||||
|
||||
def extract_openjpeg(compiler):
|
||||
return (
|
||||
r"""
|
||||
rem build openjpeg
|
||||
setlocal
|
||||
cd %%BUILD%%
|
||||
mkdir %%INCLIB%%\openjpeg-2.0
|
||||
copy /Y /B openjpeg-2.0.0-win32-x86\include\openjpeg-2.0 %%INCLIB%%\openjpeg-2.0
|
||||
copy /Y /B openjpeg-2.0.0-win32-x86\bin\ %%INCLIB%%
|
||||
copy /Y /B openjpeg-2.0.0-win32-x86\lib\ %%INCLIB%%
|
||||
endlocal
|
||||
"""
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def cp_tk(ver_85, ver_86):
|
||||
versions = {"ver_85": ver_85, "ver_86": ver_86}
|
||||
return (
|
||||
r"""
|
||||
mkdir %%INCLIB%%\tcl85\include\X11
|
||||
copy /Y /B %%BUILD%%\tcl%(ver_85)s\generic\*.h %%INCLIB%%\tcl85\include\
|
||||
copy /Y /B %%BUILD%%\tk%(ver_85)s\generic\*.h %%INCLIB%%\tcl85\include\
|
||||
copy /Y /B %%BUILD%%\tk%(ver_85)s\xlib\X11\* %%INCLIB%%\tcl85\include\X11\
|
||||
|
||||
mkdir %%INCLIB%%\tcl86\include\X11
|
||||
copy /Y /B %%BUILD%%\tcl%(ver_86)s\generic\*.h %%INCLIB%%\tcl86\include\
|
||||
copy /Y /B %%BUILD%%\tk%(ver_86)s\generic\*.h %%INCLIB%%\tcl86\include\
|
||||
copy /Y /B %%BUILD%%\tk%(ver_86)s\xlib\X11\* %%INCLIB%%\tcl86\include\X11\
|
||||
"""
|
||||
% versions
|
||||
)
|
||||
|
||||
|
||||
def header():
|
||||
return r"""setlocal
|
||||
set MSBUILD=C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
|
||||
set CMAKE="cmake.exe"
|
||||
set INCLIB=%~dp0\depends
|
||||
set BUILD=%~dp0\build
|
||||
""" + "\n".join(
|
||||
r"set {}=%BUILD%\{}".format(k.upper(), v["dir"])
|
||||
for (k, v) in libs.items()
|
||||
if v["dir"]
|
||||
)
|
||||
|
||||
|
||||
def setup_compiler(compiler):
|
||||
return (
|
||||
r"""setlocal EnableDelayedExpansion
|
||||
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
|
||||
echo on
|
||||
set INCLIB=%%INCLIB%%\%(inc_dir)s
|
||||
""" # noqa: E501
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def end_compiler():
|
||||
return """
|
||||
endlocal
|
||||
"""
|
||||
|
||||
|
||||
def nmake_openjpeg(compiler, bit):
|
||||
if compiler["env_version"] == "v7.0":
|
||||
return ""
|
||||
|
||||
atts = {"op_ver": "2.3.1"}
|
||||
atts.update(compiler)
|
||||
return (
|
||||
r"""
|
||||
rem build openjpeg
|
||||
setlocal
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
cd /D %%OPENJPEG%%%(inc_dir)s
|
||||
|
||||
%%CMAKE%% -DBUILD_THIRDPARTY:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_BUILD_TYPE=Release -G "NMake Makefiles" .
|
||||
nmake -nologo -f Makefile clean
|
||||
nmake -nologo -f Makefile
|
||||
copy /Y /B bin\* %%INCLIB%%
|
||||
mkdir %%INCLIB%%\openjpeg-%(op_ver)s
|
||||
copy /Y /B src\lib\openjp2\*.h %%INCLIB%%\openjpeg-%(op_ver)s
|
||||
endlocal
|
||||
""" # noqa: E501
|
||||
% atts
|
||||
)
|
||||
|
||||
|
||||
def nmake_libs(compiler, bit):
|
||||
# undone -- pre, makes, headers, libs
|
||||
script = (
|
||||
r"""
|
||||
rem Build libjpeg
|
||||
setlocal
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
cd /D %%JPEG%%
|
||||
nmake -nologo -f makefile.vc setup-vc6
|
||||
nmake -nologo -f makefile.vc clean
|
||||
nmake -nologo -f makefile.vc nodebug=1 libjpeg.lib
|
||||
copy /Y /B *.dll %%INCLIB%%
|
||||
copy /Y /B *.lib %%INCLIB%%
|
||||
copy /Y /B j*.h %%INCLIB%%
|
||||
endlocal
|
||||
|
||||
rem Build zlib
|
||||
setlocal
|
||||
cd /D %%ZLIB%%
|
||||
nmake -nologo -f win32\Makefile.msc clean
|
||||
nmake -nologo -f win32\Makefile.msc zlib.lib
|
||||
copy /Y /B *.dll %%INCLIB%%
|
||||
copy /Y /B *.lib %%INCLIB%%
|
||||
copy /Y /B zlib.lib %%INCLIB%%\z.lib
|
||||
copy /Y /B zlib.h %%INCLIB%%
|
||||
copy /Y /B zconf.h %%INCLIB%%
|
||||
endlocal
|
||||
|
||||
rem Build webp
|
||||
setlocal
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
cd /D %%WEBP%%
|
||||
rd /S /Q %%WEBP%%\output\release-static
|
||||
nmake -nologo -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output all
|
||||
copy /Y /B output\release-static\%(webp_platform)s\lib\* %%INCLIB%%
|
||||
mkdir %%INCLIB%%\webp
|
||||
copy /Y /B src\webp\*.h %%INCLIB%%\\webp
|
||||
endlocal
|
||||
|
||||
rem Build libtiff
|
||||
setlocal
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
rem do after building jpeg and zlib
|
||||
copy %%~dp0\tiff.opt %%TIFF%%\nmake.opt
|
||||
|
||||
cd /D %%TIFF%%
|
||||
nmake -nologo -f makefile.vc clean
|
||||
nmake -nologo -f makefile.vc lib
|
||||
copy /Y /B libtiff\*.dll %%INCLIB%%
|
||||
copy /Y /B libtiff\*.lib %%INCLIB%%
|
||||
copy /Y /B libtiff\tiff*.h %%INCLIB%%
|
||||
endlocal
|
||||
"""
|
||||
)
|
||||
return script % compiler
|
||||
|
||||
|
||||
def msbuild_freetype(compiler, bit):
|
||||
script = r"""
|
||||
rem Build freetype
|
||||
setlocal
|
||||
rd /S /Q %%FREETYPE%%\objs
|
||||
set DefaultPlatformToolset=v100
|
||||
"""
|
||||
properties = r"""/p:Configuration="Release" /p:Platform=%(platform)s"""
|
||||
if bit == 64:
|
||||
script += (
|
||||
r"copy /Y /B "
|
||||
r'"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64\*.Lib" '
|
||||
r"%%FREETYPE%%\builds\windows\vc2010"
|
||||
)
|
||||
properties += r" /p:_IsNativeEnvironment=false"
|
||||
script += (
|
||||
r"""
|
||||
%%MSBUILD%% %%FREETYPE%%\builds\windows\vc2010\freetype.sln /t:Clean;Build """
|
||||
+ properties
|
||||
+ r""" /m
|
||||
xcopy /Y /E /Q %%FREETYPE%%\include %%INCLIB%%
|
||||
"""
|
||||
)
|
||||
freetypeReleaseDir = r"%%FREETYPE%%\objs\%(platform)s\Release"
|
||||
script += (
|
||||
r"""
|
||||
copy /Y /B """
|
||||
+ freetypeReleaseDir
|
||||
+ r"""\freetype.lib %%INCLIB%%\freetype.lib
|
||||
copy /Y /B """
|
||||
+ freetypeReleaseDir
|
||||
+ r"""\freetype.dll %%INCLIB%%\..\freetype.dll
|
||||
endlocal
|
||||
"""
|
||||
)
|
||||
return script % compiler
|
||||
|
||||
|
||||
def build_lcms2(compiler):
|
||||
if compiler["env_version"] == "v7.1":
|
||||
return build_lcms_71(compiler)
|
||||
return build_lcms_70(compiler)
|
||||
|
||||
|
||||
def build_lcms_70(compiler):
|
||||
"""Link error here on x64"""
|
||||
if compiler["platform"] == "x64":
|
||||
return ""
|
||||
|
||||
"""Build LCMS on VC2008. This version is only 32bit/Win32"""
|
||||
return (
|
||||
r"""
|
||||
rem Build lcms2
|
||||
setlocal
|
||||
set LCMS=%%LCMS-2.7%%
|
||||
rd /S /Q %%LCMS%%\Lib
|
||||
rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=Win32 /m
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=Win32 /p:PlatformToolset=v90 /m
|
||||
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
||||
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
|
||||
endlocal
|
||||
""" # noqa: E501
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def build_lcms_71(compiler):
|
||||
return (
|
||||
r"""
|
||||
rem Build lcms2
|
||||
setlocal
|
||||
set LCMS=%%LCMS-2.8%%
|
||||
rd /S /Q %%LCMS%%\Lib
|
||||
rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
||||
powershell -Command "(gc Projects\VC2015\lcms2_static\lcms2_static.vcxproj) -replace 'MultiThreadedDLL', 'MultiThreaded' | Out-File -encoding ASCII Projects\VC2015\lcms2_static\lcms2_static.vcxproj"
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:Clean /p:Configuration="Release" /p:Platform=%(platform)s /m
|
||||
%%MSBUILD%% %%LCMS%%\Projects\VC%(vc_version)s\lcms2.sln /t:lcms2_static /p:Configuration="Release" /p:Platform=%(platform)s /m
|
||||
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
||||
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
|
||||
endlocal
|
||||
""" # noqa: E501
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def add_compiler(compiler, bit):
|
||||
script.append(setup_compiler(compiler))
|
||||
script.append(nmake_libs(compiler, bit))
|
||||
|
||||
# script.append(extract_openjpeg(compiler))
|
||||
|
||||
script.append(msbuild_freetype(compiler, bit))
|
||||
script.append(build_lcms2(compiler))
|
||||
script.append(nmake_openjpeg(compiler, bit))
|
||||
script.append(end_compiler())
|
||||
|
||||
|
||||
mkdirs()
|
||||
extract_libs()
|
||||
script = [header(), cp_tk(libs["tk-8.5"]["version"], libs["tk-8.6"]["version"])]
|
||||
|
||||
|
||||
if "PYTHON" in os.environ:
|
||||
add_compiler(compiler_from_env(), bit_from_env())
|
||||
else:
|
||||
# for compiler in all_compilers():
|
||||
# add_compiler(compiler)
|
||||
add_compiler(compilers[7.0][2010][32], 32)
|
||||
|
||||
with open("build_deps.cmd", "w") as f:
|
||||
f.write("\n".join(script))
|
|
@ -1,199 +0,0 @@
|
|||
import os
|
||||
|
||||
SF_MIRROR = "https://iweb.dl.sourceforge.net"
|
||||
|
||||
pythons = {
|
||||
"pypy3": {"compiler": 7.1, "vc": 2015},
|
||||
# for AppVeyor
|
||||
"35": {"compiler": 7.1, "vc": 2015},
|
||||
"36": {"compiler": 7.1, "vc": 2015},
|
||||
"37": {"compiler": 7.1, "vc": 2015},
|
||||
"38": {"compiler": 7.1, "vc": 2015},
|
||||
# for GitHub Actions
|
||||
"3.5": {"compiler": 7.1, "vc": 2015},
|
||||
"3.6": {"compiler": 7.1, "vc": 2015},
|
||||
"3.7": {"compiler": 7.1, "vc": 2015},
|
||||
"3.8": {"compiler": 7.1, "vc": 2015},
|
||||
}
|
||||
|
||||
VIRT_BASE = "c:/vp/"
|
||||
X64_EXT = os.environ.get("X64_EXT", "x64")
|
||||
|
||||
libs = {
|
||||
# 'openjpeg': {
|
||||
# 'filename': 'openjpeg-2.0.0-win32-x86.zip',
|
||||
# 'version': '2.0'
|
||||
# },
|
||||
"zlib": {
|
||||
"url": "http://zlib.net/zlib1211.zip",
|
||||
"filename": "zlib1211.zip",
|
||||
"dir": "zlib-1.2.11",
|
||||
},
|
||||
"jpeg": {
|
||||
"url": "http://www.ijg.org/files/jpegsr9d.zip",
|
||||
"filename": "jpegsr9d.zip",
|
||||
"dir": "jpeg-9d",
|
||||
},
|
||||
"tiff": {
|
||||
"url": "ftp://download.osgeo.org/libtiff/tiff-4.1.0.tar.gz",
|
||||
"filename": "tiff-4.1.0.tar.gz",
|
||||
"dir": "tiff-4.1.0",
|
||||
},
|
||||
"freetype": {
|
||||
"url": "https://download.savannah.gnu.org/releases/freetype/freetype-2.10.1.tar.gz", # noqa: E501
|
||||
"filename": "freetype-2.10.1.tar.gz",
|
||||
"dir": "freetype-2.10.1",
|
||||
},
|
||||
"lcms-2.7": {
|
||||
"url": SF_MIRROR + "/project/lcms/lcms/2.7/lcms2-2.7.zip",
|
||||
"filename": "lcms2-2.7.zip",
|
||||
"dir": "lcms2-2.7",
|
||||
},
|
||||
"lcms-2.8": {
|
||||
"url": SF_MIRROR + "/project/lcms/lcms/2.8/lcms2-2.8.zip",
|
||||
"filename": "lcms2-2.8.zip",
|
||||
"dir": "lcms2-2.8",
|
||||
},
|
||||
"tcl-8.5": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.5.19/tcl8519-src.zip",
|
||||
"filename": "tcl8519-src.zip",
|
||||
"dir": "",
|
||||
},
|
||||
"tk-8.5": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.5.19/tk8519-src.zip",
|
||||
"filename": "tk8519-src.zip",
|
||||
"dir": "",
|
||||
"version": "8.5.19",
|
||||
},
|
||||
"tcl-8.6": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.6.10/tcl8610-src.zip",
|
||||
"filename": "tcl8610-src.zip",
|
||||
"dir": "",
|
||||
},
|
||||
"tk-8.6": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.6.10/tk8610-src.zip",
|
||||
"filename": "tk8610-src.zip",
|
||||
"dir": "",
|
||||
"version": "8.6.10",
|
||||
},
|
||||
"webp": {
|
||||
"url": "http://downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz",
|
||||
"filename": "libwebp-1.1.0.tar.gz",
|
||||
"dir": "libwebp-1.1.0",
|
||||
},
|
||||
"openjpeg": {
|
||||
"url": "https://github.com/uclouvain/openjpeg/archive/v2.3.1.tar.gz",
|
||||
"filename": "openjpeg-2.3.1.tar.gz",
|
||||
"dir": "openjpeg-2.3.1",
|
||||
},
|
||||
"jpeg-turbo": {
|
||||
"url": SF_MIRROR + "/project/libjpeg-turbo/2.0.3/libjpeg-turbo-2.0.3.tar.gz",
|
||||
"filename": "libjpeg-turbo-2.0.3.tar.gz",
|
||||
"dir": "libjpeg-turbo-2.0.3",
|
||||
},
|
||||
# e5d454b: Merge tag '2.12.6' into msvc
|
||||
"imagequant": {
|
||||
"url": "https://github.com/ImageOptim/libimagequant/archive/e5d454bc7f5eb63ee50c84a83a7fa5ac94f68ec4.zip", # noqa: E501
|
||||
"filename": "libimagequant-e5d454bc7f5eb63ee50c84a83a7fa5ac94f68ec4.zip",
|
||||
"dir": "libimagequant-e5d454bc7f5eb63ee50c84a83a7fa5ac94f68ec4",
|
||||
},
|
||||
"harfbuzz": {
|
||||
"url": "https://github.com/harfbuzz/harfbuzz/archive/2.6.4.zip",
|
||||
"filename": "harfbuzz-2.6.4.zip",
|
||||
"dir": "harfbuzz-2.6.4",
|
||||
},
|
||||
"fribidi": {
|
||||
"url": "https://github.com/fribidi/fribidi/archive/v1.0.9.zip",
|
||||
"filename": "fribidi-1.0.9.zip",
|
||||
"dir": "fribidi-1.0.9",
|
||||
},
|
||||
"libraqm": {
|
||||
"url": "https://github.com/HOST-Oman/libraqm/archive/v0.7.0.zip",
|
||||
"filename": "libraqm-0.7.0.zip",
|
||||
"dir": "libraqm-0.7.0",
|
||||
},
|
||||
}
|
||||
|
||||
compilers = {
|
||||
7: {
|
||||
2010: {
|
||||
64: {
|
||||
"env_version": "v7.0",
|
||||
"vc_version": "2010",
|
||||
"env_flags": "/x64 /xp",
|
||||
"inc_dir": "msvcr90-x64",
|
||||
"platform": "x64",
|
||||
"webp_platform": "x64",
|
||||
},
|
||||
32: {
|
||||
"env_version": "v7.0",
|
||||
"vc_version": "2010",
|
||||
"env_flags": "/x86 /xp",
|
||||
"inc_dir": "msvcr90-x32",
|
||||
"platform": "Win32",
|
||||
"webp_platform": "x86",
|
||||
},
|
||||
}
|
||||
},
|
||||
7.1: {
|
||||
2015: {
|
||||
64: {
|
||||
"env_version": "v7.1",
|
||||
"vc_version": "2015",
|
||||
"env_flags": "/x64 /vista",
|
||||
"inc_dir": "msvcr10-x64",
|
||||
"platform": "x64",
|
||||
"webp_platform": "x64",
|
||||
},
|
||||
32: {
|
||||
"env_version": "v7.1",
|
||||
"vc_version": "2015",
|
||||
"env_flags": "/x86 /vista",
|
||||
"inc_dir": "msvcr10-x32",
|
||||
"platform": "Win32",
|
||||
"webp_platform": "x86",
|
||||
},
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
def pyversion_from_env():
|
||||
py = os.environ["PYTHON"]
|
||||
|
||||
py_version = "35"
|
||||
for k in pythons:
|
||||
if k in py:
|
||||
py_version = k
|
||||
break
|
||||
|
||||
if "64" in py:
|
||||
py_version = "{}{}".format(py_version, X64_EXT)
|
||||
|
||||
return py_version
|
||||
|
||||
|
||||
def compiler_from_env():
|
||||
py = os.environ["PYTHON"]
|
||||
|
||||
for k, v in pythons.items():
|
||||
if k in py:
|
||||
py_info = v
|
||||
break
|
||||
|
||||
bit = bit_from_env()
|
||||
return compilers[py_info["compiler"]][py_info["vc"]][bit]
|
||||
|
||||
|
||||
def bit_from_env():
|
||||
py = os.environ["PYTHON"]
|
||||
|
||||
return 64 if "64" in py else 32
|
||||
|
||||
|
||||
def all_compilers():
|
||||
all = []
|
||||
for vc_compilers in compilers.values():
|
||||
for bit_compilers in vc_compilers.values():
|
||||
all += bit_compilers.values()
|
||||
return all
|
|
@ -1,44 +0,0 @@
|
|||
import os
|
||||
import sys
|
||||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from config import libs
|
||||
|
||||
|
||||
def fetch(url):
|
||||
depends_filename = None
|
||||
for lib in libs.values():
|
||||
if lib["url"] == url:
|
||||
depends_filename = lib["filename"]
|
||||
break
|
||||
if depends_filename and os.path.exists(depends_filename):
|
||||
return depends_filename
|
||||
name = urllib.parse.urlsplit(url)[2].split("/")[-1]
|
||||
|
||||
if not os.path.exists(name):
|
||||
|
||||
def retrieve(request_url):
|
||||
print("Fetching", request_url)
|
||||
try:
|
||||
return urllib.request.urlopen(request_url)
|
||||
except urllib.error.URLError:
|
||||
return urllib.request.urlopen(request_url)
|
||||
|
||||
try:
|
||||
r = retrieve(url)
|
||||
except urllib.error.HTTPError:
|
||||
if depends_filename:
|
||||
r = retrieve(
|
||||
"https://github.com/python-pillow/pillow-depends/raw/master/"
|
||||
+ depends_filename
|
||||
)
|
||||
name = depends_filename
|
||||
content = r.read()
|
||||
with open(name, "wb") as fd:
|
||||
fd.write(content)
|
||||
return name
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
fetch(sys.argv[1])
|
|
@ -1,15 +0,0 @@
|
|||
import os
|
||||
|
||||
from fetch import fetch
|
||||
|
||||
if __name__ == "__main__":
|
||||
for version in ["3.4.4"]:
|
||||
for platform in ["", ".amd64"]:
|
||||
for extension in ["", ".asc"]:
|
||||
fetch(
|
||||
"https://www.python.org/ftp/python/%s/python-%s%s.msi%s"
|
||||
% (version, version, platform, extension)
|
||||
)
|
||||
|
||||
# find pip, if it's not in the path!
|
||||
os.system("pip install virtualenv")
|
|
@ -1,9 +0,0 @@
|
|||
|
||||
Get-ChildItem .\Projects\VC2015\ *.vcxproj -recurse |
|
||||
Foreach-Object {
|
||||
$c = ($_ | Get-Content)
|
||||
$c = $c -replace 'MultiThreaded<','MultiThreadedDLL<'
|
||||
$c = $c -replace '<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>','<WindowsTargetPlatformVersion>10</WindowsTargetPlatformVersion>'
|
||||
$c = $c -replace '<PlatformToolset>v140</PlatformToolset>','<PlatformToolset>v142</PlatformToolset>'
|
||||
[IO.File]::WriteAllText($_.FullName, ($c -join "`r`n"))
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
|
||||
import glob
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from config import VIRT_BASE, X64_EXT, pythons
|
||||
|
||||
|
||||
def test_one(params):
|
||||
python, architecture = params
|
||||
try:
|
||||
print("Running: %s, %s" % params)
|
||||
command = [
|
||||
r"{}\{}{}\Scripts\python.exe".format(VIRT_BASE, python, architecture),
|
||||
"test-installed.py",
|
||||
"--processes=-0",
|
||||
"--process-timeout=30",
|
||||
]
|
||||
command.extend(glob.glob("Tests/test*.py"))
|
||||
proc = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
|
||||
(trace, stderr) = proc.communicate()
|
||||
status = proc.returncode
|
||||
print("Done with {}, {} -- {}".format(python, architecture, status))
|
||||
return (python, architecture, status, trace)
|
||||
except Exception as msg:
|
||||
print("Error with {}, {}: {}".format(python, architecture, msg))
|
||||
return (python, architecture, -1, str(msg))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
os.chdir("..")
|
||||
matrix = [
|
||||
(python, architecture) for python in pythons for architecture in ("", X64_EXT)
|
||||
]
|
||||
|
||||
results = map(test_one, matrix)
|
||||
|
||||
for (python, architecture, status, trace) in results:
|
||||
print("{}{}: {}".format(python, architecture, status and "ERR" or "PASS"))
|
||||
|
||||
res = all(status for (python, architecture, status, trace) in results)
|
||||
sys.exit(res)
|
|
@ -1,11 +0,0 @@
|
|||
import sys
|
||||
import tarfile
|
||||
|
||||
|
||||
def untar(src, dest):
|
||||
with tarfile.open(src, "r:gz") as tgz:
|
||||
tgz.extractall(dest)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
untar(sys.argv[1], sys.argv[2])
|
|
@ -1,11 +0,0 @@
|
|||
import sys
|
||||
import zipfile
|
||||
|
||||
|
||||
def unzip(src, dest):
|
||||
with zipfile.ZipFile(src) as zf:
|
||||
zf.extractall(dest)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unzip(sys.argv[1], sys.argv[2])
|
Loading…
Reference in New Issue
Block a user