From 2aade9b54cbcbc017763f366616d9f09837d71fb Mon Sep 17 00:00:00 2001 From: Joachim Folz Date: Tue, 3 Sep 2024 16:00:51 +0200 Subject: [PATCH] cleanup MSVC mess... --- CHANGELOG | 5 ++++ setup.py | 53 ++++-------------------------------------- simplejpeg/__init__.py | 2 +- 3 files changed, 10 insertions(+), 50 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9b8e597..9507267 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -5,6 +5,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [1.7.6] - 2024-09-03 +### Changed +- Drop win32 support. + + ## [1.7.5] - 2024-08-28 ### Added - Add Python 3.13 support. diff --git a/setup.py b/setup.py index cad8994..68adda3 100644 --- a/setup.py +++ b/setup.py @@ -32,44 +32,13 @@ def __repr__(self): __fspath__ = __repr__ -WINDOWS_ARCH_MAP_32bit = { - 'x86': 'x86', - 'x86_64': 'x86', - 'x64': 'x86', - 'amd64': 'x86', - 'AMD64': 'x86', -} - - -WINDOWS_ARCH_MAP_64bit = { - 'x86_64': 'AMD64', - 'x64': 'AMD64', - 'amd64': 'AMD64', - 'AMD64': 'AMD64', -} - - -def determine_arch(): - machine = platform.machine() - try: - if OS == "windows": - if IS64BIT: - return WINDOWS_ARCH_MAP_64bit[machine] - else: - return WINDOWS_ARCH_MAP_32bit[machine] - else: - return platform.machine() - except KeyError: - raise RuntimeError(f'unsupported OS and machine combination: {OS}, {machine}') - - PACKAGE_DIR = pt.abspath(pt.dirname(__file__)) OS = platform.system().lower() NPY_API_VERSION = 'NPY_1_19_API_VERSION' # build output dir is machine-specific BUILD_DIR = 'build_' + '_'.join(platform.architecture()) IS64BIT = sys.maxsize > 2**32 -ARCH = determine_arch() +ARCH = platform.machine() if OS == 'darwin': # From pybind cmake example: # https://github.com/pybind/cmake_example/blob/0e3d4496b4eb1ca904c2f2f5278c5f375f035097/setup.py#L100 @@ -121,15 +90,6 @@ def make_type(): raise RuntimeError('Platform not supported: %s, %s' % (OS, ARCH)) -def update_env_msvc(): - from setuptools.msvc import EnvironmentInfo - print(f'Setting up environment for MSVC on {ARCH}') - env = EnvironmentInfo(ARCH).return_env() - for key, value in env.items(): - print(f"{key}={value}") - os.environ[key.upper()] = value - - def touch(path): with open(path, 'w') as f: pass @@ -151,9 +111,6 @@ def build_cmake_dependencies(self): if OS == 'darwin': if ARCHFLAGS: flags.append("-DCMAKE_OSX_ARCHITECTURES=" + ";".join(ARCHFLAGS)) - if OS == 'windows': - #update_env_msvc() - pass self.build_cmake_dependency(YASM_DIR, [ '-DBUILD_SHARED_LIBS=OFF' ]) @@ -161,10 +118,9 @@ def build_cmake_dependencies(self): cflags = os.getenv('CFLAGS', '') ldflags = os.getenv('LDFLAGS', '') if OS == 'linux': - # make GCC put functions and data in separate sections - # the linker can then remove unused sections to reduce the size of the binary - #cflags = '-flto -ffunction-sections -fdata-sections ' + cflags + # enable LTO cflags = '-flto ' + cflags + # same as extension ldflags = ( '-flto ' '-Wl,' # following are linker options @@ -190,7 +146,6 @@ def build_cmake_dependencies(self): def build_cmake_dependency(self, path, options, env=None): cur_dir = pt.abspath(os.curdir) - # TODO make build dir depend on arch build_dir = pt.join(path, BUILD_DIR) if not pt.exists(build_dir): os.makedirs(build_dir) @@ -254,7 +209,7 @@ def make_jpeg_module(): '--gc-sections' # Remove unused sections ]) extra_compile_args.extend([ - '-flto', + '-flto', # enable LTO ]) return Extension( 'simplejpeg._jpeg', diff --git a/simplejpeg/__init__.py b/simplejpeg/__init__.py index c959a1a..7bebed4 100644 --- a/simplejpeg/__init__.py +++ b/simplejpeg/__init__.py @@ -3,7 +3,7 @@ from ._jpeg import decode_jpeg_header -__version__ = '1.7.5' +__version__ = '1.7.6' __version_info__ = __version__.split('.')