From 373a1d94a8744ab34c4d641a62c961bbcbd49091 Mon Sep 17 00:00:00 2001 From: WildCard65 Date: Wed, 15 Jul 2020 13:54:51 -0400 Subject: [PATCH] Switched from using 'distutils' to 'setuptools' for installing AMBuild. Fixes #68: See [bpo-41282](https://bugs.python.org/issue41282) for switch reason. --- ambuild2/run.py | 20 +++++++++++++++++++ scripts/ambuild | 28 -------------------------- scripts/ambuild.bat | 15 -------------- setup.py | 48 +++++++++++++++------------------------------ 4 files changed, 36 insertions(+), 75 deletions(-) delete mode 100644 scripts/ambuild delete mode 100644 scripts/ambuild.bat diff --git a/ambuild2/run.py b/ambuild2/run.py index 5d1b3b16..ef8b054f 100644 --- a/ambuild2/run.py +++ b/ambuild2/run.py @@ -132,3 +132,23 @@ def BuildParser(sourcePath, api, buildPath=None): Preparer = PreparerForAPI(api) return Preparer(sourcePath=sourcePath, buildPath=buildPath) + + +def cli_run(): + options, argv = BuildOptions() + + if not len(argv): + folder = '.' + else: + folder = argv[0] + if not os.path.exists(folder): + sys.stderr.write('Error: path does not exist: {0}\n'.format(folder)) + sys.exit(1) + + cache_path = os.path.join(folder, '.ambuild2', 'graph') + if not os.path.exists(cache_path): + sys.stderr.write('Error: folder was not configured for AMBuild.\n') + sys.exit(1) + + if not Build(os.path.abspath(folder), options, argv): + sys.exit(1) diff --git a/scripts/ambuild b/scripts/ambuild deleted file mode 100644 index 1ec70b04..00000000 --- a/scripts/ambuild +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# vim: set sts=2 ts=8 sw=2 tw=99 et: -import os, sys -from ambuild2 import run -from optparse import OptionParser - -def main(): - options, argv = run.BuildOptions() - - if not len(argv): - folder = '.' - else: - folder = argv[0] - if not os.path.exists(folder): - sys.stderr.write('Error: path does not exist: {0}\n'.format(folder)) - sys.exit(1) - - cache_path = os.path.join(folder, '.ambuild2', 'graph') - if not os.path.exists(cache_path): - sys.stderr.write('Error: folder was not configured for AMBuild.\n') - sys.exit(1) - - if not run.Build(os.path.abspath(folder), options, argv): - sys.exit(1) - -if __name__ == '__main__': - main() - diff --git a/scripts/ambuild.bat b/scripts/ambuild.bat deleted file mode 100644 index fdc7dcab..00000000 --- a/scripts/ambuild.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off - -REM WTFFFFFFFFFFF Python doesn't add itself to PATH! - -setlocal - -IF EXIST "%~dp0..\python.exe" ( - set PYTHON_EXE="%~dp0..\python" -) ELSE ( - set PYTHON_EXE=python -) - -%PYTHON_EXE% "%~dp0ambuild" %* - -exit /b %ERRORLEVEL% diff --git a/setup.py b/setup.py index b9eca396..5fd30aac 100755 --- a/setup.py +++ b/setup.py @@ -1,23 +1,19 @@ #!/usr/bin/env python # vim: set ts=2 sw=2 tw=99 et: import sys -from distutils.core import setup +from setuptools import setup, find_packages try: import sqlite3 except: - raise Exception('py-sqlite3 must be installed') - -scripts = [ - 'scripts/ambuild' -] - -if sys.platform == 'win32': - scripts.append('scripts/ambuild.bat') -elif sys.platform == 'darwin': - scripts.append('scripts/ambuild_dsymutil_wrapper.sh') -else: - scripts.append('scripts/ambuild_objcopy_wrapper.sh') + raise SystemError('py-sqlite3 must be installed') + +amb_scripts = [] +if sys.platform != 'win32': + if sys.platform == 'darwin': + amb_scripts.append('scripts/ambuild_dsymutil_wrapper.sh') + else: + amb_scripts.append('scripts/ambuild_objcopy_wrapper.sh') setup( name = 'AMBuild', @@ -26,23 +22,11 @@ author = 'David Anderson', author_email = 'dvander@alliedmods.net', url = 'http://www.alliedmods.net/ambuild', - packages = [ - 'ambuild', - 'ambuild2', - 'ambuild2.frontend', - 'ambuild2.ipc', - 'ambuild2.frontend.v2_0', - 'ambuild2.frontend.v2_0.amb2', - 'ambuild2.frontend.v2_0.base', - 'ambuild2.frontend.v2_0.cpp', - 'ambuild2.frontend.v2_0.vs', - 'ambuild2.frontend.v2_1', - 'ambuild2.frontend.v2_1.amb2', - 'ambuild2.frontend.v2_1.base', - 'ambuild2.frontend.v2_1.cpp', - 'ambuild2.frontend.v2_1.vs', - 'ambuild2.frontend.v2_1.tools', - ], - scripts = scripts + packages = find_packages(), + entry_points = { + 'console_scripts': [ + 'ambuild = ambuild2.run:cli_run' + ] + }, + scripts=amb_scripts ) -