mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
python/multiprocessing build process + clean/dist options
This commit is contained in:
parent
2f7bbffb5b
commit
251749b110
|
@ -1,4 +1,8 @@
|
||||||
#/usr/bin/env python34
|
#/usr/bin/env python3
|
||||||
|
|
||||||
|
import subprocess, multiprocessing
|
||||||
|
import shutil
|
||||||
|
import sys, getopt
|
||||||
|
|
||||||
from config import *
|
from config import *
|
||||||
|
|
||||||
|
@ -10,6 +14,29 @@ def setup_vms():
|
||||||
(py, arch, VIRT_BASE, py, arch))
|
(py, arch, VIRT_BASE, py, arch))
|
||||||
return "\n".join(ret)
|
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 ("Done with %s: %s" % (version, status))
|
||||||
|
return (version, status, trace, stderr)
|
||||||
|
except Exception as msg:
|
||||||
|
print ("Error with %s: %s" % (version, str(msg)))
|
||||||
|
return (version, -1, "", str(msg))
|
||||||
|
|
||||||
|
|
||||||
def header(op):
|
def header(op):
|
||||||
return r"""
|
return r"""
|
||||||
setlocal
|
setlocal
|
||||||
|
@ -37,19 +64,53 @@ set INCLUDE=%%INCLUDE%%;%%INCLIB%%\%(inc_dir)s;%%INCLIB%%\tcl85\include
|
||||||
|
|
||||||
setlocal
|
setlocal
|
||||||
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl
|
set LIB=%%LIB%%;C:\Python%(py_ver)s\tcl
|
||||||
rd /q /s build
|
|
||||||
call c:\vp\%(py_ver)s\Scripts\python.exe setup.py %%BLDOPT%%
|
call c:\vp\%(py_ver)s\Scripts\python.exe setup.py %%BLDOPT%%
|
||||||
endlocal
|
endlocal
|
||||||
|
|
||||||
endlocal
|
endlocal
|
||||||
""" % args
|
""" % args
|
||||||
|
|
||||||
script = [setup_vms(), header('install')]
|
def clean():
|
||||||
|
try:
|
||||||
|
shutil.rmtree('../build')
|
||||||
|
except:
|
||||||
|
# could already be removed
|
||||||
|
pass
|
||||||
|
run_script(('virtualenvs', setup_vms()))
|
||||||
|
|
||||||
|
def main(op):
|
||||||
|
scripts = []
|
||||||
|
|
||||||
for py_version, compiler_version in pythons.items():
|
for py_version, compiler_version in pythons.items():
|
||||||
script.append(build_one(py_version, compilers[(compiler_version, 32)]))
|
scripts.append((py_version,
|
||||||
script.append(build_one("%sx64" %py_version, compilers[(compiler_version, 64)]))
|
"\n".join([header(op),
|
||||||
script.append(footer())
|
build_one(py_version,
|
||||||
|
compilers[(compiler_version, 32)]),
|
||||||
|
footer()])))
|
||||||
|
|
||||||
with open('build_pillows.cmd', 'w') as f:
|
scripts.append(("%sx64" % py_version,
|
||||||
f.write("\n".join(script))
|
"\n".join([header(op),
|
||||||
|
build_one("%sx64" %py_version,
|
||||||
|
compilers[(compiler_version, 64)]),
|
||||||
|
footer()])))
|
||||||
|
|
||||||
|
pool = multiprocessing.Pool()
|
||||||
|
results = pool.map(run_script, scripts)
|
||||||
|
|
||||||
|
for (version, status, trace, err) in results:
|
||||||
|
print ("Compiled %s: %s" % (version, status))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__=='__main__':
|
||||||
|
opts, args = getopt.getopt(sys.argv[1:], '', ['clean', 'dist'])
|
||||||
|
opts = dict(opts)
|
||||||
|
|
||||||
|
if '--clean' in opts:
|
||||||
|
clean()
|
||||||
|
|
||||||
|
op = 'install'
|
||||||
|
if '--dist' in opts:
|
||||||
|
op = "bdist_wininst --user-access-control=auto"
|
||||||
|
|
||||||
|
main(op)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user