diff --git a/tools/build_launchers.py b/tools/build_launchers.py deleted file mode 100644 index 48609367a0..0000000000 --- a/tools/build_launchers.py +++ /dev/null @@ -1,156 +0,0 @@ -""" -Build executable launchers for Windows. - -Build module requires installation of -`CMake `_ and Visual Studio. - -Please ensure that buildtools v143 or later are installed for Visual -Studio. Ensure that you install ARM build tools. - -From Visual Studio Installer: -Visual Studio -> Modify -> Individual Components - -List of components needed to install to compile on ARM: -- C++ Universal Windows Platform Support for v143 build Tools (ARM64) -- MSVC v143 - VS 2022 C++ ARM64 build tools (latest) -- MSVC v143 - VS 2022 C++ ARM64 Spectre-mitigated libs (latest) -- C++ ATL for latest v143 build tools (ARM64) -""" - -import functools -import itertools -import os -import pathlib -import shutil -import subprocess -import tempfile - -BUILD_TARGETS = ["cli", "gui"] -GUI = {"cli": 0, "gui": 1} -BUILD_PLATFORMS = ["Win32", "x64", "arm64"] -REPO_ROOT = pathlib.Path(__file__).parent.parent.resolve() -LAUNCHER_CMAKE_PROJECT = REPO_ROOT / "launcher" -MSBUILD_OUT_DIR = REPO_ROOT / "setuptools" -VISUAL_STUDIO_VERSION = "Visual Studio 17 2022" -""" -Version of Visual Studio that is currently installed on the machine. -Not tested with the older visual studios less then 16 version. -Generators -* Visual Studio 17 2022 = Generates Visual Studio 2022 project files. - Use -A option to specify architecture. - Visual Studio 16 2019 = Generates Visual Studio 2019 project files. - Use -A option to specify architecture. - Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files. - Optional [arch] can be "Win64" or "ARM". - Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files. - Optional [arch] can be "Win64" or "ARM". - Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files. - Optional [arch] can be "Win64" or "ARM". - Visual Studio 11 2012 [arch] = Deprecated. Generates Visual Studio 2012 - project files. Optional [arch] can be - "Win64" or "ARM". - Visual Studio 9 2008 [arch] = Generates Visual Studio 2008 project files. - Optional [arch] can be "Win64" or "IA64". -""" - - -def resolve_platform(platform: str) -> str: - if platform in ["Win32", "x64"]: - return platform[-2:] - return platform - - -def get_executable_name(name, platform: str) -> str: - return f"{name}-{resolve_platform(platform)}" - - -def generate_cmake_project(build_arena, cmake_project_path, platform, is_gui): - cmd = [ - get_cmake(), - '-G', - VISUAL_STUDIO_VERSION, - '-A', - platform, - cmake_project_path, - f'-DGUI={is_gui}', - ] - subprocess.check_call(cmd, cwd=build_arena) - - -def build_cmake_project_with_msbuild(build_arena, msbuild_parameters): - cmd = [ - get_msbuild(), - 'launcher.vcxproj', - ] + msbuild_parameters - subprocess.check_call(cmd, cwd=build_arena) - - -@functools.lru_cache -def get_cmake(): - """Find CMake using registry.""" - import winreg - - with winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Kitware\CMake") as key: - root = pathlib.Path(winreg.QueryValueEx(key, "InstallDir")[0]) - return root / 'bin\\CMake.exe' - - -@functools.lru_cache -def get_msbuild(): - """Use VSWhere to find MSBuild.""" - vswhere = pathlib.Path( - os.environ['ProgramFiles(x86)'], - 'Microsoft Visual Studio', - 'Installer', - 'vswhere.exe', - ) - cmd = [ - vswhere, - '-latest', - '-prerelease', - '-products', - '*', - '-requires', - 'Microsoft.Component.MSBuild', - '-find', - r'MSBuild\**\Bin\MSBuild.exe', - ] - try: - return subprocess.check_output(cmd, encoding='utf-8', text=True).strip() - except subprocess.CalledProcessError as e: - raise SystemExit("Unable to find MSBuild; check Visual Studio install") from e - - -def do_build(arena, platform, target): - print(f"Building {target} for {platform}") - - generate_cmake_project(arena, LAUNCHER_CMAKE_PROJECT, platform, GUI[target]) - - build_params = [ - '/t:build', - '/property:Configuration=Release', - f'/property:Platform={platform}', - f'/p:OutDir={MSBUILD_OUT_DIR.resolve()}', - f'/p:TargetName={get_executable_name(target, platform)}', - ] - build_cmake_project_with_msbuild(arena, build_params) - - -def main(): - # check for executables early - get_cmake() - get_msbuild() - - for platform, target in itertools.product(BUILD_PLATFORMS, BUILD_TARGETS): - with tempfile.TemporaryDirectory(dir=REPO_ROOT) as arena: - do_build(arena, platform, target) - - # copy win32 as default executables - for target in BUILD_TARGETS: - executable = MSBUILD_OUT_DIR / f"{get_executable_name(target, 'Win32')}.exe" - destination_executable = MSBUILD_OUT_DIR / f"{target}.exe" - shutil.copy(executable, destination_executable) - - -if __name__ == "__main__": - main() diff --git a/tools/finalize.py b/tools/finalize.py deleted file mode 100644 index 27471c7e25..0000000000 --- a/tools/finalize.py +++ /dev/null @@ -1,62 +0,0 @@ -""" -Finalize the repo for a release. Invokes towncrier and bumpversion. -""" - -__requires__ = ['bump2version', 'towncrier', 'jaraco.develop>=7.21'] - - -import pathlib -import re -import subprocess -import sys - -from jaraco.develop import towncrier - -bump_version_command = [ - sys.executable, - '-m', - 'bumpversion', - towncrier.release_kind(), -] - - -def get_version(): - cmd = bump_version_command + ['--dry-run', '--verbose'] - out = subprocess.check_output(cmd, text=True, encoding='utf-8') - return re.search('^new_version=(.*)', out, re.MULTILINE).group(1) - - -def update_changelog(): - towncrier.run('build', '--yes') - _repair_changelog() - - -def _repair_changelog(): - """ - Workaround for #2666 - """ - changelog_fn = pathlib.Path('NEWS.rst') - changelog = changelog_fn.read_text(encoding='utf-8') - fixed = re.sub(r'^(v[0-9.]+)v[0-9.]+$', r'\1', changelog, flags=re.MULTILINE) - changelog_fn.write_text(fixed, encoding='utf-8') - subprocess.check_output(['git', 'add', changelog_fn]) - - -def bump_version(): - cmd = bump_version_command + ['--allow-dirty'] - subprocess.check_call(cmd) - - -def ensure_config(): - """ - Double-check that Git has an e-mail configured. - """ - subprocess.check_output(['git', 'config', 'user.email']) - - -if __name__ == '__main__': - print("Cutting release at", get_version()) - ensure_config() - towncrier.check_changes() - update_changelog() - bump_version() diff --git a/tools/generate_validation_code.py b/tools/generate_validation_code.py deleted file mode 100644 index 157693de65..0000000000 --- a/tools/generate_validation_code.py +++ /dev/null @@ -1,39 +0,0 @@ -from __future__ import annotations - -import itertools -import subprocess -import sys -from collections.abc import Iterable -from pathlib import Path - - -def generate_pyproject_validation(dest: Path, schemas: Iterable[Path]) -> bool: - """ - Generates validation code for ``pyproject.toml`` based on JSON schemas and the - ``validate-pyproject`` library. - """ - schema_args = (("-t", f"{f.name.partition('.')[0]}={f}") for f in schemas) - cmd = [ - sys.executable, - "-m", - "validate_pyproject.pre_compile", - f"--output-dir={dest}", - "--enable-plugins", - "setuptools", - "distutils", - "--very-verbose", - *itertools.chain.from_iterable(schema_args), - ] - subprocess.check_call(cmd) - print(f"Validation code generated at: {dest}") - return True - - -def main() -> bool: - return generate_pyproject_validation( - Path("setuptools/config/_validate_pyproject"), - schemas=Path("setuptools/config").glob("*.schema.json"), - ) - - -__name__ == '__main__' and main() diff --git a/tools/vendored.py b/tools/vendored.py deleted file mode 100644 index 2525d5fdce..0000000000 --- a/tools/vendored.py +++ /dev/null @@ -1,75 +0,0 @@ -import functools -import re -import subprocess - -import jaraco.packaging.metadata -from path import Path - - -def remove_all(paths): - for path in paths: - path.rmtree() if path.is_dir() else path.remove() - - -def update_vendored(): - update_setuptools() - - -def clean(vendor): - """ - Remove all files out of the vendor directory except the meta - data (as pip uninstall doesn't support -t). - """ - ignored = ['ruff.toml'] - remove_all(path for path in vendor.glob('*') if path.basename() not in ignored) - - -@functools.lru_cache -def metadata(): - return jaraco.packaging.metadata.load('.') - - -def upgrade_core(dep): - """ - Remove 'extra == "core"' from any dependency. - """ - return re.sub('''(;| and) extra == ['"]core['"]''', '', dep) - - -def load_deps(): - """ - Read the dependencies from `.[core]`. - """ - return list(map(upgrade_core, metadata().get_all('Requires-Dist'))) - - -def min_python(): - return metadata()['Requires-Python'].removeprefix('>=').strip() - - -def install_deps(deps, vendor): - """ - Install the deps to vendor. - """ - install_args = [ - 'uv', - 'pip', - 'install', - '--target', - str(vendor), - '--python-version', - min_python(), - '--only-binary', - ':all:', - ] + list(deps) - subprocess.check_call(install_args) - - -def update_setuptools(): - vendor = Path('setuptools/_vendor') - deps = load_deps() - clean(vendor) - install_deps(deps, vendor) - - -__name__ == '__main__' and update_vendored()