From a69a47c042b83ef03bdb8d5b81cdf9f303a6a984 Mon Sep 17 00:00:00 2001 From: wiredfool Date: Thu, 11 Jun 2015 13:11:26 -0700 Subject: [PATCH] refactoring for PYTHON environment --- winbuild/build.py | 18 ++++-------------- winbuild/build_dep.py | 17 +++-------------- winbuild/config.py | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+), 28 deletions(-) diff --git a/winbuild/build.py b/winbuild/build.py index f96111b9d..a4c4a5e92 100644 --- a/winbuild/build.py +++ b/winbuild/build.py @@ -109,24 +109,14 @@ def main(op): print ("Compiled %s: %s" % (version, status)) def run_one(op): - py = os.environ['PYTHON'] - - py_version = '27' - for k,v in pythons.items(): - if k in py: - compiler_version = v - py_version = k - break - - bit = 32 - if '64' in py: - bit = 64 - py_version = '%s-x64' % py_version + + compiler = compiler_fromEnv() + py_version = pyversion_fromEnv() run_script((py_version, "\n".join([header(op), - build_one(py_version, compilers[(compiler_version, bit)]), + build_one(py_version, compiler), footer()]) )) diff --git a/winbuild/build_dep.py b/winbuild/build_dep.py index 36876c488..8c782853e 100644 --- a/winbuild/build_dep.py +++ b/winbuild/build_dep.py @@ -250,7 +250,7 @@ def add_compiler(compiler): mkdirs() -fetch_libs() +#fetch_libs() #extract_binlib() script = [header()] #, cp_tk()] @@ -259,20 +259,9 @@ script = [header()] #, cp_tk()] # add_compiler(compiler) if 'PYTHON' in os.environ: - bit = 32 - if '64' in os.environ['PYTHON']: - bit = 64 - break - - ver = 7 - for k,v in pythons: - if k in os.environ['PYTHON']: - ver = v - break - - add_compiler(compilers[(ver,bit)]) + add_compiler(compiler_fromEnv()) else: - compiler = compilers[(7,64)] + add_compiler(compilers[(7,64)]) with open('build_deps.cmd', 'w') as f: f.write("\n".join(script)) diff --git a/winbuild/config.py b/winbuild/config.py index 26f81d84d..7ac50f209 100644 --- a/winbuild/config.py +++ b/winbuild/config.py @@ -1,3 +1,5 @@ +import os + SF_MIRROR = 'http://hivelocity.dl.sourceforge.net' SF_MIRROR = 'http://iweb.dl.sourceforge.net' @@ -102,3 +104,33 @@ compilers = { (7,64): { }, } + + +def pyversion_fromEnv(): + py = os.environ['PYTHON'] + + py_version = '27' + for k,v in pythons.items(): + if k in py: + py_version = k + break + + if '64' in py: + py_version = '%s-x64' % py_version + + return py_version + + +def compiler_fromEnv(): + py = os.environ['PYTHON'] + + for k,v in pythons.items(): + if k in py: + compiler_version = v + break + + bit = 32 + if '64' in py: + bit = 64 + + return compilers[(compiler_version, bit)]