diff --git a/build_tdfaust.py b/build_tdfaust.py index e8ba63c..e3fa318 100644 --- a/build_tdfaust.py +++ b/build_tdfaust.py @@ -2,6 +2,7 @@ import os import platform import subprocess +import shlex def run_command(command, shell=False): @@ -66,7 +67,8 @@ def build_macos(pythonver: str, touchdesigner_app: str, arch: str=None): run_command(["cmake", "--build", "build", "--config", "Release"]) os.system('mv build/Release/TD-Faust.plugin Plugins') if 'CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM' in os.environ: - os.system(f'codesign --force --verify --verbose=2 --timestamp --options=runtime --deep --sign "Developer ID Application: David Braun ($CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)" build/Release/TD-Faust.plugin') + CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM = os.environ['CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM'] + subprocess.call(shlex.split(f'codesign --force --verify --verbose=2 --timestamp --options=runtime --deep --sign "Developer ID Application: David Braun ({CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM})" build/Release/TD-Faust.plugin')) if __name__ == "__main__": parser = argparse.ArgumentParser(description="Build TD-Faust plugin for Windows or macOS.") diff --git a/faust2td.py b/faust2td.py index 18e23f8..1c5b787 100644 --- a/faust2td.py +++ b/faust2td.py @@ -299,7 +299,7 @@ def add_toggle(item) -> str: assert isdir(libfaust_dir), "Have you run `sh download_libfaust.sh`?" # execute CMake and build - build_dir = 'build_faust2touchdesigner' + build_dir = f'build_{op_type}' generator = " -G Xcode " if platform.system() == 'Darwin' else '' subprocess.call(shlex.split(f'cmake faust2touchdesigner -B{build_dir} {generator} -DOP_TYPE={op_type} -DAUTHOR_NAME="{author_name}" -DLIBFAUST_DIR="{libfaust_dir}" {cmake_osx_deployment_target} {cmake_build_arch}')) subprocess.call(shlex.split(f'cmake --build {build_dir} --config Release')) @@ -308,7 +308,8 @@ def add_toggle(item) -> str: file_dest = f'"{build_dir}/Release/{op_type}.plugin"' subprocess.call(shlex.split(f'cp -r {file_dest} Plugins')) if 'CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM' in os.environ: - os.system(f'codesign --force --verify --verbose=2 --timestamp --options=runtime --deep --sign "Developer ID Application: David Braun ($CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM)" {file_dest}') + CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM = os.environ['CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM'] + subprocess.call(shlex.split(f'codesign --force --verify --verbose=2 --timestamp --options=runtime --deep --sign "Developer ID Application: David Braun ({CMAKE_XCODE_ATTRIBUTE_DEVELOPMENT_TEAM})" {file_dest}')) print('All done!') diff --git a/install_script/install_certifi.py b/install_script/install_certifi.py deleted file mode 100644 index 89bf82f..0000000 --- a/install_script/install_certifi.py +++ /dev/null @@ -1,55 +0,0 @@ -# Based on: https://github.com/python/cpython/blob/master/Mac/BuildScript/resources/install_certificates.command - -# install_certifi.py -# -# sample script to install or update a set of default Root Certificates -# for the ssl module. Uses the certificates provided by the certifi package: -# https://pypi.org/project/certifi/ - -import os -import os.path -import ssl -import stat -import subprocess -import sys - -STAT_0o775 = ( - stat.S_IRUSR - | stat.S_IWUSR - | stat.S_IXUSR - | stat.S_IRGRP - | stat.S_IWGRP - | stat.S_IXGRP - | stat.S_IROTH - | stat.S_IXOTH -) - - -def main(): - openssl_dir, openssl_cafile = os.path.split(ssl.get_default_verify_paths().openssl_cafile) - print(" -- pip install --upgrade certifi") - subprocess.check_call( - [sys.executable, "-E", "-s", "-m", "pip", "install", "--upgrade", "certifi"] - ) - - import certifi - - # change working directory to the default SSL directory - os.chdir(openssl_dir) - relpath_to_certifi_cafile = os.path.relpath(certifi.where()) - - print(" -- removing any existing file or link") - try: - os.remove(openssl_cafile) - except FileNotFoundError: - pass - print(" -- creating symlink to certifi certificate bundle") - os.symlink(relpath_to_certifi_cafile, openssl_cafile) - - print(" -- setting permissions") - os.chmod(openssl_cafile, STAT_0o775) - print(" -- update complete") - - -if __name__ == "__main__": - main() diff --git a/install_script/macos_install_python.py b/install_script/macos_install_python.py deleted file mode 100644 index b187e13..0000000 --- a/install_script/macos_install_python.py +++ /dev/null @@ -1,130 +0,0 @@ -# This project is licensed under the 'BSD 2-clause license'. - -# Copyright (c) 2017-2019, Joe Rickerby and contributors. All rights reserved. - -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: - -# 1. Redistributions of source code must retain the above copyright notice, this -# list of conditions and the following disclaimer. - -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. - -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER -# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - - -from pathlib import Path -import os -import ssl -import urllib.request -import subprocess -import certifi -import shlex -import shutil - -from typing import Union, Optional - - -install_certifi_script = Path(__file__).parent / "install_certifi.py" - -def download(url: str, dest: Path) -> None: - print(f"+ Download {url} to {dest}") - dest_dir = dest.parent - if not dest_dir.exists(): - dest_dir.mkdir(parents=True) - - # we've had issues when relying on the host OS' CA certificates on Windows, - # so we use certifi (this sounds odd but requests also does this by default) - cafile = os.environ.get("SSL_CERT_FILE", certifi.where()) - context = ssl.create_default_context(cafile=cafile) - repeat_num = 3 - for i in range(repeat_num): - try: - response = urllib.request.urlopen(url, context=context) - except Exception: - if i == repeat_num - 1: - raise - sleep(3) - continue - break - - try: - dest.write_bytes(response.read()) - finally: - response.close() - - -PathOrStr = Union[str, "os.PathLike[str]"] - - -def call( - *args: PathOrStr, -) -> Optional[str]: - """ - Run subprocess.run, but print the commands first. Takes the commands as - *args. Uses shell=True on Windows due to a bug. Also converts to - Paths to strings, due to Windows behavior at least on older Pythons. - https://bugs.python.org/issue8557 - """ - args_ = [str(arg) for arg in args] - # print the command executing for the logs - print("+ " + " ".join(shlex.quote(a) for a in args_)) - result = subprocess.run(args_, check=True, shell=False, env=None, cwd=None) - return None - - -SYMLINKS_DIR = Path("/tmp/cibw_bin") - - -def make_symlinks(installation_bin_path: Path, python_executable: str, pip_executable: str) -> None: - assert (installation_bin_path / python_executable).exists() - - # Python bin folders on Mac don't symlink `python3` to `python`, and neither - # does PyPy for `pypy` or `pypy3`, so we do that so `python` and `pip` always - # point to the active configuration. - if SYMLINKS_DIR.exists(): - shutil.rmtree(SYMLINKS_DIR) - SYMLINKS_DIR.mkdir(parents=True) - - (SYMLINKS_DIR / "python").symlink_to(installation_bin_path / python_executable) - (SYMLINKS_DIR / "python-config").symlink_to( - installation_bin_path / (python_executable + "-config") - ) - (SYMLINKS_DIR / "pip").symlink_to(installation_bin_path / pip_executable) - - -def install_cpython(tmp: Path, version: str, url: str) -> Path: - installation_path = Path(f"/Library/Frameworks/Python.framework/Versions/{version}") - pkg_path = tmp / "Python.pkg" - # download the pkg - download(url, pkg_path) - # install - call("sudo", "installer", "-pkg", pkg_path, "-target", "/") - pkg_path.unlink() - call(installation_path / "bin" / "python3", install_certifi_script) - - return installation_path / "bin" / "python3" - - -def main(): - - tmp = Path("/tmp/cibw_tmp") - version = "3.11" - url = "https://www.python.org/ftp/python/3.11.9/python-3.11.9-macos11.pkg" - - base_python = install_cpython(tmp, version, url) - assert base_python.exists() - -if __name__ == '__main__': - main()