mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 18:26:17 +03:00
Format with Black
This commit is contained in:
parent
5631718a8d
commit
471220093b
53
docs/conf.py
53
docs/conf.py
|
@ -29,27 +29,26 @@ import PIL
|
|||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode',
|
||||
'sphinx.ext.intersphinx']
|
||||
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.intersphinx"]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
source_suffix = ".rst"
|
||||
|
||||
# The encoding of source files.
|
||||
# source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
master_doc = "index"
|
||||
|
||||
# General information about the project.
|
||||
project = u'Pillow (PIL Fork)'
|
||||
copyright = u'1995-2011 Fredrik Lundh, 2010-2019 Alex Clark and Contributors'
|
||||
author = u'Fredrik Lundh, Alex Clark and Contributors'
|
||||
project = u"Pillow (PIL Fork)"
|
||||
copyright = u"1995-2011 Fredrik Lundh, 2010-2019 Alex Clark and Contributors"
|
||||
author = u"Fredrik Lundh, Alex Clark and Contributors"
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
|
@ -75,7 +74,7 @@ language = None
|
|||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = ['_build']
|
||||
exclude_patterns = ["_build"]
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
|
@ -93,7 +92,7 @@ exclude_patterns = ['_build']
|
|||
# show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
pygments_style = "sphinx"
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
# modindex_common_prefix = []
|
||||
|
@ -140,7 +139,7 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
|||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static', 'resources']
|
||||
html_static_path = ["_static", "resources"]
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
|
@ -203,20 +202,17 @@ html_static_path = ['_static', 'resources']
|
|||
# html_search_scorer = 'scorer.js'
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'PillowPILForkdoc'
|
||||
htmlhelp_basename = "PillowPILForkdoc"
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
@ -225,8 +221,13 @@ latex_elements = {
|
|||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'PillowPILFork.tex', u'Pillow (PIL Fork) Documentation',
|
||||
u'Alex Clark', 'manual'),
|
||||
(
|
||||
master_doc,
|
||||
"PillowPILFork.tex",
|
||||
u"Pillow (PIL Fork) Documentation",
|
||||
u"Alex Clark",
|
||||
"manual",
|
||||
)
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
|
@ -255,8 +256,7 @@ latex_documents = [
|
|||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'pillowpilfork', u'Pillow (PIL Fork) Documentation',
|
||||
[author], 1)
|
||||
(master_doc, "pillowpilfork", u"Pillow (PIL Fork) Documentation", [author], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
|
@ -269,10 +269,15 @@ man_pages = [
|
|||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'PillowPILFork', u'Pillow (PIL Fork) Documentation',
|
||||
author, 'PillowPILFork',
|
||||
'Pillow is the friendly PIL fork by Alex Clark and Contributors.',
|
||||
'Miscellaneous'),
|
||||
(
|
||||
master_doc,
|
||||
"PillowPILFork",
|
||||
u"Pillow (PIL Fork) Documentation",
|
||||
author,
|
||||
"PillowPILFork",
|
||||
"Pillow is the friendly PIL fork by Alex Clark and Contributors.",
|
||||
"Miscellaneous",
|
||||
)
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
|
@ -289,4 +294,4 @@ texinfo_documents = [
|
|||
|
||||
|
||||
def setup(app):
|
||||
app.add_javascript('js/script.js')
|
||||
app.add_javascript("js/script.js")
|
||||
|
|
|
@ -61,8 +61,7 @@ DDS_LUMINANCEA = DDPF_LUMINANCE | DDPF_ALPHAPIXELS
|
|||
DDS_ALPHA = DDPF_ALPHA
|
||||
DDS_PAL8 = DDPF_PALETTEINDEXED8
|
||||
|
||||
DDS_HEADER_FLAGS_TEXTURE = (DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH |
|
||||
DDSD_PIXELFORMAT)
|
||||
DDS_HEADER_FLAGS_TEXTURE = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH | DDSD_PIXELFORMAT
|
||||
DDS_HEADER_FLAGS_MIPMAP = DDSD_MIPMAPCOUNT
|
||||
DDS_HEADER_FLAGS_VOLUME = DDSD_DEPTH
|
||||
DDS_HEADER_FLAGS_PITCH = DDSD_PITCH
|
||||
|
@ -94,9 +93,9 @@ DXT5_FOURCC = 0x35545844
|
|||
|
||||
|
||||
def _decode565(bits):
|
||||
a = ((bits >> 11) & 0x1f) << 3
|
||||
b = ((bits >> 5) & 0x3f) << 2
|
||||
c = (bits & 0x1f) << 3
|
||||
a = ((bits >> 11) & 0x1F) << 3
|
||||
b = ((bits >> 5) & 0x3F) << 2
|
||||
c = (bits & 0x1F) << 3
|
||||
return a, b, c
|
||||
|
||||
|
||||
|
@ -145,7 +144,7 @@ def _dxt1(data, width, height):
|
|||
r, g, b = 0, 0, 0
|
||||
|
||||
idx = 4 * ((y + j) * width + x + i)
|
||||
ret[idx:idx+4] = struct.pack('4B', r, g, b, 255)
|
||||
ret[idx : idx + 4] = struct.pack("4B", r, g, b, 255)
|
||||
|
||||
return bytes(ret)
|
||||
|
||||
|
@ -167,7 +166,7 @@ def _dxtc_alpha(a0, a1, ac0, ac1, ai):
|
|||
elif ac == 6:
|
||||
alpha = 0
|
||||
elif ac == 7:
|
||||
alpha = 0xff
|
||||
alpha = 0xFF
|
||||
else:
|
||||
alpha = ((6 - ac) * a0 + (ac - 1) * a1) // 5
|
||||
|
||||
|
@ -180,8 +179,7 @@ def _dxt5(data, width, height):
|
|||
|
||||
for y in range(0, height, 4):
|
||||
for x in range(0, width, 4):
|
||||
a0, a1, ac0, ac1, c0, c1, code = struct.unpack("<2BHI2HI",
|
||||
data.read(16))
|
||||
a0, a1, ac0, ac1, c0, c1, code = struct.unpack("<2BHI2HI", data.read(16))
|
||||
|
||||
r0, g0, b0 = _decode565(c0)
|
||||
r1, g1, b1 = _decode565(c1)
|
||||
|
@ -202,7 +200,7 @@ def _dxt5(data, width, height):
|
|||
r, g, b = _c3(r0, r1), _c3(g0, g1), _c3(b0, b1)
|
||||
|
||||
idx = 4 * ((y + j) * width + x + i)
|
||||
ret[idx:idx+4] = struct.pack('4B', r, g, b, alpha)
|
||||
ret[idx : idx + 4] = struct.pack("4B", r, g, b, alpha)
|
||||
|
||||
return bytes(ret)
|
||||
|
||||
|
@ -230,8 +228,7 @@ class DdsImageFile(ImageFile.ImageFile):
|
|||
# pixel format
|
||||
pfsize, pfflags = struct.unpack("<2I", header.read(8))
|
||||
fourcc = header.read(4)
|
||||
bitcount, rmask, gmask, bmask, amask = struct.unpack("<5I",
|
||||
header.read(20))
|
||||
bitcount, rmask, gmask, bmask, amask = struct.unpack("<5I", header.read(20))
|
||||
|
||||
if fourcc == b"DXT1":
|
||||
self.decoder = "DXT1"
|
||||
|
@ -240,9 +237,7 @@ class DdsImageFile(ImageFile.ImageFile):
|
|||
else:
|
||||
raise NotImplementedError("Unimplemented pixel format %r" % fourcc)
|
||||
|
||||
self.tile = [
|
||||
(self.decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))
|
||||
]
|
||||
self.tile = [(self.decoder, (0, 0) + self.size, 0, (self.mode, 0, 1))]
|
||||
|
||||
def load_seek(self, pos):
|
||||
pass
|
||||
|
@ -270,8 +265,8 @@ class DXT5Decoder(ImageFile.PyDecoder):
|
|||
return 0, 0
|
||||
|
||||
|
||||
Image.register_decoder('DXT1', DXT1Decoder)
|
||||
Image.register_decoder('DXT5', DXT5Decoder)
|
||||
Image.register_decoder("DXT1", DXT1Decoder)
|
||||
Image.register_decoder("DXT5", DXT5Decoder)
|
||||
|
||||
|
||||
def _validate(prefix):
|
||||
|
|
|
@ -10,7 +10,7 @@ import os
|
|||
import sys
|
||||
|
||||
try:
|
||||
MAX_PROCS = int(os.environ.get('MAX_CONCURRENCY', min(4, cpu_count())))
|
||||
MAX_PROCS = int(os.environ.get("MAX_CONCURRENCY", min(4, cpu_count())))
|
||||
except NotImplementedError:
|
||||
MAX_PROCS = None
|
||||
|
||||
|
@ -26,9 +26,17 @@ def _mp_compile_one(tp):
|
|||
return
|
||||
|
||||
|
||||
def _mp_compile(self, sources, output_dir=None, macros=None,
|
||||
include_dirs=None, debug=0, extra_preargs=None,
|
||||
extra_postargs=None, depends=None):
|
||||
def _mp_compile(
|
||||
self,
|
||||
sources,
|
||||
output_dir=None,
|
||||
macros=None,
|
||||
include_dirs=None,
|
||||
debug=0,
|
||||
extra_preargs=None,
|
||||
extra_postargs=None,
|
||||
depends=None,
|
||||
):
|
||||
"""Compile one or more source files.
|
||||
|
||||
see distutils.ccompiler.CCompiler.compile for comments.
|
||||
|
@ -37,7 +45,8 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
|
|||
# entirely or implement _compile().
|
||||
|
||||
macros, objects, extra_postargs, pp_opts, build = self._setup_compile(
|
||||
output_dir, macros, include_dirs, sources, depends, extra_postargs)
|
||||
output_dir, macros, include_dirs, sources, depends, extra_postargs
|
||||
)
|
||||
cc_args = self._get_cc_args(pp_opts, debug, extra_preargs)
|
||||
|
||||
pool = Pool(MAX_PROCS)
|
||||
|
@ -45,8 +54,7 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
|
|||
print("Building using %d processes" % pool._processes)
|
||||
except Exception:
|
||||
pass
|
||||
arr = [(self, obj, build, cc_args, extra_postargs, pp_opts)
|
||||
for obj in objects]
|
||||
arr = [(self, obj, build, cc_args, extra_postargs, pp_opts) for obj in objects]
|
||||
pool.map_async(_mp_compile_one, arr)
|
||||
pool.close()
|
||||
pool.join()
|
||||
|
@ -56,8 +64,8 @@ def _mp_compile(self, sources, output_dir=None, macros=None,
|
|||
|
||||
def install():
|
||||
|
||||
fl_win = sys.platform.startswith('win')
|
||||
fl_cygwin = sys.platform.startswith('cygwin')
|
||||
fl_win = sys.platform.startswith("win")
|
||||
fl_cygwin = sys.platform.startswith("cygwin")
|
||||
|
||||
if fl_win or fl_cygwin:
|
||||
# Windows barfs on multiprocessing installs
|
||||
|
@ -72,11 +80,11 @@ def install():
|
|||
Pool(2)
|
||||
CCompiler.compile = _mp_compile
|
||||
except Exception as msg:
|
||||
print("Exception installing mp_compile, proceeding without:"
|
||||
"%s" % msg)
|
||||
print("Exception installing mp_compile, proceeding without: %s" % msg)
|
||||
else:
|
||||
print("Single threaded build, not installing mp_compile:"
|
||||
"%s processes" % MAX_PROCS)
|
||||
print(
|
||||
"Single threaded build, not installing mp_compile: %s processes" % MAX_PROCS
|
||||
)
|
||||
|
||||
|
||||
# We monkeypatch Python 2.7
|
||||
|
|
11
selftest.py
11
selftest.py
|
@ -161,12 +161,12 @@ if __name__ == "__main__":
|
|||
|
||||
exit_status = 0
|
||||
|
||||
print("-"*68)
|
||||
print("-" * 68)
|
||||
print("Pillow", Image.__version__, "TEST SUMMARY ")
|
||||
print("-"*68)
|
||||
print("-" * 68)
|
||||
print("Python modules loaded from", os.path.dirname(Image.__file__))
|
||||
print("Binary modules loaded from", os.path.dirname(Image.core.__file__))
|
||||
print("-"*68)
|
||||
print("-" * 68)
|
||||
for name, feature in [
|
||||
("pil", "PIL CORE"),
|
||||
("tkinter", "TKINTER"),
|
||||
|
@ -180,16 +180,17 @@ if __name__ == "__main__":
|
|||
("jpg_2000", "OPENJPEG (JPEG2000)"),
|
||||
("zlib", "ZLIB (PNG/ZIP)"),
|
||||
("libtiff", "LIBTIFF"),
|
||||
("raqm", "RAQM (Bidirectional Text)")
|
||||
("raqm", "RAQM (Bidirectional Text)"),
|
||||
]:
|
||||
if features.check(name):
|
||||
print("---", feature, "support ok")
|
||||
else:
|
||||
print("***", feature, "support not installed")
|
||||
print("-"*68)
|
||||
print("-" * 68)
|
||||
|
||||
# use doctest to make sure the test program behaves as documented!
|
||||
import doctest
|
||||
|
||||
print("Running selftest:")
|
||||
status = doctest.testmod(sys.modules[__name__])
|
||||
if status[0]:
|
||||
|
|
570
setup.py
570
setup.py
|
@ -29,26 +29,81 @@ if sys.platform == "win32" and sys.version_info >= (3, 8):
|
|||
warnings.warn(
|
||||
"Pillow does not yet support Python {}.{} and does not yet provide "
|
||||
"prebuilt Windows binaries. We do not recommend building from "
|
||||
"source on Windows.".format(sys.version_info.major,
|
||||
sys.version_info.minor),
|
||||
RuntimeWarning)
|
||||
"source on Windows.".format(sys.version_info.major, sys.version_info.minor),
|
||||
RuntimeWarning,
|
||||
)
|
||||
|
||||
|
||||
_IMAGING = ("decode", "encode", "map", "display", "outline", "path")
|
||||
|
||||
_LIB_IMAGING = (
|
||||
"Access", "AlphaComposite", "Resample", "Bands", "BcnDecode", "BitDecode",
|
||||
"Blend", "Chops", "ColorLUT", "Convert", "ConvertYCbCr", "Copy", "Crop",
|
||||
"Dib", "Draw", "Effects", "EpsEncode", "File", "Fill", "Filter",
|
||||
"FliDecode", "Geometry", "GetBBox", "GifDecode", "GifEncode", "HexDecode",
|
||||
"Histo", "JpegDecode", "JpegEncode", "Matrix", "ModeFilter",
|
||||
"Negative", "Offset", "Pack", "PackDecode", "Palette", "Paste", "Quant",
|
||||
"QuantOctree", "QuantHash", "QuantHeap", "PcdDecode", "PcxDecode",
|
||||
"PcxEncode", "Point", "RankFilter", "RawDecode", "RawEncode", "Storage",
|
||||
"SgiRleDecode", "SunRleDecode", "TgaRleDecode", "TgaRleEncode", "Unpack",
|
||||
"UnpackYCC", "UnsharpMask", "XbmDecode", "XbmEncode", "ZipDecode",
|
||||
"ZipEncode", "TiffDecode", "Jpeg2KDecode", "Jpeg2KEncode", "BoxBlur",
|
||||
"QuantPngQuant", "codec_fd")
|
||||
"Access",
|
||||
"AlphaComposite",
|
||||
"Resample",
|
||||
"Bands",
|
||||
"BcnDecode",
|
||||
"BitDecode",
|
||||
"Blend",
|
||||
"Chops",
|
||||
"ColorLUT",
|
||||
"Convert",
|
||||
"ConvertYCbCr",
|
||||
"Copy",
|
||||
"Crop",
|
||||
"Dib",
|
||||
"Draw",
|
||||
"Effects",
|
||||
"EpsEncode",
|
||||
"File",
|
||||
"Fill",
|
||||
"Filter",
|
||||
"FliDecode",
|
||||
"Geometry",
|
||||
"GetBBox",
|
||||
"GifDecode",
|
||||
"GifEncode",
|
||||
"HexDecode",
|
||||
"Histo",
|
||||
"JpegDecode",
|
||||
"JpegEncode",
|
||||
"Matrix",
|
||||
"ModeFilter",
|
||||
"Negative",
|
||||
"Offset",
|
||||
"Pack",
|
||||
"PackDecode",
|
||||
"Palette",
|
||||
"Paste",
|
||||
"Quant",
|
||||
"QuantOctree",
|
||||
"QuantHash",
|
||||
"QuantHeap",
|
||||
"PcdDecode",
|
||||
"PcxDecode",
|
||||
"PcxEncode",
|
||||
"Point",
|
||||
"RankFilter",
|
||||
"RawDecode",
|
||||
"RawEncode",
|
||||
"Storage",
|
||||
"SgiRleDecode",
|
||||
"SunRleDecode",
|
||||
"TgaRleDecode",
|
||||
"TgaRleEncode",
|
||||
"Unpack",
|
||||
"UnpackYCC",
|
||||
"UnsharpMask",
|
||||
"XbmDecode",
|
||||
"XbmEncode",
|
||||
"ZipDecode",
|
||||
"ZipEncode",
|
||||
"TiffDecode",
|
||||
"Jpeg2KDecode",
|
||||
"Jpeg2KEncode",
|
||||
"BoxBlur",
|
||||
"QuantPngQuant",
|
||||
"codec_fd",
|
||||
)
|
||||
|
||||
DEBUG = False
|
||||
|
||||
|
@ -61,8 +116,8 @@ class RequiredDependencyException(Exception):
|
|||
pass
|
||||
|
||||
|
||||
PLATFORM_MINGW = 'mingw' in ccompiler.get_default_compiler()
|
||||
PLATFORM_PYPY = hasattr(sys, 'pypy_version_info')
|
||||
PLATFORM_MINGW = "mingw" in ccompiler.get_default_compiler()
|
||||
PLATFORM_PYPY = hasattr(sys, "pypy_version_info")
|
||||
|
||||
|
||||
def _dbg(s, tp=None):
|
||||
|
@ -77,39 +132,36 @@ def _find_library_dirs_ldconfig():
|
|||
# Based on ctypes.util from Python 2
|
||||
|
||||
if sys.platform.startswith("linux") or sys.platform.startswith("gnu"):
|
||||
if struct.calcsize('l') == 4:
|
||||
machine = os.uname()[4] + '-32'
|
||||
if struct.calcsize("l") == 4:
|
||||
machine = os.uname()[4] + "-32"
|
||||
else:
|
||||
machine = os.uname()[4] + '-64'
|
||||
machine = os.uname()[4] + "-64"
|
||||
mach_map = {
|
||||
'x86_64-64': 'libc6,x86-64',
|
||||
'ppc64-64': 'libc6,64bit',
|
||||
'sparc64-64': 'libc6,64bit',
|
||||
's390x-64': 'libc6,64bit',
|
||||
'ia64-64': 'libc6,IA-64',
|
||||
}
|
||||
abi_type = mach_map.get(machine, 'libc6')
|
||||
"x86_64-64": "libc6,x86-64",
|
||||
"ppc64-64": "libc6,64bit",
|
||||
"sparc64-64": "libc6,64bit",
|
||||
"s390x-64": "libc6,64bit",
|
||||
"ia64-64": "libc6,IA-64",
|
||||
}
|
||||
abi_type = mach_map.get(machine, "libc6")
|
||||
|
||||
# Assuming GLIBC's ldconfig (with option -p)
|
||||
# Alpine Linux uses musl that can't print cache
|
||||
args = ['/sbin/ldconfig', '-p']
|
||||
expr = r'.*\(%s.*\) => (.*)' % abi_type
|
||||
args = ["/sbin/ldconfig", "-p"]
|
||||
expr = r".*\(%s.*\) => (.*)" % abi_type
|
||||
env = dict(os.environ)
|
||||
env['LC_ALL'] = 'C'
|
||||
env['LANG'] = 'C'
|
||||
env["LC_ALL"] = "C"
|
||||
env["LANG"] = "C"
|
||||
|
||||
elif sys.platform.startswith("freebsd"):
|
||||
args = ['/sbin/ldconfig', '-r']
|
||||
expr = r'.* => (.*)'
|
||||
args = ["/sbin/ldconfig", "-r"]
|
||||
expr = r".* => (.*)"
|
||||
env = {}
|
||||
|
||||
null = open(os.devnull, 'wb')
|
||||
null = open(os.devnull, "wb")
|
||||
try:
|
||||
with null:
|
||||
p = subprocess.Popen(args,
|
||||
stderr=null,
|
||||
stdout=subprocess.PIPE,
|
||||
env=env)
|
||||
p = subprocess.Popen(args, stderr=null, stdout=subprocess.PIPE, env=env)
|
||||
except OSError: # E.g. command not found
|
||||
return []
|
||||
[data, _] = p.communicate()
|
||||
|
@ -130,10 +182,10 @@ def _add_directory(path, subdir, where=None):
|
|||
subdir = os.path.realpath(subdir)
|
||||
if os.path.isdir(subdir) and subdir not in path:
|
||||
if where is None:
|
||||
_dbg('Appending path %s', subdir)
|
||||
_dbg("Appending path %s", subdir)
|
||||
path.append(subdir)
|
||||
else:
|
||||
_dbg('Inserting path %s', subdir)
|
||||
_dbg("Inserting path %s", subdir)
|
||||
path.insert(where, subdir)
|
||||
elif subdir in path and where is not None:
|
||||
path.remove(subdir)
|
||||
|
@ -142,9 +194,9 @@ def _add_directory(path, subdir, where=None):
|
|||
|
||||
def _find_include_file(self, include):
|
||||
for directory in self.compiler.include_dirs:
|
||||
_dbg('Checking for include file %s in %s', (include, directory))
|
||||
_dbg("Checking for include file %s in %s", (include, directory))
|
||||
if os.path.isfile(os.path.join(directory, include)):
|
||||
_dbg('Found %s', include)
|
||||
_dbg("Found %s", include)
|
||||
return 1
|
||||
return 0
|
||||
|
||||
|
@ -152,10 +204,9 @@ def _find_include_file(self, include):
|
|||
def _find_library_file(self, library):
|
||||
ret = self.compiler.find_library_file(self.compiler.library_dirs, library)
|
||||
if ret:
|
||||
_dbg('Found library %s at %s', (library, ret))
|
||||
_dbg("Found library %s at %s", (library, ret))
|
||||
else:
|
||||
_dbg("Couldn't find library %s in %s",
|
||||
(library, self.compiler.library_dirs))
|
||||
_dbg("Couldn't find library %s in %s", (library, self.compiler.library_dirs))
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -167,18 +218,18 @@ def _cmd_exists(cmd):
|
|||
|
||||
|
||||
def _read(file):
|
||||
with open(file, 'rb') as fp:
|
||||
with open(file, "rb") as fp:
|
||||
return fp.read()
|
||||
|
||||
|
||||
def get_version():
|
||||
version_file = 'src/PIL/_version.py'
|
||||
with open(version_file, 'r') as f:
|
||||
exec(compile(f.read(), version_file, 'exec'))
|
||||
return locals()['__version__']
|
||||
version_file = "src/PIL/_version.py"
|
||||
with open(version_file, "r") as f:
|
||||
exec(compile(f.read(), version_file, "exec"))
|
||||
return locals()["__version__"]
|
||||
|
||||
|
||||
NAME = 'Pillow'
|
||||
NAME = "Pillow"
|
||||
PILLOW_VERSION = get_version()
|
||||
JPEG_ROOT = None
|
||||
JPEG2K_ROOT = None
|
||||
|
@ -191,17 +242,11 @@ LCMS_ROOT = None
|
|||
|
||||
def _pkg_config(name):
|
||||
try:
|
||||
command_libs = [
|
||||
'pkg-config',
|
||||
'--libs-only-L', name,
|
||||
]
|
||||
command_cflags = [
|
||||
'pkg-config',
|
||||
'--cflags-only-I', name,
|
||||
]
|
||||
command_libs = ["pkg-config", "--libs-only-L", name]
|
||||
command_cflags = ["pkg-config", "--cflags-only-I", name]
|
||||
if not DEBUG:
|
||||
command_libs.append('--silence-errors')
|
||||
command_cflags.append('--silence-errors')
|
||||
command_libs.append("--silence-errors")
|
||||
command_cflags.append("--silence-errors")
|
||||
libs = (
|
||||
subprocess.check_output(command_libs)
|
||||
.decode("utf8")
|
||||
|
@ -221,10 +266,19 @@ def _pkg_config(name):
|
|||
|
||||
class pil_build_ext(build_ext):
|
||||
class feature:
|
||||
features = ['zlib', 'jpeg', 'tiff', 'freetype', 'lcms', 'webp',
|
||||
'webpmux', 'jpeg2000', 'imagequant']
|
||||
features = [
|
||||
"zlib",
|
||||
"jpeg",
|
||||
"tiff",
|
||||
"freetype",
|
||||
"lcms",
|
||||
"webp",
|
||||
"webpmux",
|
||||
"jpeg2000",
|
||||
"imagequant",
|
||||
]
|
||||
|
||||
required = {'jpeg', 'zlib'}
|
||||
required = {"jpeg", "zlib"}
|
||||
|
||||
def __init__(self):
|
||||
for f in self.features:
|
||||
|
@ -242,23 +296,24 @@ class pil_build_ext(build_ext):
|
|||
|
||||
feature = feature()
|
||||
|
||||
user_options = build_ext.user_options + [
|
||||
('disable-%s' % x, None, 'Disable support for %s' % x) for x in feature
|
||||
] + [
|
||||
('enable-%s' % x, None, 'Enable support for %s' % x) for x in feature
|
||||
] + [
|
||||
('disable-platform-guessing', None,
|
||||
'Disable platform guessing on Linux'),
|
||||
('debug', None, 'Debug logging')
|
||||
] + [('add-imaging-libs=', None, 'Add libs to _imaging build')]
|
||||
user_options = (
|
||||
build_ext.user_options
|
||||
+ [("disable-%s" % x, None, "Disable support for %s" % x) for x in feature]
|
||||
+ [("enable-%s" % x, None, "Enable support for %s" % x) for x in feature]
|
||||
+ [
|
||||
("disable-platform-guessing", None, "Disable platform guessing on Linux"),
|
||||
("debug", None, "Debug logging"),
|
||||
]
|
||||
+ [("add-imaging-libs=", None, "Add libs to _imaging build")]
|
||||
)
|
||||
|
||||
def initialize_options(self):
|
||||
self.disable_platform_guessing = None
|
||||
self.add_imaging_libs = ""
|
||||
build_ext.initialize_options(self)
|
||||
for x in self.feature:
|
||||
setattr(self, 'disable_%s' % x, None)
|
||||
setattr(self, 'enable_%s' % x, None)
|
||||
setattr(self, "disable_%s" % x, None)
|
||||
setattr(self, "enable_%s" % x, None)
|
||||
|
||||
def finalize_options(self):
|
||||
build_ext.finalize_options(self)
|
||||
|
@ -272,16 +327,16 @@ class pil_build_ext(build_ext):
|
|||
# number of jobs.
|
||||
self.parallel = mp_compile.MAX_PROCS
|
||||
for x in self.feature:
|
||||
if getattr(self, 'disable_%s' % x):
|
||||
if getattr(self, "disable_%s" % x):
|
||||
setattr(self.feature, x, False)
|
||||
self.feature.required.discard(x)
|
||||
_dbg('Disabling %s', x)
|
||||
if getattr(self, 'enable_%s' % x):
|
||||
_dbg("Disabling %s", x)
|
||||
if getattr(self, "enable_%s" % x):
|
||||
raise ValueError(
|
||||
'Conflicting options: --enable-%s and --disable-%s' %
|
||||
(x, x))
|
||||
if getattr(self, 'enable_%s' % x):
|
||||
_dbg('Requiring %s', x)
|
||||
"Conflicting options: --enable-%s and --disable-%s" % (x, x)
|
||||
)
|
||||
if getattr(self, "enable_%s" % x):
|
||||
_dbg("Requiring %s", x)
|
||||
self.feature.required.add(x)
|
||||
|
||||
def build_extensions(self):
|
||||
|
@ -292,34 +347,35 @@ class pil_build_ext(build_ext):
|
|||
_add_directory(include_dirs, "src/libImaging")
|
||||
|
||||
pkg_config = None
|
||||
if _cmd_exists('pkg-config'):
|
||||
if _cmd_exists("pkg-config"):
|
||||
pkg_config = _pkg_config
|
||||
|
||||
#
|
||||
# add configured kits
|
||||
for root_name, lib_name in dict(JPEG_ROOT="libjpeg",
|
||||
JPEG2K_ROOT="libopenjp2",
|
||||
TIFF_ROOT=("libtiff-5", "libtiff-4"),
|
||||
ZLIB_ROOT="zlib",
|
||||
FREETYPE_ROOT="freetype2",
|
||||
LCMS_ROOT="lcms2",
|
||||
IMAGEQUANT_ROOT="libimagequant"
|
||||
).items():
|
||||
for root_name, lib_name in dict(
|
||||
JPEG_ROOT="libjpeg",
|
||||
JPEG2K_ROOT="libopenjp2",
|
||||
TIFF_ROOT=("libtiff-5", "libtiff-4"),
|
||||
ZLIB_ROOT="zlib",
|
||||
FREETYPE_ROOT="freetype2",
|
||||
LCMS_ROOT="lcms2",
|
||||
IMAGEQUANT_ROOT="libimagequant",
|
||||
).items():
|
||||
root = globals()[root_name]
|
||||
|
||||
if root is None and root_name in os.environ:
|
||||
prefix = os.environ[root_name]
|
||||
root = (os.path.join(prefix, 'lib'), os.path.join(prefix, 'include'))
|
||||
root = (os.path.join(prefix, "lib"), os.path.join(prefix, "include"))
|
||||
|
||||
if root is None and pkg_config:
|
||||
if isinstance(lib_name, tuple):
|
||||
for lib_name2 in lib_name:
|
||||
_dbg('Looking for `%s` using pkg-config.' % lib_name2)
|
||||
_dbg("Looking for `%s` using pkg-config." % lib_name2)
|
||||
root = pkg_config(lib_name2)
|
||||
if root:
|
||||
break
|
||||
else:
|
||||
_dbg('Looking for `%s` using pkg-config.' % lib_name)
|
||||
_dbg("Looking for `%s` using pkg-config." % lib_name)
|
||||
root = pkg_config(lib_name)
|
||||
|
||||
if isinstance(root, tuple):
|
||||
|
@ -331,20 +387,20 @@ class pil_build_ext(build_ext):
|
|||
_add_directory(include_dirs, include_root)
|
||||
|
||||
# respect CFLAGS/LDFLAGS
|
||||
for k in ('CFLAGS', 'LDFLAGS'):
|
||||
for k in ("CFLAGS", "LDFLAGS"):
|
||||
if k in os.environ:
|
||||
for match in re.finditer(r'-I([^\s]+)', os.environ[k]):
|
||||
for match in re.finditer(r"-I([^\s]+)", os.environ[k]):
|
||||
_add_directory(include_dirs, match.group(1))
|
||||
for match in re.finditer(r'-L([^\s]+)', os.environ[k]):
|
||||
for match in re.finditer(r"-L([^\s]+)", os.environ[k]):
|
||||
_add_directory(library_dirs, match.group(1))
|
||||
|
||||
# include, rpath, if set as environment variables:
|
||||
for k in ('C_INCLUDE_PATH', 'CPATH', 'INCLUDE'):
|
||||
for k in ("C_INCLUDE_PATH", "CPATH", "INCLUDE"):
|
||||
if k in os.environ:
|
||||
for d in os.environ[k].split(os.path.pathsep):
|
||||
_add_directory(include_dirs, d)
|
||||
|
||||
for k in ('LD_RUN_PATH', 'LIBRARY_PATH', 'LIB'):
|
||||
for k in ("LD_RUN_PATH", "LIBRARY_PATH", "LIB"):
|
||||
if k in os.environ:
|
||||
for d in os.environ[k].split(os.path.pathsep):
|
||||
_add_directory(library_dirs, d)
|
||||
|
@ -362,9 +418,10 @@ class pil_build_ext(build_ext):
|
|||
|
||||
elif sys.platform == "cygwin":
|
||||
# pythonX.Y.dll.a is in the /usr/lib/pythonX.Y/config directory
|
||||
_add_directory(library_dirs,
|
||||
os.path.join("/usr/lib", "python%s" %
|
||||
sys.version[:3], "config"))
|
||||
_add_directory(
|
||||
library_dirs,
|
||||
os.path.join("/usr/lib", "python%s" % sys.version[:3], "config"),
|
||||
)
|
||||
|
||||
elif sys.platform == "darwin":
|
||||
# attempt to make sure we pick freetype2 over other versions
|
||||
|
@ -379,8 +436,11 @@ class pil_build_ext(build_ext):
|
|||
|
||||
# if Homebrew is installed, use its lib and include directories
|
||||
try:
|
||||
prefix = subprocess.check_output(['brew', '--prefix']).strip(
|
||||
).decode('latin1')
|
||||
prefix = (
|
||||
subprocess.check_output(["brew", "--prefix"])
|
||||
.strip()
|
||||
.decode("latin1")
|
||||
)
|
||||
except Exception:
|
||||
# Homebrew not installed
|
||||
prefix = None
|
||||
|
@ -389,28 +449,30 @@ class pil_build_ext(build_ext):
|
|||
|
||||
if prefix:
|
||||
# add Homebrew's include and lib directories
|
||||
_add_directory(library_dirs, os.path.join(prefix, 'lib'))
|
||||
_add_directory(include_dirs, os.path.join(prefix, 'include'))
|
||||
ft_prefix = os.path.join(prefix, 'opt', 'freetype')
|
||||
_add_directory(library_dirs, os.path.join(prefix, "lib"))
|
||||
_add_directory(include_dirs, os.path.join(prefix, "include"))
|
||||
ft_prefix = os.path.join(prefix, "opt", "freetype")
|
||||
|
||||
if ft_prefix and os.path.isdir(ft_prefix):
|
||||
# freetype might not be linked into Homebrew's prefix
|
||||
_add_directory(library_dirs, os.path.join(ft_prefix, 'lib'))
|
||||
_add_directory(include_dirs,
|
||||
os.path.join(ft_prefix, 'include'))
|
||||
_add_directory(library_dirs, os.path.join(ft_prefix, "lib"))
|
||||
_add_directory(include_dirs, os.path.join(ft_prefix, "include"))
|
||||
else:
|
||||
# fall back to freetype from XQuartz if
|
||||
# Homebrew's freetype is missing
|
||||
_add_directory(library_dirs, "/usr/X11/lib")
|
||||
_add_directory(include_dirs, "/usr/X11/include")
|
||||
|
||||
elif sys.platform.startswith("linux") or \
|
||||
sys.platform.startswith("gnu") or \
|
||||
sys.platform.startswith("freebsd"):
|
||||
elif (
|
||||
sys.platform.startswith("linux")
|
||||
or sys.platform.startswith("gnu")
|
||||
or sys.platform.startswith("freebsd")
|
||||
):
|
||||
for dirname in _find_library_dirs_ldconfig():
|
||||
_add_directory(library_dirs, dirname)
|
||||
if sys.platform.startswith("linux") and \
|
||||
os.environ.get('ANDROID_ROOT', None):
|
||||
if sys.platform.startswith("linux") and os.environ.get(
|
||||
"ANDROID_ROOT", None
|
||||
):
|
||||
# termux support for android.
|
||||
# system libraries (zlib) are installed in /system/lib
|
||||
# headers are at $PREFIX/include
|
||||
|
@ -441,27 +503,26 @@ class pil_build_ext(build_ext):
|
|||
|
||||
if sys.platform == "win32":
|
||||
if PLATFORM_MINGW:
|
||||
_add_directory(include_dirs,
|
||||
"C:\\msys64\\mingw32\\include\\libimagequant")
|
||||
_add_directory(
|
||||
include_dirs, "C:\\msys64\\mingw32\\include\\libimagequant"
|
||||
)
|
||||
|
||||
# on Windows, look for the OpenJPEG libraries in the location that
|
||||
# the official installer puts them
|
||||
program_files = os.environ.get('ProgramFiles', '')
|
||||
program_files = os.environ.get("ProgramFiles", "")
|
||||
best_version = (0, 0)
|
||||
best_path = None
|
||||
for name in os.listdir(program_files):
|
||||
if name.startswith('OpenJPEG '):
|
||||
version = tuple(int(x) for x in
|
||||
name[9:].strip().split('.'))
|
||||
if name.startswith("OpenJPEG "):
|
||||
version = tuple(int(x) for x in name[9:].strip().split("."))
|
||||
if version > best_version:
|
||||
best_version = version
|
||||
best_path = os.path.join(program_files, name)
|
||||
|
||||
if best_path:
|
||||
_dbg('Adding %s to search list', best_path)
|
||||
_add_directory(library_dirs, os.path.join(best_path, 'lib'))
|
||||
_add_directory(include_dirs,
|
||||
os.path.join(best_path, 'include'))
|
||||
_dbg("Adding %s to search list", best_path)
|
||||
_add_directory(library_dirs, os.path.join(best_path, "lib"))
|
||||
_add_directory(include_dirs, os.path.join(best_path, "include"))
|
||||
|
||||
#
|
||||
# insert new dirs *before* default libs, to avoid conflicts
|
||||
|
@ -475,51 +536,51 @@ class pil_build_ext(build_ext):
|
|||
|
||||
feature = self.feature
|
||||
|
||||
if feature.want('zlib'):
|
||||
_dbg('Looking for zlib')
|
||||
if feature.want("zlib"):
|
||||
_dbg("Looking for zlib")
|
||||
if _find_include_file(self, "zlib.h"):
|
||||
if _find_library_file(self, "z"):
|
||||
feature.zlib = "z"
|
||||
elif (sys.platform == "win32" and
|
||||
_find_library_file(self, "zlib")):
|
||||
elif sys.platform == "win32" and _find_library_file(self, "zlib"):
|
||||
feature.zlib = "zlib" # alternative name
|
||||
|
||||
if feature.want('jpeg'):
|
||||
_dbg('Looking for jpeg')
|
||||
if feature.want("jpeg"):
|
||||
_dbg("Looking for jpeg")
|
||||
if _find_include_file(self, "jpeglib.h"):
|
||||
if _find_library_file(self, "jpeg"):
|
||||
feature.jpeg = "jpeg"
|
||||
elif (sys.platform == "win32" and
|
||||
_find_library_file(self, "libjpeg")):
|
||||
elif sys.platform == "win32" and _find_library_file(self, "libjpeg"):
|
||||
feature.jpeg = "libjpeg" # alternative name
|
||||
|
||||
feature.openjpeg_version = None
|
||||
if feature.want('jpeg2000'):
|
||||
_dbg('Looking for jpeg2000')
|
||||
if feature.want("jpeg2000"):
|
||||
_dbg("Looking for jpeg2000")
|
||||
best_version = None
|
||||
best_path = None
|
||||
|
||||
# Find the best version
|
||||
for directory in self.compiler.include_dirs:
|
||||
_dbg('Checking for openjpeg-#.# in %s', directory)
|
||||
_dbg("Checking for openjpeg-#.# in %s", directory)
|
||||
try:
|
||||
listdir = os.listdir(directory)
|
||||
except Exception:
|
||||
# WindowsError, FileNotFoundError
|
||||
continue
|
||||
for name in listdir:
|
||||
if name.startswith('openjpeg-') and \
|
||||
os.path.isfile(os.path.join(directory, name,
|
||||
'openjpeg.h')):
|
||||
_dbg('Found openjpeg.h in %s/%s', (directory, name))
|
||||
version = tuple(int(x) for x in name[9:].split('.'))
|
||||
if name.startswith("openjpeg-") and os.path.isfile(
|
||||
os.path.join(directory, name, "openjpeg.h")
|
||||
):
|
||||
_dbg("Found openjpeg.h in %s/%s", (directory, name))
|
||||
version = tuple(int(x) for x in name[9:].split("."))
|
||||
if best_version is None or version > best_version:
|
||||
best_version = version
|
||||
best_path = os.path.join(directory, name)
|
||||
_dbg('Best openjpeg version %s so far in %s',
|
||||
(best_version, best_path))
|
||||
_dbg(
|
||||
"Best openjpeg version %s so far in %s",
|
||||
(best_version, best_path),
|
||||
)
|
||||
|
||||
if best_version and _find_library_file(self, 'openjp2'):
|
||||
if best_version and _find_library_file(self, "openjp2"):
|
||||
# Add the directory to the include path so we can include
|
||||
# <openjpeg.h> rather than having to cope with the versioned
|
||||
# include path
|
||||
|
@ -528,45 +589,43 @@ class pil_build_ext(build_ext):
|
|||
# self.compiler.include_dirs. Should investigate how that is
|
||||
# possible.
|
||||
_add_directory(self.compiler.include_dirs, best_path, 0)
|
||||
feature.jpeg2000 = 'openjp2'
|
||||
feature.openjpeg_version = '.'.join(str(x) for x in
|
||||
best_version)
|
||||
feature.jpeg2000 = "openjp2"
|
||||
feature.openjpeg_version = ".".join(str(x) for x in best_version)
|
||||
|
||||
if feature.want('imagequant'):
|
||||
_dbg('Looking for imagequant')
|
||||
if _find_include_file(self, 'libimagequant.h'):
|
||||
if feature.want("imagequant"):
|
||||
_dbg("Looking for imagequant")
|
||||
if _find_include_file(self, "libimagequant.h"):
|
||||
if _find_library_file(self, "imagequant"):
|
||||
feature.imagequant = "imagequant"
|
||||
elif _find_library_file(self, "libimagequant"):
|
||||
feature.imagequant = "libimagequant"
|
||||
|
||||
if feature.want('tiff'):
|
||||
_dbg('Looking for tiff')
|
||||
if _find_include_file(self, 'tiff.h'):
|
||||
if feature.want("tiff"):
|
||||
_dbg("Looking for tiff")
|
||||
if _find_include_file(self, "tiff.h"):
|
||||
if _find_library_file(self, "tiff"):
|
||||
feature.tiff = "tiff"
|
||||
if (sys.platform in ["win32", "darwin"] and
|
||||
_find_library_file(self, "libtiff")):
|
||||
if sys.platform in ["win32", "darwin"] and _find_library_file(
|
||||
self, "libtiff"
|
||||
):
|
||||
feature.tiff = "libtiff"
|
||||
|
||||
if feature.want('freetype'):
|
||||
_dbg('Looking for freetype')
|
||||
if feature.want("freetype"):
|
||||
_dbg("Looking for freetype")
|
||||
if _find_library_file(self, "freetype"):
|
||||
# look for freetype2 include files
|
||||
freetype_version = 0
|
||||
for subdir in self.compiler.include_dirs:
|
||||
_dbg('Checking for include file %s in %s',
|
||||
("ft2build.h", subdir))
|
||||
_dbg("Checking for include file %s in %s", ("ft2build.h", subdir))
|
||||
if os.path.isfile(os.path.join(subdir, "ft2build.h")):
|
||||
_dbg('Found %s in %s', ("ft2build.h", subdir))
|
||||
_dbg("Found %s in %s", ("ft2build.h", subdir))
|
||||
freetype_version = 21
|
||||
subdir = os.path.join(subdir, "freetype2")
|
||||
break
|
||||
subdir = os.path.join(subdir, "freetype2")
|
||||
_dbg('Checking for include file %s in %s',
|
||||
("ft2build.h", subdir))
|
||||
_dbg("Checking for include file %s in %s", ("ft2build.h", subdir))
|
||||
if os.path.isfile(os.path.join(subdir, "ft2build.h")):
|
||||
_dbg('Found %s in %s', ("ft2build.h", subdir))
|
||||
_dbg("Found %s in %s", ("ft2build.h", subdir))
|
||||
freetype_version = 21
|
||||
break
|
||||
if freetype_version:
|
||||
|
@ -574,8 +633,8 @@ class pil_build_ext(build_ext):
|
|||
if subdir:
|
||||
_add_directory(self.compiler.include_dirs, subdir, 0)
|
||||
|
||||
if feature.want('lcms'):
|
||||
_dbg('Looking for lcms')
|
||||
if feature.want("lcms"):
|
||||
_dbg("Looking for lcms")
|
||||
if _find_include_file(self, "lcms2.h"):
|
||||
if _find_library_file(self, "lcms2"):
|
||||
feature.lcms = "lcms2"
|
||||
|
@ -583,30 +642,34 @@ class pil_build_ext(build_ext):
|
|||
# alternate Windows name.
|
||||
feature.lcms = "lcms2_static"
|
||||
|
||||
if feature.want('webp'):
|
||||
_dbg('Looking for webp')
|
||||
if (_find_include_file(self, "webp/encode.h") and
|
||||
_find_include_file(self, "webp/decode.h")):
|
||||
if feature.want("webp"):
|
||||
_dbg("Looking for webp")
|
||||
if _find_include_file(self, "webp/encode.h") and _find_include_file(
|
||||
self, "webp/decode.h"
|
||||
):
|
||||
# In Google's precompiled zip it is call "libwebp":
|
||||
if _find_library_file(self, "webp"):
|
||||
feature.webp = "webp"
|
||||
elif _find_library_file(self, "libwebp"):
|
||||
feature.webp = "libwebp"
|
||||
|
||||
if feature.want('webpmux'):
|
||||
_dbg('Looking for webpmux')
|
||||
if (_find_include_file(self, "webp/mux.h") and
|
||||
_find_include_file(self, "webp/demux.h")):
|
||||
if (_find_library_file(self, "webpmux") and
|
||||
_find_library_file(self, "webpdemux")):
|
||||
if feature.want("webpmux"):
|
||||
_dbg("Looking for webpmux")
|
||||
if _find_include_file(self, "webp/mux.h") and _find_include_file(
|
||||
self, "webp/demux.h"
|
||||
):
|
||||
if _find_library_file(self, "webpmux") and _find_library_file(
|
||||
self, "webpdemux"
|
||||
):
|
||||
feature.webpmux = "webpmux"
|
||||
if (_find_library_file(self, "libwebpmux") and
|
||||
_find_library_file(self, "libwebpdemux")):
|
||||
if _find_library_file(self, "libwebpmux") and _find_library_file(
|
||||
self, "libwebpdemux"
|
||||
):
|
||||
feature.webpmux = "libwebpmux"
|
||||
|
||||
for f in feature:
|
||||
if not getattr(feature, f) and feature.require(f):
|
||||
if f in ('jpeg', 'zlib'):
|
||||
if f in ("jpeg", "zlib"):
|
||||
raise RequiredDependencyException(f)
|
||||
raise DependencyException(f)
|
||||
|
||||
|
@ -640,7 +703,7 @@ class pil_build_ext(build_ext):
|
|||
defs.append(("HAVE_LIBTIFF", None))
|
||||
if sys.platform == "win32":
|
||||
libs.extend(["kernel32", "user32", "gdi32"])
|
||||
if struct.unpack("h", "\0\1".encode('ascii'))[0] == 1:
|
||||
if struct.unpack("h", "\0\1".encode("ascii"))[0] == 1:
|
||||
defs.append(("WORDS_BIGENDIAN", None))
|
||||
|
||||
if sys.platform == "win32" and not (PLATFORM_PYPY or PLATFORM_MINGW):
|
||||
|
@ -648,10 +711,7 @@ class pil_build_ext(build_ext):
|
|||
else:
|
||||
defs.append(("PILLOW_VERSION", '"%s"' % PILLOW_VERSION))
|
||||
|
||||
exts = [(Extension("PIL._imaging",
|
||||
files,
|
||||
libraries=libs,
|
||||
define_macros=defs))]
|
||||
exts = [(Extension("PIL._imaging", files, libraries=libs, define_macros=defs))]
|
||||
|
||||
#
|
||||
# additional libraries
|
||||
|
@ -659,17 +719,26 @@ class pil_build_ext(build_ext):
|
|||
if feature.freetype:
|
||||
libs = ["freetype"]
|
||||
defs = []
|
||||
exts.append(Extension(
|
||||
"PIL._imagingft", ["src/_imagingft.c"], libraries=libs,
|
||||
define_macros=defs))
|
||||
exts.append(
|
||||
Extension(
|
||||
"PIL._imagingft",
|
||||
["src/_imagingft.c"],
|
||||
libraries=libs,
|
||||
define_macros=defs,
|
||||
)
|
||||
)
|
||||
|
||||
if feature.lcms:
|
||||
extra = []
|
||||
if sys.platform == "win32":
|
||||
extra.extend(["user32", "gdi32"])
|
||||
exts.append(Extension("PIL._imagingcms",
|
||||
["src/_imagingcms.c"],
|
||||
libraries=[feature.lcms] + extra))
|
||||
exts.append(
|
||||
Extension(
|
||||
"PIL._imagingcms",
|
||||
["src/_imagingcms.c"],
|
||||
libraries=[feature.lcms] + extra,
|
||||
)
|
||||
)
|
||||
|
||||
if feature.webp:
|
||||
libs = [feature.webp]
|
||||
|
@ -678,18 +747,23 @@ class pil_build_ext(build_ext):
|
|||
if feature.webpmux:
|
||||
defs.append(("HAVE_WEBPMUX", None))
|
||||
libs.append(feature.webpmux)
|
||||
libs.append(feature.webpmux.replace('pmux', 'pdemux'))
|
||||
libs.append(feature.webpmux.replace("pmux", "pdemux"))
|
||||
|
||||
exts.append(Extension("PIL._webp",
|
||||
["src/_webp.c"],
|
||||
libraries=libs,
|
||||
define_macros=defs))
|
||||
exts.append(
|
||||
Extension(
|
||||
"PIL._webp", ["src/_webp.c"], libraries=libs, define_macros=defs
|
||||
)
|
||||
)
|
||||
|
||||
tk_libs = ['psapi'] if sys.platform == 'win32' else []
|
||||
exts.append(Extension("PIL._imagingtk",
|
||||
["src/_imagingtk.c", "src/Tk/tkImaging.c"],
|
||||
include_dirs=['src/Tk'],
|
||||
libraries=tk_libs))
|
||||
tk_libs = ["psapi"] if sys.platform == "win32" else []
|
||||
exts.append(
|
||||
Extension(
|
||||
"PIL._imagingtk",
|
||||
["src/_imagingtk.c", "src/Tk/tkImaging.c"],
|
||||
include_dirs=["src/Tk"],
|
||||
libraries=tk_libs,
|
||||
)
|
||||
)
|
||||
|
||||
exts.append(Extension("PIL._imagingmath", ["src/_imagingmath.c"]))
|
||||
exts.append(Extension("PIL._imagingmorph", ["src/_imagingmorph.c"]))
|
||||
|
@ -717,8 +791,7 @@ class pil_build_ext(build_ext):
|
|||
|
||||
options = [
|
||||
(feature.jpeg, "JPEG"),
|
||||
(feature.jpeg2000, "OPENJPEG (JPEG2000)",
|
||||
feature.openjpeg_version),
|
||||
(feature.jpeg2000, "OPENJPEG (JPEG2000)", feature.openjpeg_version),
|
||||
(feature.zlib, "ZLIB (PNG/ZIP)"),
|
||||
(feature.imagequant, "LIBIMAGEQUANT"),
|
||||
(feature.tiff, "LIBTIFF"),
|
||||
|
@ -731,9 +804,9 @@ class pil_build_ext(build_ext):
|
|||
all = 1
|
||||
for option in options:
|
||||
if option[0]:
|
||||
version = ''
|
||||
version = ""
|
||||
if len(option) >= 3 and option[2]:
|
||||
version = ' (%s)' % option[2]
|
||||
version = " (%s)" % option[2]
|
||||
print("--- %s support available%s" % (option[1], version))
|
||||
else:
|
||||
print("*** %s support not available" % option[1])
|
||||
|
@ -744,8 +817,10 @@ class pil_build_ext(build_ext):
|
|||
if not all:
|
||||
print("To add a missing option, make sure you have the required")
|
||||
print("library and headers.")
|
||||
print("See https://pillow.readthedocs.io/en/latest/installation."
|
||||
"html#building-from-source")
|
||||
print(
|
||||
"See https://pillow.readthedocs.io/en/latest/installation."
|
||||
"html#building-from-source"
|
||||
)
|
||||
print("")
|
||||
|
||||
print("To check the build, run the selftest.py script.")
|
||||
|
@ -753,47 +828,49 @@ class pil_build_ext(build_ext):
|
|||
|
||||
|
||||
def debug_build():
|
||||
return hasattr(sys, 'gettotalrefcount')
|
||||
return hasattr(sys, "gettotalrefcount")
|
||||
|
||||
|
||||
needs_pytest = {'pytest', 'test', 'ptr'}.intersection(sys.argv)
|
||||
pytest_runner = ['pytest-runner'] if needs_pytest else []
|
||||
needs_pytest = {"pytest", "test", "ptr"}.intersection(sys.argv)
|
||||
pytest_runner = ["pytest-runner"] if needs_pytest else []
|
||||
|
||||
try:
|
||||
setup(name=NAME,
|
||||
version=PILLOW_VERSION,
|
||||
description='Python Imaging Library (Fork)',
|
||||
long_description=_read('README.rst').decode('utf-8'),
|
||||
author='Alex Clark (Fork Author)',
|
||||
author_email='aclark@aclark.net',
|
||||
url='http://python-pillow.org',
|
||||
classifiers=[
|
||||
"Development Status :: 6 - Mature",
|
||||
"License :: OSI Approved :: Historical Permission Notice and Disclaimer (HPND)", # noqa: E501
|
||||
"Programming Language :: Python :: 2",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
"Topic :: Multimedia :: Graphics",
|
||||
"Topic :: Multimedia :: Graphics :: Capture :: Digital Camera",
|
||||
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
|
||||
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
|
||||
"Topic :: Multimedia :: Graphics :: Viewers",
|
||||
],
|
||||
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
|
||||
cmdclass={"build_ext": pil_build_ext},
|
||||
ext_modules=[Extension("PIL._imaging", ["_imaging.c"])],
|
||||
include_package_data=True,
|
||||
setup_requires=pytest_runner,
|
||||
tests_require=['pytest'],
|
||||
packages=["PIL"],
|
||||
package_dir={'': 'src'},
|
||||
keywords=["Imaging", ],
|
||||
zip_safe=not (debug_build() or PLATFORM_MINGW), )
|
||||
setup(
|
||||
name=NAME,
|
||||
version=PILLOW_VERSION,
|
||||
description="Python Imaging Library (Fork)",
|
||||
long_description=_read("README.rst").decode("utf-8"),
|
||||
author="Alex Clark (Fork Author)",
|
||||
author_email="aclark@aclark.net",
|
||||
url="http://python-pillow.org",
|
||||
classifiers=[
|
||||
"Development Status :: 6 - Mature",
|
||||
"License :: OSI Approved :: Historical Permission Notice and Disclaimer (HPND)", # noqa: E501
|
||||
"Programming Language :: Python :: 2",
|
||||
"Programming Language :: Python :: 2.7",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.5",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
"Topic :: Multimedia :: Graphics",
|
||||
"Topic :: Multimedia :: Graphics :: Capture :: Digital Camera",
|
||||
"Topic :: Multimedia :: Graphics :: Capture :: Screen Capture",
|
||||
"Topic :: Multimedia :: Graphics :: Graphics Conversion",
|
||||
"Topic :: Multimedia :: Graphics :: Viewers",
|
||||
],
|
||||
python_requires=">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*",
|
||||
cmdclass={"build_ext": pil_build_ext},
|
||||
ext_modules=[Extension("PIL._imaging", ["_imaging.c"])],
|
||||
include_package_data=True,
|
||||
setup_requires=pytest_runner,
|
||||
tests_require=["pytest"],
|
||||
packages=["PIL"],
|
||||
package_dir={"": "src"},
|
||||
keywords=["Imaging"],
|
||||
zip_safe=not (debug_build() or PLATFORM_MINGW),
|
||||
)
|
||||
except RequiredDependencyException as err:
|
||||
msg = """
|
||||
|
||||
|
@ -803,7 +880,9 @@ a required dependency when compiling Pillow from source.
|
|||
Please see the install instructions at:
|
||||
https://pillow.readthedocs.io/en/latest/installation.html
|
||||
|
||||
""" % (str(err))
|
||||
""" % (
|
||||
str(err)
|
||||
)
|
||||
sys.stderr.write(msg)
|
||||
raise RequiredDependencyException(msg)
|
||||
except DependencyException as err:
|
||||
|
@ -812,6 +891,9 @@ except DependencyException as err:
|
|||
The headers or library files could not be found for %s,
|
||||
which was requested by the option flag --enable-%s
|
||||
|
||||
""" % (str(err), str(err))
|
||||
""" % (
|
||||
str(err),
|
||||
str(err),
|
||||
)
|
||||
sys.stderr.write(msg)
|
||||
raise DependencyException(msg)
|
||||
|
|
2
tox.ini
2
tox.ini
|
@ -24,7 +24,7 @@ deps =
|
|||
|
||||
[testenv:lint]
|
||||
commands =
|
||||
black --check --diff src
|
||||
black --check --diff .
|
||||
flake8 --statistics --count
|
||||
check-manifest
|
||||
deps =
|
||||
|
|
|
@ -6,18 +6,29 @@ import sys
|
|||
import getopt
|
||||
import os
|
||||
|
||||
from config import (compilers, compiler_from_env, pythons, pyversion_from_env,
|
||||
bit_from_env, VIRT_BASE, X64_EXT)
|
||||
from config import (
|
||||
compilers,
|
||||
compiler_from_env,
|
||||
pythons,
|
||||
pyversion_from_env,
|
||||
bit_from_env,
|
||||
VIRT_BASE,
|
||||
X64_EXT,
|
||||
)
|
||||
|
||||
|
||||
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))
|
||||
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)
|
||||
|
||||
|
||||
|
@ -25,16 +36,17 @@ def run_script(params):
|
|||
(version, script) = params
|
||||
try:
|
||||
print("Running %s" % version)
|
||||
filename = 'build_pillow_%s.cmd' % version
|
||||
with open(filename, 'w') as f:
|
||||
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,
|
||||
)
|
||||
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 --")
|
||||
|
@ -55,7 +67,9 @@ set MPLSRC=%%~dp0\..
|
|||
set INCLIB=%%~dp0\depends
|
||||
set BLDOPT=%s
|
||||
cd /D %%MPLSRC%%
|
||||
""" % (op)
|
||||
""" % (
|
||||
op
|
||||
)
|
||||
|
||||
|
||||
def footer():
|
||||
|
@ -66,10 +80,13 @@ exit
|
|||
|
||||
def vc_setup(compiler, bit):
|
||||
script = ""
|
||||
if compiler['vc_version'] == '2015':
|
||||
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""" % arch
|
||||
script = (
|
||||
r"""
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" %s"""
|
||||
% arch
|
||||
)
|
||||
return script
|
||||
|
||||
|
||||
|
@ -77,27 +94,27 @@ 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%"
|
||||
if "PYTHON" in os.environ:
|
||||
args["python_path"] = "%PYTHON%"
|
||||
else:
|
||||
args['python_path'] = "%s%s\\Scripts" % (VIRT_BASE, py_ver)
|
||||
args["python_path"] = "%s%s\\Scripts" % (VIRT_BASE, py_ver)
|
||||
|
||||
args['executable'] = "python.exe"
|
||||
if 'EXECUTABLE' in os.environ:
|
||||
args['executable'] = "%EXECUTABLE%"
|
||||
args["executable"] = "python.exe"
|
||||
if "EXECUTABLE" in os.environ:
|
||||
args["executable"] = "%EXECUTABLE%"
|
||||
|
||||
args['py_ver'] = py_ver
|
||||
if '27' in py_ver:
|
||||
args['tcl_ver'] = '85'
|
||||
args["py_ver"] = py_ver
|
||||
if "27" in py_ver:
|
||||
args["tcl_ver"] = "85"
|
||||
else:
|
||||
args['tcl_ver'] = '86'
|
||||
args["tcl_ver"] = "86"
|
||||
|
||||
if compiler['vc_version'] == '2015':
|
||||
args['imaging_libs'] = ' build_ext --add-imaging-libs=msvcrt'
|
||||
if compiler["vc_version"] == "2015":
|
||||
args["imaging_libs"] = " build_ext --add-imaging-libs=msvcrt"
|
||||
else:
|
||||
args['imaging_libs'] = ''
|
||||
args["imaging_libs"] = ""
|
||||
|
||||
args['vc_setup'] = vc_setup(compiler, bit)
|
||||
args["vc_setup"] = vc_setup(compiler, bit)
|
||||
|
||||
script = r"""
|
||||
setlocal EnableDelayedExpansion
|
||||
|
@ -119,34 +136,44 @@ endlocal
|
|||
|
||||
def clean():
|
||||
try:
|
||||
shutil.rmtree('../build')
|
||||
shutil.rmtree("../build")
|
||||
except Exception:
|
||||
# could already be removed
|
||||
pass
|
||||
run_script(('virtualenvs', setup_vms()))
|
||||
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()])))
|
||||
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(("%s%s" % (py_version, X64_EXT),
|
||||
"\n".join([header(op),
|
||||
build_one("%sx64" % py_version,
|
||||
py_compilers[64], 64),
|
||||
footer()])))
|
||||
scripts.append(
|
||||
(
|
||||
"%s%s" % (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 %s: %s" % (version, status and 'ERR' or 'OK'))
|
||||
print("Compiled %s: %s" % (version, status and "ERR" or "OK"))
|
||||
|
||||
|
||||
def run_one(op):
|
||||
|
@ -155,27 +182,28 @@ def run_one(op):
|
|||
py_version = pyversion_from_env()
|
||||
bit = bit_from_env()
|
||||
|
||||
run_script((py_version,
|
||||
"\n".join([header(op),
|
||||
build_one(py_version, compiler, bit),
|
||||
footer()])
|
||||
))
|
||||
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', 'dist', 'wheel'])
|
||||
if __name__ == "__main__":
|
||||
opts, args = getopt.getopt(sys.argv[1:], "", ["clean", "dist", "wheel"])
|
||||
opts = dict(opts)
|
||||
|
||||
if '--clean' in opts:
|
||||
if "--clean" in opts:
|
||||
clean()
|
||||
|
||||
op = 'install'
|
||||
if '--dist' in opts:
|
||||
op = "install"
|
||||
if "--dist" in opts:
|
||||
op = "bdist_wininst --user-access-control=auto"
|
||||
elif '--wheel' in opts:
|
||||
elif "--wheel" in opts:
|
||||
op = "bdist_wheel"
|
||||
|
||||
if 'PYTHON' in os.environ:
|
||||
if "PYTHON" in os.environ:
|
||||
run_one(op)
|
||||
else:
|
||||
main(op)
|
||||
|
|
|
@ -3,8 +3,7 @@ from untar import untar
|
|||
import os
|
||||
|
||||
from fetch import fetch
|
||||
from config import (compilers, all_compilers, compiler_from_env, bit_from_env,
|
||||
libs)
|
||||
from config import compilers, all_compilers, compiler_from_env, bit_from_env, libs
|
||||
from build import vc_setup
|
||||
|
||||
|
||||
|
@ -12,8 +11,8 @@ def _relpath(*args):
|
|||
return os.path.join(os.getcwd(), *args)
|
||||
|
||||
|
||||
build_dir = _relpath('build')
|
||||
inc_dir = _relpath('depends')
|
||||
build_dir = _relpath("build")
|
||||
inc_dir = _relpath("depends")
|
||||
|
||||
|
||||
def check_sig(filename, signame):
|
||||
|
@ -32,37 +31,40 @@ def mkdirs():
|
|||
pass
|
||||
for compiler in all_compilers():
|
||||
try:
|
||||
os.mkdir(os.path.join(inc_dir, compiler['inc_dir']))
|
||||
os.mkdir(os.path.join(inc_dir, compiler["inc_dir"]))
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
|
||||
def extract(src, dest):
|
||||
if '.zip' in src:
|
||||
if ".zip" in src:
|
||||
return unzip(src, dest)
|
||||
if '.tar.gz' in src or '.tgz' in src:
|
||||
if ".tar.gz" in src or ".tgz" in src:
|
||||
return untar(src, dest)
|
||||
|
||||
|
||||
def extract_libs():
|
||||
for name, lib in libs.items():
|
||||
filename = lib['filename']
|
||||
filename = lib["filename"]
|
||||
if not os.path.exists(filename):
|
||||
filename = fetch(lib['url'])
|
||||
if name == 'openjpeg':
|
||||
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'])):
|
||||
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']))
|
||||
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"""
|
||||
return (
|
||||
r"""
|
||||
rem build openjpeg
|
||||
setlocal
|
||||
@echo on
|
||||
|
@ -72,12 +74,15 @@ copy /Y /B openjpeg-2.0.0-win32-x86\include\openjpeg-2.0 %%INCLIB%%\openjpeg-2.
|
|||
copy /Y /B openjpeg-2.0.0-win32-x86\bin\ %%INCLIB%%
|
||||
copy /Y /B openjpeg-2.0.0-win32-x86\lib\ %%INCLIB%%
|
||||
endlocal
|
||||
""" % compiler
|
||||
"""
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def cp_tk(ver_85, ver_86):
|
||||
versions = {'ver_85': ver_85, 'ver_86': ver_86}
|
||||
return r"""
|
||||
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\
|
||||
|
@ -87,7 +92,9 @@ 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
|
||||
"""
|
||||
% versions
|
||||
)
|
||||
|
||||
|
||||
def header():
|
||||
|
@ -96,15 +103,21 @@ 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 %s=%%BUILD%%\%s' % (k.upper(), v['dir'])
|
||||
for (k, v) in libs.items() if v['dir'])
|
||||
""" + "\n".join(
|
||||
r"set %s=%%BUILD%%\%s" % (k.upper(), v["dir"])
|
||||
for (k, v) in libs.items()
|
||||
if v["dir"]
|
||||
)
|
||||
|
||||
|
||||
def setup_compiler(compiler):
|
||||
return r"""setlocal EnableDelayedExpansion
|
||||
return (
|
||||
r"""setlocal EnableDelayedExpansion
|
||||
call "%%ProgramFiles%%\Microsoft SDKs\Windows\%(env_version)s\Bin\SetEnv.Cmd" /Release %(env_flags)s
|
||||
set INCLIB=%%INCLIB%%\%(inc_dir)s
|
||||
""" % compiler # noqa: E501
|
||||
""" # noqa: E501
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def end_compiler():
|
||||
|
@ -114,15 +127,18 @@ endlocal
|
|||
|
||||
|
||||
def nmake_openjpeg(compiler, bit):
|
||||
if compiler['env_version'] == 'v7.0':
|
||||
if compiler["env_version"] == "v7.0":
|
||||
return ""
|
||||
|
||||
atts = {'op_ver': '2.3.1'}
|
||||
atts = {"op_ver": "2.3.1"}
|
||||
atts.update(compiler)
|
||||
return r"""
|
||||
return (
|
||||
r"""
|
||||
rem build openjpeg
|
||||
setlocal
|
||||
""" + vc_setup(compiler, bit) + r"""
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
@echo on
|
||||
cd /D %%OPENJPEG%%%(inc_dir)s
|
||||
|
||||
|
@ -133,15 +149,20 @@ copy /Y /B bin\* %%INCLIB%%
|
|||
mkdir %%INCLIB%%\openjpeg-%(op_ver)s
|
||||
copy /Y /B src\lib\openjp2\*.h %%INCLIB%%\openjpeg-%(op_ver)s
|
||||
endlocal
|
||||
""" % atts # noqa: E501
|
||||
""" # noqa: E501
|
||||
% atts
|
||||
)
|
||||
|
||||
|
||||
def nmake_libs(compiler, bit):
|
||||
# undone -- pre, makes, headers, libs
|
||||
script = r"""
|
||||
script = (
|
||||
r"""
|
||||
rem Build libjpeg
|
||||
setlocal
|
||||
""" + vc_setup(compiler, bit) + r"""
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
cd /D %%JPEG%%
|
||||
nmake -f makefile.vc setup-vc6
|
||||
nmake -f makefile.vc clean
|
||||
|
@ -165,7 +186,9 @@ endlocal
|
|||
|
||||
rem Build webp
|
||||
setlocal
|
||||
""" + vc_setup(compiler, bit) + r"""
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
cd /D %%WEBP%%
|
||||
rd /S /Q %%WEBP%%\output\release-static
|
||||
nmake -f Makefile.vc CFG=release-static RTLIBCFG=static OBJDIR=output all
|
||||
|
@ -176,7 +199,9 @@ endlocal
|
|||
|
||||
rem Build libtiff
|
||||
setlocal
|
||||
""" + vc_setup(compiler, bit) + r"""
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
rem do after building jpeg and zlib
|
||||
copy %%~dp0\nmake.opt %%TIFF%%
|
||||
|
||||
|
@ -188,6 +213,7 @@ copy /Y /B libtiff\*.lib %%INCLIB%%
|
|||
copy /Y /B libtiff\tiff*.h %%INCLIB%%
|
||||
endlocal
|
||||
"""
|
||||
)
|
||||
return script % compiler
|
||||
|
||||
|
||||
|
@ -200,36 +226,49 @@ 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'
|
||||
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
|
||||
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
|
||||
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 # noqa: E501
|
||||
)
|
||||
return script % compiler
|
||||
|
||||
|
||||
def build_lcms2(compiler):
|
||||
if compiler['env_version'] == 'v7.1':
|
||||
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 ''
|
||||
if compiler["platform"] == "x64":
|
||||
return ""
|
||||
|
||||
"""Build LCMS on VC2008. This version is only 32bit/Win32"""
|
||||
return r"""
|
||||
return (
|
||||
r"""
|
||||
rem Build lcms2
|
||||
setlocal
|
||||
rd /S /Q %%LCMS%%\Lib
|
||||
|
@ -239,11 +278,14 @@ rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
|||
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
||||
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
|
||||
endlocal
|
||||
""" % compiler # noqa: E501
|
||||
""" # noqa: E501
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def build_lcms_71(compiler):
|
||||
return r"""
|
||||
return (
|
||||
r"""
|
||||
rem Build lcms2
|
||||
setlocal
|
||||
rd /S /Q %%LCMS%%\Lib
|
||||
|
@ -253,21 +295,26 @@ rd /S /Q %%LCMS%%\Projects\VC%(vc_version)s\Release
|
|||
xcopy /Y /E /Q %%LCMS%%\include %%INCLIB%%
|
||||
copy /Y /B %%LCMS%%\Lib\MS\*.lib %%INCLIB%%
|
||||
endlocal
|
||||
""" % compiler # noqa: E501
|
||||
""" # noqa: E501
|
||||
% compiler
|
||||
)
|
||||
|
||||
|
||||
def build_ghostscript(compiler, bit):
|
||||
script = r"""
|
||||
script = (
|
||||
r"""
|
||||
rem Build gs
|
||||
setlocal
|
||||
""" + vc_setup(compiler, bit) + r"""
|
||||
set MSVC_VERSION=""" + {
|
||||
"2010": "90",
|
||||
"2015": "14"
|
||||
}[compiler['vc_version']] + r"""
|
||||
"""
|
||||
+ vc_setup(compiler, bit)
|
||||
+ r"""
|
||||
set MSVC_VERSION="""
|
||||
+ {"2010": "90", "2015": "14"}[compiler["vc_version"]]
|
||||
+ r"""
|
||||
set RCOMP="C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin\RC.Exe"
|
||||
cd /D %%GHOSTSCRIPT%%
|
||||
"""
|
||||
)
|
||||
if bit == 64:
|
||||
script += r"""
|
||||
set WIN64=""
|
||||
|
@ -277,7 +324,7 @@ nmake -f psi/msvc.mak
|
|||
copy /Y /B bin\ C:\Python27\
|
||||
endlocal
|
||||
"""
|
||||
return script % compiler # noqa: E501
|
||||
return script % compiler
|
||||
|
||||
|
||||
def add_compiler(compiler, bit):
|
||||
|
@ -295,17 +342,15 @@ def add_compiler(compiler, bit):
|
|||
|
||||
mkdirs()
|
||||
extract_libs()
|
||||
script = [header(),
|
||||
cp_tk(libs['tk-8.5']['version'],
|
||||
libs['tk-8.6']['version'])]
|
||||
script = [header(), cp_tk(libs["tk-8.5"]["version"], libs["tk-8.6"]["version"])]
|
||||
|
||||
|
||||
if 'PYTHON' in os.environ:
|
||||
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:
|
||||
with open("build_deps.cmd", "w") as f:
|
||||
f.write("\n".join(script))
|
||||
|
|
|
@ -1,83 +1,85 @@
|
|||
import os
|
||||
|
||||
SF_MIRROR = 'http://iweb.dl.sourceforge.net'
|
||||
PILLOW_DEPENDS_DIR = 'C:\\pillow-depends\\'
|
||||
SF_MIRROR = "http://iweb.dl.sourceforge.net"
|
||||
PILLOW_DEPENDS_DIR = "C:\\pillow-depends\\"
|
||||
|
||||
pythons = {'27': {'compiler': 7, 'vc': 2010},
|
||||
'pypy2': {'compiler': 7, 'vc': 2010},
|
||||
'35': {'compiler': 7.1, 'vc': 2015},
|
||||
'36': {'compiler': 7.1, 'vc': 2015},
|
||||
'37': {'compiler': 7.1, 'vc': 2015}}
|
||||
pythons = {
|
||||
"27": {"compiler": 7, "vc": 2010},
|
||||
"pypy2": {"compiler": 7, "vc": 2010},
|
||||
"35": {"compiler": 7.1, "vc": 2015},
|
||||
"36": {"compiler": 7.1, "vc": 2015},
|
||||
"37": {"compiler": 7.1, "vc": 2015},
|
||||
}
|
||||
|
||||
VIRT_BASE = "c:/vp/"
|
||||
X64_EXT = os.environ.get('X64_EXT', "x64")
|
||||
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': PILLOW_DEPENDS_DIR + 'zlib1211.zip',
|
||||
'dir': 'zlib-1.2.11',
|
||||
"zlib": {
|
||||
"url": "http://zlib.net/zlib1211.zip",
|
||||
"filename": PILLOW_DEPENDS_DIR + "zlib1211.zip",
|
||||
"dir": "zlib-1.2.11",
|
||||
},
|
||||
'jpeg': {
|
||||
'url': 'http://www.ijg.org/files/jpegsr9c.zip',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'jpegsr9c.zip',
|
||||
'dir': 'jpeg-9c',
|
||||
"jpeg": {
|
||||
"url": "http://www.ijg.org/files/jpegsr9c.zip",
|
||||
"filename": PILLOW_DEPENDS_DIR + "jpegsr9c.zip",
|
||||
"dir": "jpeg-9c",
|
||||
},
|
||||
'tiff': {
|
||||
'url': 'ftp://download.osgeo.org/libtiff/tiff-4.0.10.tar.gz',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'tiff-4.0.10.tar.gz',
|
||||
'dir': 'tiff-4.0.10',
|
||||
"tiff": {
|
||||
"url": "ftp://download.osgeo.org/libtiff/tiff-4.0.10.tar.gz",
|
||||
"filename": PILLOW_DEPENDS_DIR + "tiff-4.0.10.tar.gz",
|
||||
"dir": "tiff-4.0.10",
|
||||
},
|
||||
'freetype': {
|
||||
'url': 'https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz', # noqa: E501
|
||||
'filename': PILLOW_DEPENDS_DIR + 'freetype-2.10.0.tar.gz',
|
||||
'dir': 'freetype-2.10.0',
|
||||
"freetype": {
|
||||
"url": "https://download.savannah.gnu.org/releases/freetype/freetype-2.10.0.tar.gz", # noqa: E501
|
||||
"filename": PILLOW_DEPENDS_DIR + "freetype-2.10.0.tar.gz",
|
||||
"dir": "freetype-2.10.0",
|
||||
},
|
||||
'lcms': {
|
||||
'url': SF_MIRROR+'/project/lcms/lcms/2.7/lcms2-2.7.zip',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'lcms2-2.7.zip',
|
||||
'dir': 'lcms2-2.7',
|
||||
"lcms": {
|
||||
"url": SF_MIRROR + "/project/lcms/lcms/2.7/lcms2-2.7.zip",
|
||||
"filename": PILLOW_DEPENDS_DIR + "lcms2-2.7.zip",
|
||||
"dir": "lcms2-2.7",
|
||||
},
|
||||
'ghostscript': {
|
||||
'url': 'https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs927/ghostscript-9.27.tar.gz', # noqa: E501
|
||||
'filename': PILLOW_DEPENDS_DIR + 'ghostscript-9.27.tar.gz',
|
||||
'dir': 'ghostscript-9.27',
|
||||
"ghostscript": {
|
||||
"url": "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs927/ghostscript-9.27.tar.gz", # noqa: E501
|
||||
"filename": PILLOW_DEPENDS_DIR + "ghostscript-9.27.tar.gz",
|
||||
"dir": "ghostscript-9.27",
|
||||
},
|
||||
'tcl-8.5': {
|
||||
'url': SF_MIRROR+'/project/tcl/Tcl/8.5.19/tcl8519-src.zip',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'tcl8519-src.zip',
|
||||
'dir': '',
|
||||
"tcl-8.5": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.5.19/tcl8519-src.zip",
|
||||
"filename": PILLOW_DEPENDS_DIR + "tcl8519-src.zip",
|
||||
"dir": "",
|
||||
},
|
||||
'tk-8.5': {
|
||||
'url': SF_MIRROR+'/project/tcl/Tcl/8.5.19/tk8519-src.zip',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'tk8519-src.zip',
|
||||
'dir': '',
|
||||
'version': '8.5.19',
|
||||
"tk-8.5": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.5.19/tk8519-src.zip",
|
||||
"filename": PILLOW_DEPENDS_DIR + "tk8519-src.zip",
|
||||
"dir": "",
|
||||
"version": "8.5.19",
|
||||
},
|
||||
'tcl-8.6': {
|
||||
'url': SF_MIRROR+'/project/tcl/Tcl/8.6.9/tcl869-src.zip',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'tcl869-src.zip',
|
||||
'dir': '',
|
||||
"tcl-8.6": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.6.9/tcl869-src.zip",
|
||||
"filename": PILLOW_DEPENDS_DIR + "tcl869-src.zip",
|
||||
"dir": "",
|
||||
},
|
||||
'tk-8.6': {
|
||||
'url': SF_MIRROR+'/project/tcl/Tcl/8.6.9/tk869-src.zip',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'tk869-src.zip',
|
||||
'dir': '',
|
||||
'version': '8.6.9',
|
||||
"tk-8.6": {
|
||||
"url": SF_MIRROR + "/project/tcl/Tcl/8.6.9/tk869-src.zip",
|
||||
"filename": PILLOW_DEPENDS_DIR + "tk869-src.zip",
|
||||
"dir": "",
|
||||
"version": "8.6.9",
|
||||
},
|
||||
'webp': {
|
||||
'url': 'http://downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'libwebp-1.0.2.tar.gz',
|
||||
'dir': 'libwebp-1.0.2',
|
||||
"webp": {
|
||||
"url": "http://downloads.webmproject.org/releases/webp/libwebp-1.0.2.tar.gz",
|
||||
"filename": PILLOW_DEPENDS_DIR + "libwebp-1.0.2.tar.gz",
|
||||
"dir": "libwebp-1.0.2",
|
||||
},
|
||||
'openjpeg': {
|
||||
'url': 'https://github.com/uclouvain/openjpeg/archive/v2.3.1.tar.gz',
|
||||
'filename': PILLOW_DEPENDS_DIR + 'openjpeg-2.3.1.tar.gz',
|
||||
'dir': 'openjpeg-2.3.1',
|
||||
"openjpeg": {
|
||||
"url": "https://github.com/uclouvain/openjpeg/archive/v2.3.1.tar.gz",
|
||||
"filename": PILLOW_DEPENDS_DIR + "openjpeg-2.3.1.tar.gz",
|
||||
"dir": "openjpeg-2.3.1",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -85,63 +87,63 @@ compilers = {
|
|||
7: {
|
||||
2010: {
|
||||
64: {
|
||||
'env_version': 'v7.0',
|
||||
'vc_version': '2010',
|
||||
'env_flags': '/x64 /xp',
|
||||
'inc_dir': 'msvcr90-x64',
|
||||
'platform': 'x64',
|
||||
'webp_platform': 'x64',
|
||||
"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',
|
||||
}
|
||||
"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',
|
||||
"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',
|
||||
}
|
||||
"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 = os.environ["PYTHON"]
|
||||
|
||||
py_version = '27'
|
||||
py_version = "27"
|
||||
for k in pythons:
|
||||
if k in py:
|
||||
py_version = k
|
||||
break
|
||||
|
||||
if '64' in py:
|
||||
py_version = '%s%s' % (py_version, X64_EXT)
|
||||
if "64" in py:
|
||||
py_version = "%s%s" % (py_version, X64_EXT)
|
||||
|
||||
return py_version
|
||||
|
||||
|
||||
def compiler_from_env():
|
||||
py = os.environ['PYTHON']
|
||||
py = os.environ["PYTHON"]
|
||||
|
||||
for k, v in pythons.items():
|
||||
if k in py:
|
||||
|
@ -149,13 +151,13 @@ def compiler_from_env():
|
|||
break
|
||||
|
||||
bit = bit_from_env()
|
||||
return compilers[py_info['compiler']][py_info['vc']][bit]
|
||||
return compilers[py_info["compiler"]][py_info["vc"]][bit]
|
||||
|
||||
|
||||
def bit_from_env():
|
||||
py = os.environ['PYTHON']
|
||||
py = os.environ["PYTHON"]
|
||||
|
||||
return 64 if '64' in py else 32
|
||||
return 64 if "64" in py else 32
|
||||
|
||||
|
||||
def all_compilers():
|
||||
|
|
|
@ -5,7 +5,7 @@ import urllib.request
|
|||
|
||||
|
||||
def fetch(url):
|
||||
name = urllib.parse.urlsplit(url)[2].split('/')[-1]
|
||||
name = urllib.parse.urlsplit(url)[2].split("/")[-1]
|
||||
|
||||
if not os.path.exists(name):
|
||||
print("Fetching", url)
|
||||
|
@ -14,10 +14,10 @@ def fetch(url):
|
|||
except urllib.error.URLError:
|
||||
r = urllib.request.urlopen(url)
|
||||
content = r.read()
|
||||
with open(name, 'wb') as fd:
|
||||
with open(name, "wb") as fd:
|
||||
fd.write(content)
|
||||
return name
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
fetch(sys.argv[1])
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
from fetch import fetch
|
||||
import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
for version in ['2.7.15', '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))
|
||||
if __name__ == "__main__":
|
||||
for version in ["2.7.15", "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')
|
||||
os.system("pip install virtualenv")
|
||||
|
|
|
@ -12,16 +12,14 @@ def test_one(params):
|
|||
python, architecture = params
|
||||
try:
|
||||
print("Running: %s, %s" % params)
|
||||
command = [r'%s\%s%s\Scripts\python.exe' %
|
||||
(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)
|
||||
command = [
|
||||
r"%s\%s%s\Scripts\python.exe" % (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 %s, %s -- %s" % (python, architecture, status))
|
||||
|
@ -31,16 +29,17 @@ def test_one(params):
|
|||
return (python, architecture, -1, str(msg))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
|
||||
os.chdir('..')
|
||||
matrix = [(python, architecture) for python in pythons
|
||||
for architecture in ('', X64_EXT)]
|
||||
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("%s%s: %s" % (python, architecture, status and 'ERR' or 'PASS'))
|
||||
print("%s%s: %s" % (python, architecture, status and "ERR" or "PASS"))
|
||||
|
||||
res = all(status for (python, architecture, status, trace) in results)
|
||||
sys.exit(res)
|
||||
|
|
|
@ -3,9 +3,9 @@ import tarfile
|
|||
|
||||
|
||||
def untar(src, dest):
|
||||
with tarfile.open(src, 'r:gz') as tgz:
|
||||
with tarfile.open(src, "r:gz") as tgz:
|
||||
tgz.extractall(dest)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
untar(sys.argv[1], sys.argv[2])
|
||||
|
|
|
@ -7,5 +7,5 @@ def unzip(src, dest):
|
|||
zf.extractall(dest)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
unzip(sys.argv[1], sys.argv[2])
|
||||
|
|
Loading…
Reference in New Issue
Block a user