From 637a1551a1f4a99ecc274dc8854945424dd7e674 Mon Sep 17 00:00:00 2001 From: Stephen Mackenzie Date: Mon, 21 Mar 2022 23:33:26 -0400 Subject: [PATCH 1/6] feat: add entry to .gitignore which ignores src files --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 03ad656..570cd5d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,9 @@ # rez build +# src files +recipes/*/src/* + # Byte-compiled / optimized / DLL files __pycache__/ *.py[cod] From af02a59782397a6c46e1211cab28c34ad353feb7 Mon Sep 17 00:00:00 2001 From: Stephen Mackenzie Date: Mon, 21 Mar 2022 23:34:59 -0400 Subject: [PATCH 2/6] feat: add basic cmake recipe --- recipes/cmake/3.22.3/build.py | 1 + recipes/cmake/3.22.3/package.py | 1 + recipes/cmake/3.22.3/src | 1 + recipes/cmake/build.py | 131 ++++++++++++++++++++++++++++++++ recipes/cmake/package.py | 96 +++++++++++++++++++++++ 5 files changed, 230 insertions(+) create mode 120000 recipes/cmake/3.22.3/build.py create mode 120000 recipes/cmake/3.22.3/package.py create mode 120000 recipes/cmake/3.22.3/src create mode 100644 recipes/cmake/build.py create mode 100644 recipes/cmake/package.py diff --git a/recipes/cmake/3.22.3/build.py b/recipes/cmake/3.22.3/build.py new file mode 120000 index 0000000..3c76af7 --- /dev/null +++ b/recipes/cmake/3.22.3/build.py @@ -0,0 +1 @@ +../build.py \ No newline at end of file diff --git a/recipes/cmake/3.22.3/package.py b/recipes/cmake/3.22.3/package.py new file mode 120000 index 0000000..d04d114 --- /dev/null +++ b/recipes/cmake/3.22.3/package.py @@ -0,0 +1 @@ +../package.py \ No newline at end of file diff --git a/recipes/cmake/3.22.3/src b/recipes/cmake/3.22.3/src new file mode 120000 index 0000000..5cd551c --- /dev/null +++ b/recipes/cmake/3.22.3/src @@ -0,0 +1 @@ +../src \ No newline at end of file diff --git a/recipes/cmake/build.py b/recipes/cmake/build.py new file mode 100644 index 0000000..544daa3 --- /dev/null +++ b/recipes/cmake/build.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python + +import multiprocessing +import os +import re +import shutil +import subprocess +import sys + +SOURCE_TAR = "src/cmake-{version}.tar.gz" + +CONFIGURE_ENV = { + "linux_x86_64_rocky-8.5": { + "CFLAGS": "-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions " + "-fstack-protector-strong --param=ssp-buffer-size=4 " + "-grecord-gcc-switches -m64 -mtune=generic ", + "LDFLAGS": "-Wl,-z,relro,-rpath={config.package_path}/lib64" + } +} + +#CONFIGURE_OPTS = { +# "linux_x86_64_rocky-8.5": #"--build=x86_64-unknown-linux-gnu " +# #"--host-x86_64-unknown-linux-gnu " +# "--prefix={config.package_path} --enable-ipv6 " +# "--enable-shared " +# "--with-dbmliborder=gdbm:ndbm:bdb " +# "--with-system-expat --with-system-ffi " +# # "--enable-optimizations " +# "--without-ensurepip " +#} + + + +def build(): + build_config = BuildConfig() + + if not build_config.is_installing: + raise SystemExit("ERROR: This build must be run in a mode which would install or release it") + + source_tar = os.path.join(build_config.source_path, SOURCE_TAR.format(version=build_config.package_version)) + + _build_and_install_payload(build_config, source_tar) + + if build_config.is_releasing: + _lock_payload(build_config) + +def _build_and_install_payload(config, source_tar): + cmake_file = os.path.join(config.build_path, "CMakeLists.txt") + with open(cmake_file, "w") as outstream: + _generate_cmakelists(config, source_tar, stream=outstream) + + subprocess.check_call(["cmake", "."], cwd=config.build_path) + subprocess.check_call(["make"], cwd=config.build_path) + +def _generate_cmakelists(build_config, source_tar, stream=sys.stdout): + """ + Args: + build_config (`BuildConfig`): Build configuration + source_tar (str): Path to source tarball + stream (file): Output file stream + """ + qt_gui_enable = "" # possibly hook this up to a qt variant in future + if 'REZ_QT_ROOT' in os.environ: + qt_gui_enable = "--qt-gui" + + configure_env = "" + for name, value in CONFIGURE_ENV[build_config.build_variant_str].items(): + _str = ' "{var}={value}"'.format(var=name, value=value.format(config=build_config)) + configure_env += _str + + # configure_opts = CONFIGURE_OPTS[build_config.build_variant_str].format(config=build_config) + + stream.write(""" +cmake_minimum_required(VERSION 3.0) + +project(cmake CXX) + +include(ExternalProject) + +ExternalProject_Add( + {config.package_name} + URL {source_tarfile} + PREFIX {config.package_name} + SOURCE_DIR build + CONFIGURE_COMMAND env {configure_env} ./bootstrap --prefix={config.package_path} {qt_gui_enable} --parallel={cpus} --system-curl + BUILD_IN_SOURCE 1 + BUILD_COMMAND make -j{cpus} + INSTALL_DIR {config.package_path} +) +""".format( + config=build_config, + source_tarfile=source_tar, + configure_env=configure_env, + # configure_opts=configure_opts, + qt_gui_enable=qt_gui_enable, + cpus=multiprocessing.cpu_count(), + ) + ) + +def _lock_payload(build_config): + path = os.path.dirname(build_config.package_path) + subprocess.check_call(["/bin/chmod", "-R", "a-w", path]) + + +class BuildConfig(object): + def __init__(self): + self.source_path = os.environ["REZ_BUILD_SOURCE_PATH"] + self.build_path = os.environ["REZ_BUILD_PATH"] + self.package_path = os.environ["REZ_BUILD_INSTALL_PATH"] + self.package_name = os.environ["REZ_BUILD_PROJECT_NAME"] + self.package_version = os.environ["REZ_BUILD_PROJECT_VERSION"] + + @property + def is_installing(self): + return os.environ["REZ_BUILD_INSTALL"] == '1' + + @property + def is_releasing(self): + return os.environ["REZ_BUILD_TYPE"] in ["central"] + + @property + def build_variant_str(self): + desc = "{platform}_{arch}_{os}".format( + platform=os.environ["REZ_PLATFORM_VERSION"], + arch=os.environ["REZ_ARCH_VERSION"], + os=os.environ["REZ_OS_VERSION"], + ) + return desc + +if __name__ == "__main__": + build() diff --git a/recipes/cmake/package.py b/recipes/cmake/package.py new file mode 100644 index 0000000..033b405 --- /dev/null +++ b/recipes/cmake/package.py @@ -0,0 +1,96 @@ +# -*- coding: utf-8 -*- + +@early() +def name(): + import os + name = os.path.basename(os.path.dirname(os.getcwd())) + return name + +@early() +def version(): + import os + version = os.path.basename(os.getcwd()) + return version + +@early() +def uuid(): + import uuid + return str(uuid.uuid5(uuid.NAMESPACE_DNS, name())) + +description = \ + """ + Open-source and cross-platform family of tools designed to build, test, and package software. + """ + +vendor_name = "Kitware" + +vendor_type = "external" + +opensource = True + +source_author = vendor_name + +source_license = "BSD 3-clause" + +source_type = "c++" + +gpl_compatible = True + +has_plugins = False + +vendor_version = version() + +build_type = "python" + +package_author = "maxnbk" +build_author = "maxnbk" + +relocateable = False + +build_requires_source = True +build_requires_internet = False +build_requires_sudo = False + +@early() +def tools(): + major, minor = version().split('.')[:2] + return [ + "2to3", + "idle", + "pydoc", + "python", + "python{major}".format(major=major), + "python{major}.{minor}".format(major=major,minor=minor), + "python{major}.{minor}-config".format(major=major,minor=minor), + "python{major}-config".format(major=major), + "python-config", + "smtpd.py", + ] + +private_build_requires = [ + 'gcc-4+', + # 'cmake-3', + # build will rely on the system-level cmake installation because we're being meta for now + # 'python-2.7+<4', + # build will rely on the system-level python interpreter because python package itself will be built using cmake +] + +build_command = "python {root}/build.py {install}" +#build_command = "/bin/true" # temp while I work on the definition + +@early() +def variants(): + from rez.package_py_utils import expand_requires + requires = ["platform-linux", "arch-x86_64", "os-**"] + return [expand_requires(*requires)] + +def commands(): + env.PATH.prepend("{this.root}/bin") + +tests = { + "version_check": 'echo [[ \\"$(cmake --version | head -n 1)\\" -eq \\"cmake version {version}\\" ]]'.format(version=version()) +} + +with scope('config') as config: + config.release_packages_path = '${SW_EXTERNAL_RELEASE_ROOT}' + From f209fdf78c6875472b7c7a6affba008bbb873a74 Mon Sep 17 00:00:00 2001 From: Stephen Mackenzie Date: Mon, 21 Mar 2022 23:35:12 -0400 Subject: [PATCH 3/6] feat: add basic python recipe --- recipes/python/2.7.18/build.py | 1 + recipes/python/2.7.18/package.py | 1 + recipes/python/2.7.18/src | 1 + recipes/python/3.7.12/build.py | 1 + recipes/python/3.7.12/package.py | 1 + recipes/python/3.7.12/src | 1 + recipes/python/build.py | 130 +++++++++++++++++++++++++++++++ recipes/python/package.py | 104 +++++++++++++++++++++++++ 8 files changed, 240 insertions(+) create mode 120000 recipes/python/2.7.18/build.py create mode 120000 recipes/python/2.7.18/package.py create mode 120000 recipes/python/2.7.18/src create mode 120000 recipes/python/3.7.12/build.py create mode 120000 recipes/python/3.7.12/package.py create mode 120000 recipes/python/3.7.12/src create mode 100644 recipes/python/build.py create mode 100644 recipes/python/package.py diff --git a/recipes/python/2.7.18/build.py b/recipes/python/2.7.18/build.py new file mode 120000 index 0000000..3c76af7 --- /dev/null +++ b/recipes/python/2.7.18/build.py @@ -0,0 +1 @@ +../build.py \ No newline at end of file diff --git a/recipes/python/2.7.18/package.py b/recipes/python/2.7.18/package.py new file mode 120000 index 0000000..d04d114 --- /dev/null +++ b/recipes/python/2.7.18/package.py @@ -0,0 +1 @@ +../package.py \ No newline at end of file diff --git a/recipes/python/2.7.18/src b/recipes/python/2.7.18/src new file mode 120000 index 0000000..5cd551c --- /dev/null +++ b/recipes/python/2.7.18/src @@ -0,0 +1 @@ +../src \ No newline at end of file diff --git a/recipes/python/3.7.12/build.py b/recipes/python/3.7.12/build.py new file mode 120000 index 0000000..3c76af7 --- /dev/null +++ b/recipes/python/3.7.12/build.py @@ -0,0 +1 @@ +../build.py \ No newline at end of file diff --git a/recipes/python/3.7.12/package.py b/recipes/python/3.7.12/package.py new file mode 120000 index 0000000..d04d114 --- /dev/null +++ b/recipes/python/3.7.12/package.py @@ -0,0 +1 @@ +../package.py \ No newline at end of file diff --git a/recipes/python/3.7.12/src b/recipes/python/3.7.12/src new file mode 120000 index 0000000..5cd551c --- /dev/null +++ b/recipes/python/3.7.12/src @@ -0,0 +1 @@ +../src \ No newline at end of file diff --git a/recipes/python/build.py b/recipes/python/build.py new file mode 100644 index 0000000..7ee1485 --- /dev/null +++ b/recipes/python/build.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python + +import multiprocessing +import os +import re +import subprocess +import sys + +SOURCE_TAR = "src/Python-{version}.tgz" + +CONFIGURE_ENV = { + "linux_x86_64_rocky-8.5": { + "CFLAGS": "-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions " + "-fstack-protector-strong --param=ssp-buffer-size=4 " + "-grecord-gcc-switches -m64 -mtune=generic -D_GNU_SOURCE " + "-fPIC -fwrapv", + "LDFLAGS": "-Wl,-z,relro,-rpath={config.package_path}/lib" + } +} + +CONFIGURE_OPTS = { + "linux_x86_64_rocky-8.5": #"--build=x86_64-unknown-linux-gnu " + #"--host-x86_64-unknown-linux-gnu " + "--prefix={config.package_path} --enable-ipv6 " + "--enable-shared " + "--with-dbmliborder=gdbm:ndbm:bdb " + "--with-system-expat --with-system-ffi " + # "--enable-optimizations " + "--without-ensurepip " +} + +def build(): + build_config = BuildConfig() + + if not build_config.is_installing: + raise SystemExit("ERROR: This build must be run in a mode which would install or release it") + + source_tar = os.path.join(build_config.source_path, SOURCE_TAR.format(version=build_config.package_version)) + + _build_and_install_payload(build_config, source_tar) + _create_unversioned_python_symlink(build_config) + + if build_config.is_releasing: + _lock_payload(build_config) + +def _build_and_install_payload(config, source_tar): + cmake_file = os.path.join(config.build_path, "CMakeLists.txt") + with open(cmake_file, "w") as outstream: + _generate_cmakelists(config, source_tar, stream=outstream) + + subprocess.check_call(["cmake", "."], cwd=config.build_path) + subprocess.check_call(["make"], cwd=config.build_path) + +def _generate_cmakelists(build_config, source_tar, stream=sys.stdout): + """ + Args: + build_config (`BuildConfig`): Build configuration + source_tar (str): Path to source tarball + stream (file): Output file stream + """ + configure_env = "" + for name, value in CONFIGURE_ENV[build_config.build_variant_str].items(): + _str = ' "{var}={value}"'.format(var=name, value=value.format(config=build_config)) + configure_env += _str + + configure_opts = CONFIGURE_OPTS[build_config.build_variant_str].format(config=build_config) + + stream.write(""" +cmake_minimum_required(VERSION 3.0) + +project(python CXX) + +include(ExternalProject) + +ExternalProject_Add( + {config.package_name} + URL {source_tar} + PREFIX {config.package_name} + SOURCE_DIR build + CONFIGURE_COMMAND env {configure_env} ./configure {configure_opts} + BUILD_IN_SOURCE 1 + BUILD_COMMAND make -j{cpus} + INSTALL_DIR {config.package_path} +) +""".format( + config=build_config, + source_tar=source_tar, + configure_env=configure_env, + configure_opts=configure_opts, + cpus=multiprocessing.cpu_count(), + ) + ) + +def _create_unversioned_python_symlink(build_config): + python_link = os.path.join(build_config.package_path, "bin", "python") + if not os.path.lexists(python_link): + os.symlink("python{major}".format(major=self.package_version.split('.')[0]), python_link) + +def _lock_payload(build_config): + path = os.path.dirname(build_config.package_path) + subprocess.check_call(["/bin/chmod", "-R", "a-w", path]) + + +class BuildConfig(object): + def __init__(self): + self.source_path = os.environ["REZ_BUILD_SOURCE_PATH"] + self.build_path = os.environ["REZ_BUILD_PATH"] + self.package_path = os.environ["REZ_BUILD_INSTALL_PATH"] + self.package_name = os.environ["REZ_BUILD_PROJECT_NAME"] + self.package_version = os.environ["REZ_BUILD_PROJECT_VERSION"] + + @property + def is_installing(self): + return os.environ["REZ_BUILD_INSTALL"] == '1' + + @property + def is_releasing(self): + return os.environ["REZ_BUILD_TYPE"] in ["central"] + + @property + def build_variant_str(self): + desc = "{platform}_{arch}_{os}".format( + platform=os.environ["REZ_PLATFORM_VERSION"], + arch=os.environ["REZ_ARCH_VERSION"], + os=os.environ["REZ_OS_VERSION"], + ) + return desc + +if __name__ == "__main__": + build() diff --git a/recipes/python/package.py b/recipes/python/package.py new file mode 100644 index 0000000..da3296b --- /dev/null +++ b/recipes/python/package.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- + +@early() +def name(): + import os + name = os.path.basename(os.path.dirname(os.getcwd())) + return name + +@early() +def version(): + import os + version = os.path.basename(os.getcwd()) + return version + +@early() +def uuid(): + import uuid + return str(uuid.uuid5(uuid.NAMESPACE_DNS, name())) + +description = \ + """ + An interpreted, interactive, object-oriented programming language + """ + +vendor_name = "Python Software Foundation" + +vendor_type = "external" + +opensource = True + +source_author = vendor_name + +source_license = "PSF" + +source_type = "c++" + +gpl_compatible = True + +has_plugins = False + +vendor_version = version() + +build_type = "python" + +package_author = "maxnbk" +build_author = "maxnbk" + +relocateable = False + +build_requires_source = True +build_requires_internet = False +build_requires_sudo = False + +@early() +def tools(): + major, minor = version().split('.')[:2] + return [ + "2to3", + "idle", + "pydoc", + "python", + "python{major}".format(major=major), + "python{major}.{minor}".format(major=major,minor=minor), + "python{major}.{minor}-config".format(major=major,minor=minor), + "python{major}-config".format(major=major), + "python-config", + "smtpd.py", + ] + +private_build_requires = [ + 'cmake-3' + # build command requires a system-level python interpreter + # expat-devel is installed at system-level +] + +build_command = "python {root}/build.py {install}" +#build_command = "/bin/true" # temp while I work on the definition + +variants = [ + ['platform-linux', 'arch-x86_64', 'os-rocky-8.5'] +] + +@early() +def variants(): + from rez.package_py_utils import expand_requires + requires = ["platform-linux", "arch-x86_64", "os-**"] + return [expand_requires(*requires)] + +def pre_commands(): + env.PYTHONHOME.unset() + +def commands(): + env.PATH.prepend("{this.root}/bin") + +tests = { + "python_runs": 'echo [[ "$(python -c \'import os; import sys; print(\".\".join(str(x) for x in sys.version_info[:3]))\')" -eq "{version}" ]]'.format(version=version()) +} + +has_plugins = True +plugin_for = ['rez'] + +with scope('config') as config: + config.release_packages_path = '${SW_EXTERNAL_RELEASE_ROOT}' + From be6bcb556a706f5059ece6d03c767978ef20a36d Mon Sep 17 00:00:00 2001 From: Stephen Mackenzie Date: Mon, 21 Mar 2022 23:35:29 -0400 Subject: [PATCH 4/6] feat: add linux src download script --- download_linux_srcs.sh | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 download_linux_srcs.sh diff --git a/download_linux_srcs.sh b/download_linux_srcs.sh new file mode 100644 index 0000000..64a7205 --- /dev/null +++ b/download_linux_srcs.sh @@ -0,0 +1,9 @@ + +# This utility script may be useful later to act as a host arch triplet guesser +# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess + +# This whole setup should get parameterized later but let's just get started shall we? + +curl -O ./reciples/cmake/src/ https://github.com/Kitware/CMake/releases/download/v3.22.3/cmake-3.22.3.tar.gz +curl -O ./recipes/python/src/ https://www.python.org/ftp/python/2.7.18/Python-2.7.18.tgz +curl -O ./recipes/python/src/ https://www.python.org/ftp/python/3.7.12/Python-3.7.12.tgz From 5fe13e37851848a5c68d6c3546bd0ae8eba437da Mon Sep 17 00:00:00 2001 From: Stephen Mackenzie Date: Sat, 23 Apr 2022 15:42:48 -0400 Subject: [PATCH 5/6] fix: cmake+python with hashed_variants, no early bind name, no extra build command --- recipes/cmake/package.py | 11 ++++------- recipes/python/package.py | 13 +++---------- 2 files changed, 7 insertions(+), 17 deletions(-) diff --git a/recipes/cmake/package.py b/recipes/cmake/package.py index 033b405..08911fb 100644 --- a/recipes/cmake/package.py +++ b/recipes/cmake/package.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -@early() -def name(): - import os - name = os.path.basename(os.path.dirname(os.getcwd())) - return name +name = "cmake" @early() def version(): @@ -15,7 +11,7 @@ def version(): @early() def uuid(): import uuid - return str(uuid.uuid5(uuid.NAMESPACE_DNS, name())) + return str(uuid.uuid5(uuid.NAMESPACE_DNS, name)) description = \ """ @@ -76,7 +72,8 @@ def tools(): ] build_command = "python {root}/build.py {install}" -#build_command = "/bin/true" # temp while I work on the definition + +hashed_variants = True @early() def variants(): diff --git a/recipes/python/package.py b/recipes/python/package.py index da3296b..7efdd9d 100644 --- a/recipes/python/package.py +++ b/recipes/python/package.py @@ -1,10 +1,6 @@ # -*- coding: utf-8 -*- -@early() -def name(): - import os - name = os.path.basename(os.path.dirname(os.getcwd())) - return name +name = "python" @early() def version(): @@ -15,7 +11,7 @@ def version(): @early() def uuid(): import uuid - return str(uuid.uuid5(uuid.NAMESPACE_DNS, name())) + return str(uuid.uuid5(uuid.NAMESPACE_DNS, name)) description = \ """ @@ -74,11 +70,8 @@ def tools(): ] build_command = "python {root}/build.py {install}" -#build_command = "/bin/true" # temp while I work on the definition -variants = [ - ['platform-linux', 'arch-x86_64', 'os-rocky-8.5'] -] +hashed_variants = True @early() def variants(): From 2bb4f9702529764bc9f743b9aaf82b61613335ec Mon Sep 17 00:00:00 2001 From: Stephen Mackenzie Date: Sat, 23 Apr 2022 15:45:49 -0400 Subject: [PATCH 6/6] fix: cmake+python global BuildConfig --- recipes/cmake/build.py | 22 +++++++++++----------- recipes/python/build.py | 29 +++++++++++++++-------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/recipes/cmake/build.py b/recipes/cmake/build.py index 544daa3..937896a 100644 --- a/recipes/cmake/build.py +++ b/recipes/cmake/build.py @@ -32,30 +32,28 @@ def build(): - build_config = BuildConfig() if not build_config.is_installing: raise SystemExit("ERROR: This build must be run in a mode which would install or release it") source_tar = os.path.join(build_config.source_path, SOURCE_TAR.format(version=build_config.package_version)) - _build_and_install_payload(build_config, source_tar) + _build_and_install_payload(source_tar) if build_config.is_releasing: - _lock_payload(build_config) + _lock_payload() -def _build_and_install_payload(config, source_tar): - cmake_file = os.path.join(config.build_path, "CMakeLists.txt") +def _build_and_install_payload(source_tar): + cmake_file = os.path.join(build_config.build_path, "CMakeLists.txt") with open(cmake_file, "w") as outstream: - _generate_cmakelists(config, source_tar, stream=outstream) + _generate_cmakelists(source_tar, stream=outstream) - subprocess.check_call(["cmake", "."], cwd=config.build_path) - subprocess.check_call(["make"], cwd=config.build_path) + subprocess.check_call(["cmake", "."], cwd=build_config.build_path) + subprocess.check_call(["make"], cwd=build_config.build_path) -def _generate_cmakelists(build_config, source_tar, stream=sys.stdout): +def _generate_cmakelists(source_tar, stream=sys.stdout): """ Args: - build_config (`BuildConfig`): Build configuration source_tar (str): Path to source tarball stream (file): Output file stream """ @@ -97,7 +95,7 @@ def _generate_cmakelists(build_config, source_tar, stream=sys.stdout): ) ) -def _lock_payload(build_config): +def _lock_payload(): path = os.path.dirname(build_config.package_path) subprocess.check_call(["/bin/chmod", "-R", "a-w", path]) @@ -127,5 +125,7 @@ def build_variant_str(self): ) return desc +build_config = BuildConfig() + if __name__ == "__main__": build() diff --git a/recipes/python/build.py b/recipes/python/build.py index 7ee1485..6b74248 100644 --- a/recipes/python/build.py +++ b/recipes/python/build.py @@ -29,32 +29,30 @@ "--without-ensurepip " } -def build(): - build_config = BuildConfig() +def build(): if not build_config.is_installing: raise SystemExit("ERROR: This build must be run in a mode which would install or release it") source_tar = os.path.join(build_config.source_path, SOURCE_TAR.format(version=build_config.package_version)) - _build_and_install_payload(build_config, source_tar) - _create_unversioned_python_symlink(build_config) + _build_and_install_payload(source_tar) + _create_unversioned_python_symlink() if build_config.is_releasing: - _lock_payload(build_config) + _lock_payload() -def _build_and_install_payload(config, source_tar): - cmake_file = os.path.join(config.build_path, "CMakeLists.txt") +def _build_and_install_payload(source_tar): + cmake_file = os.path.join(build_config.build_path, "CMakeLists.txt") with open(cmake_file, "w") as outstream: - _generate_cmakelists(config, source_tar, stream=outstream) + _generate_cmakelists(source_tar, stream=outstream) - subprocess.check_call(["cmake", "."], cwd=config.build_path) - subprocess.check_call(["make"], cwd=config.build_path) + subprocess.check_call(["cmake", "."], cwd=build_config.build_path) + subprocess.check_call(["make"], cwd=build_config.build_path) -def _generate_cmakelists(build_config, source_tar, stream=sys.stdout): +def _generate_cmakelists(source_tar, stream=sys.stdout): """ Args: - build_config (`BuildConfig`): Build configuration source_tar (str): Path to source tarball stream (file): Output file stream """ @@ -91,12 +89,12 @@ def _generate_cmakelists(build_config, source_tar, stream=sys.stdout): ) ) -def _create_unversioned_python_symlink(build_config): +def _create_unversioned_python_symlink(): python_link = os.path.join(build_config.package_path, "bin", "python") if not os.path.lexists(python_link): os.symlink("python{major}".format(major=self.package_version.split('.')[0]), python_link) -def _lock_payload(build_config): +def _lock_payload(): path = os.path.dirname(build_config.package_path) subprocess.check_call(["/bin/chmod", "-R", "a-w", path]) @@ -126,5 +124,8 @@ def build_variant_str(self): ) return desc +build_config = BuildConfig() + if __name__ == "__main__": build() +