From 199589bf053897949f7f858604faf89f40b82f40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:24:45 +0000 Subject: [PATCH 01/16] Generate sdist with multiple python versions --- .github/workflows/ci-build.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 6a969760f..95dd0cb3a 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -45,7 +45,11 @@ jobs: outputs: VERSION: ${{ steps.generate.outputs.version }} - + strategy: + matrix: + python-version: + - 3.10 + - 3.12 steps: - name: Checkout repo uses: actions/checkout@v4 @@ -53,10 +57,10 @@ jobs: submodules: 'recursive' fetch-depth: 0 - - name: Set up Python 3.10 + - name: Set up Python uses: actions/setup-python@v5 with: - python-version: '3.10' + python-version: ${{ matrix.python-version }} cache: 'pip' - name: Install dependencies @@ -78,7 +82,7 @@ jobs: - name: Save sdist as job artifact uses: actions/upload-artifact@v4 with: - name: wxPython-source + name: wxPython-source-${{ matrix.python-version }} path: dist/wxPython-${{ steps.generate.outputs.version }}.tar.gz - name: Create demo source distribution (sdist_demo) @@ -104,6 +108,7 @@ jobs: strategy: fail-fast: false matrix: + sdist-python-version: ['3.10'] os: [ ubuntu-22.04, windows-2022, macos-13 ] python-version: [ '3.9', '3.10', '3.11', '3.12', '3.13' ] architecture: [ 'x86', 'x64' ] @@ -152,7 +157,7 @@ jobs: - name: download CI source artifact uses: actions/download-artifact@v4 with: - name: wxPython-source + name: wxPython-source-${{ matrix.sdist-python-version }} path: dist - name: Set up Python ${{ matrix.python-version }}-${{ matrix.architecture }} From 9b711f9a7c0a16279003b93d994bb4fd625bb588 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:25:55 +0000 Subject: [PATCH 02/16] Python versions as strings --- .github/workflows/ci-build.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 95dd0cb3a..94d429349 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -48,8 +48,8 @@ jobs: strategy: matrix: python-version: - - 3.10 - - 3.12 + - '3.10' + - '3.12' steps: - name: Checkout repo uses: actions/checkout@v4 From 7dfe3ae5eb1b34314b9074b0c417928ea1ac6fd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 16:54:07 +0000 Subject: [PATCH 03/16] Replace usage of distutils.dir_util.mkpath function --- buildtools/config.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/buildtools/config.py b/buildtools/config.py index 5bee90cd4..626580b9b 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -15,6 +15,7 @@ import os import glob import fnmatch +import logging import shlex import re import shutil @@ -22,7 +23,9 @@ import platform from distutils.file_util import copy_file -from distutils.dir_util import mkpath +from pathlib import Path +from typing import Union + try: from setuptools.modified import newer except ImportError: @@ -32,6 +35,15 @@ runSilently = False +log = logging.getLogger() + +def mkpath(name: Union[Path, str], mode=0o777, verbose: Union[bool, int] = False): + """Replacement for distutils.dir_util.mkpath function, with verbose support""" + path = Path(name) + if verbose and not path.is_dir(): + log.info("creating %s", path) + Path(path).mkdir(mode=mode, parents=True, exist_ok=True) + #---------------------------------------------------------------------- class Configuration(object): @@ -1069,7 +1081,6 @@ def getToolsPlatformName(useLinuxBits=False): def updateLicenseFiles(cfg): from distutils.file_util import copy_file - from distutils.dir_util import mkpath # Copy the license files from wxWidgets mkpath('license') From 4d805a0a224668ab777b18f95ed3e59d23a89507 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 17:00:19 +0000 Subject: [PATCH 04/16] Replace "from distutils import log" with logging.getLogger() --- buildtools/distutils_hacks.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/buildtools/distutils_hacks.py b/buildtools/distutils_hacks.py index eafd59837..495d7f08f 100644 --- a/buildtools/distutils_hacks.py +++ b/buildtools/distutils_hacks.py @@ -10,6 +10,7 @@ # License: wxWindows License #---------------------------------------------------------------------- +import logging import sys import os @@ -23,7 +24,7 @@ except ImportError: from distutils.dep_util import newer, newer_group -from distutils import log +log = logging.getLogger() from .config import Config, posixjoin, loadETG, etg2sip From ccf4431a91858e288e00535d02aaae24ddf9d6c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 17:02:55 +0000 Subject: [PATCH 05/16] Test building sdist with older and newer python versions, including python 3.14 --- .github/workflows/ci-build.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 94d429349..b98e985d1 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -46,10 +46,13 @@ jobs: outputs: VERSION: ${{ steps.generate.outputs.version }} strategy: - matrix: - python-version: - - '3.10' - - '3.12' + matrix: + python-version: + - '3.9' + - '3.10' + - '3.12' + - '3.13' + - '3.14' steps: - name: Checkout repo uses: actions/checkout@v4 @@ -62,6 +65,7 @@ jobs: with: python-version: ${{ matrix.python-version }} cache: 'pip' + allow-prereleases: true - name: Install dependencies run: | From b77b2437998a593b2d1a525d59e483d6246f7f3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:17:27 +0000 Subject: [PATCH 06/16] Do not install any dependency on gitpod --- .gitpod.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .gitpod.yml diff --git a/.gitpod.yml b/.gitpod.yml new file mode 100644 index 000000000..c1e6dee81 --- /dev/null +++ b/.gitpod.yml @@ -0,0 +1,10 @@ +# This configuration file was automatically generated by Gitpod. +# Please adjust to your needs (see https://www.gitpod.io/docs/introduction/learn-gitpod/gitpod-yaml) +# and commit this file to your remote git repository to share the goodness with others. + +# Learn more from ready-to-use templates: https://www.gitpod.io/docs/introduction/getting-started/quickstart + +tasks: + - init: echo "nothing done" + + From 55d3d85869705df9b7de23d1c0ac92e0c5cf146d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 19:28:01 +0000 Subject: [PATCH 07/16] Unpin documentation packages --- requirements/devel.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/requirements/devel.txt b/requirements/devel.txt index ea5b520f9..ff3f1a491 100644 --- a/requirements/devel.txt +++ b/requirements/devel.txt @@ -14,18 +14,18 @@ pytest-xdist pytest-forked pytest-timeout -sphinx==2.2.0 ; python_version >= '3.0' +sphinx ; python_version >= '3.0' sphinx==1.8.5 ; python_version < '3.0' -alabaster<0.7.14 -sphinxcontrib-applehelp<1.0.8 -sphinxcontrib-devhelp<1.0.6 -sphinxcontrib-htmlhelp<2.0.5 -sphinxcontrib-jsmath<1.0.2 -sphinxcontrib-qthelp<1.0.7 -sphinxcontrib-serializinghtml<1.1.10 -Jinja2==2.10 -markupsafe==1.1.1 -doc2dash==2.3.0 +alabaster +sphinxcontrib-applehelp +sphinxcontrib-devhelp +sphinxcontrib-htmlhelp +sphinxcontrib-jsmath +sphinxcontrib-qthelp +sphinxcontrib-serializinghtml +Jinja2 +markupsafe +doc2dash beautifulsoup4 attrdict3 ; sys_platform == 'win32' typing-extensions; python_version < '3.10' From 7a046b379842f5b52aa951d9a3397e42662171ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:46:18 +0000 Subject: [PATCH 08/16] Add requests to setup_requires in setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index 99ee66128..95768a012 100644 --- a/setup.py +++ b/setup.py @@ -389,4 +389,5 @@ def wx_make_writable(target): headers = HEADERS, cmdclass = CMDCLASS, entry_points = ENTRY_POINTS, + setup_requires = ["requests" ], ) From 9282e059ae13583ce550cb8585ee0e3608cc7773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 20:46:49 +0000 Subject: [PATCH 09/16] Concatenate sip cpp files --- build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/build.py b/build.py index 4672c3b8f..94c3c8274 100755 --- a/build.py +++ b/build.py @@ -1321,6 +1321,7 @@ def cmd_sip(options, args): protected-is-public = false generate-extracts = [\'{extracts}\'] pep484-pyi = false + concatenate = 2 [tool.sip.project] abi-version = "{abi_version}" From 7cc7881744120e2d939aebe384203d09ce8ff4c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 21:14:06 +0000 Subject: [PATCH 10/16] Concatenate sip cpp files into 10 parts --- build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.py b/build.py index 94c3c8274..2f4c80a0d 100755 --- a/build.py +++ b/build.py @@ -1321,7 +1321,7 @@ def cmd_sip(options, args): protected-is-public = false generate-extracts = [\'{extracts}\'] pep484-pyi = false - concatenate = 2 + concatenate = 10 [tool.sip.project] abi-version = "{abi_version}" From 3cbaf6b69e97d92cdbde8c34c8ccdd7771cb86c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 21:26:41 +0000 Subject: [PATCH 11/16] Revert concatenate sip cpp files --- build.py | 1 - 1 file changed, 1 deletion(-) diff --git a/build.py b/build.py index 2f4c80a0d..4672c3b8f 100755 --- a/build.py +++ b/build.py @@ -1321,7 +1321,6 @@ def cmd_sip(options, args): protected-is-public = false generate-extracts = [\'{extracts}\'] pep484-pyi = false - concatenate = 10 [tool.sip.project] abi-version = "{abi_version}" From 96caed502148b519191d98eb3000f31c516b5c7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 12 Jan 2025 21:31:19 +0000 Subject: [PATCH 12/16] Replace distutils.command.* with setuptools.command.* --- buildtools/distutils_hacks.py | 28 ++++++++++++++-------------- buildtools/sipdistutils.py | 8 ++++---- setup.py | 2 +- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/buildtools/distutils_hacks.py b/buildtools/distutils_hacks.py index 495d7f08f..1d00d269a 100644 --- a/buildtools/distutils_hacks.py +++ b/buildtools/distutils_hacks.py @@ -14,10 +14,10 @@ import sys import os -import distutils.command.install -import distutils.command.install_data -import distutils.command.install_headers -import distutils.command.clean +import setuptools.command.install +import setuptools.command.install_data +import setuptools.command.install_headers +import setuptools.command.clean try: from setuptools.modified import newer, newer_group @@ -34,15 +34,15 @@ # New command classes -class wx_smart_install_data(distutils.command.install_data.install_data): +class wx_smart_install_data(setuptools.command.install_data.install_data): """need to change self.install_dir to the actual library dir""" def run(self): install_cmd = self.get_finalized_command('install') self.install_dir = getattr(install_cmd, 'install_lib') - return distutils.command.install_data.install_data.run(self) + return setuptools.command.install_data.install_data.run(self) -class wx_extra_clean(distutils.command.clean.clean): +class wx_extra_clean(setuptools.command.clean.clean): """ Also cleans stuff that this setup.py copies itself. If the --all flag was used also searches for .pyc, .pyd, .so files @@ -50,7 +50,7 @@ class wx_extra_clean(distutils.command.clean.clean): def run(self): from distutils.filelist import FileList - distutils.command.clean.clean.run(self) + setuptools.command.clean.clean.run(self) cfg = Config() if self.all: @@ -83,7 +83,7 @@ def run(self): # is used in our package build. If we detect that the current # distutils does not have it then make sure that it is removed from # the command-line options, otherwise the build will fail. -for item in distutils.command.install.install.user_options: +for item in setuptools.command.install.install.user_options: if item[0] == 'install-layout=': break else: @@ -94,27 +94,27 @@ def run(self): -class wx_install(distutils.command.install.install): +class wx_install(setuptools.command.install.install): """ Turns off install_path_file """ def initialize_options(self): - distutils.command.install.install.initialize_options(self) + setuptools.command.install.install.initialize_options(self) self.install_path_file = 0 -class wx_install_headers(distutils.command.install_headers.install_headers): +class wx_install_headers(setuptools.command.install_headers.install_headers): """ Install the header files to the WXPREFIX, with an extra dir per filename too """ def initialize_options(self): self.root = None - distutils.command.install_headers.install_headers.initialize_options(self) + setuptools.command.install_headers.install_headers.initialize_options(self) def finalize_options(self): self.set_undefined_options('install', ('root', 'root')) - distutils.command.install_headers.install_headers.finalize_options(self) + setuptools.command.install_headers.install_headers.finalize_options(self) def run(self): if os.name == 'nt': diff --git a/buildtools/sipdistutils.py b/buildtools/sipdistutils.py index 5d8318cfc..5737bfaa4 100644 --- a/buildtools/sipdistutils.py +++ b/buildtools/sipdistutils.py @@ -1,21 +1,21 @@ -# Subclasses distutils.command.build_ext, +# Subclasses setuptools.command.build_ext, # replacing it with a SIP version that compiles .sip -> .cpp # before calling the original build_ext command. # Written by Giovanni Bajo # Based on Pyrex.Distutils, written by Graham Fawcett and Darrel Gallion. -import distutils.command.build_ext +import setuptools.command.build_ext from distutils.dep_util import newer, newer_group import os import sys from hashlib import sha1 -build_ext_base = distutils.command.build_ext.build_ext +build_ext_base = setuptools.command.build_ext.build_ext def replace_suffix(path, new_suffix): return os.path.splitext(path)[0] + new_suffix -class build_ext (build_ext_base): +class build_ext(build_ext_base): description = "Compile SIP descriptions, then build C/C++ extensions (compile/link to build directory)" diff --git a/setup.py b/setup.py index 95768a012..b0ec7bf7f 100644 --- a/setup.py +++ b/setup.py @@ -14,7 +14,7 @@ import stat from setuptools import setup, find_packages -from distutils.command.build import build as orig_build +from setuptools.command.build import build as orig_build from setuptools.command.install import install as orig_install from setuptools.command.bdist_egg import bdist_egg as orig_bdist_egg from setuptools.command.sdist import sdist as orig_sdist From e66cd85cbfe0a71a9c7bebadb76ecd12e862c346 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 13 Jan 2025 01:35:55 +0000 Subject: [PATCH 13/16] Replace distutils logging with plain logging --- setup.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index b0ec7bf7f..9537ee50d 100644 --- a/setup.py +++ b/setup.py @@ -292,8 +292,8 @@ def wx_copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0, dst = os.path.join(dst, os.path.basename(src)) linkdst = os.readlink(src) if verbose >= 1: - from distutils import log - log.info("%s %s -> %s", 'copying symlink', src, dst) + import logging + logging.info("%s %s -> %s", 'copying symlink', src, dst) if not dry_run and not os.path.exists(dst): os.symlink(linkdst, dst) return (dst, 1) From ded39df4315819ef617b561000578da98a3d6e79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 13 Jan 2025 02:29:56 +0000 Subject: [PATCH 14/16] Replace distutils.sysconfig with standard library's sysconfig --- buildtools/config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildtools/config.py b/buildtools/config.py index 626580b9b..e0a39536a 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -31,7 +31,7 @@ except ImportError: from distutils.dep_util import newer -import distutils.sysconfig +import sysconfig runSilently = False @@ -281,7 +281,7 @@ def finishSetup(self, wx_config=None, debug=None, compiler=None): # we get the right sysroot, but we also need to ensure that # the other linker flags that distutils wants to use are # included as well. - LDSHARED = distutils.sysconfig.get_config_var('LDSHARED').split() + LDSHARED = sysconfig.get_config_var('LDSHARED').split() # remove the compiler command del LDSHARED[0] # remove any -sysroot flags and their arg From f13a87bb7705de61c74372efac325353b198dba6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 13 Jan 2025 02:32:48 +0000 Subject: [PATCH 15/16] Use _distutils commands when it doesn't exist in setuptools.command --- buildtools/distutils_hacks.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/buildtools/distutils_hacks.py b/buildtools/distutils_hacks.py index 1d00d269a..527f89326 100644 --- a/buildtools/distutils_hacks.py +++ b/buildtools/distutils_hacks.py @@ -15,9 +15,9 @@ import os import setuptools.command.install -import setuptools.command.install_data -import setuptools.command.install_headers -import setuptools.command.clean +import setuptools._distutils.command.install_data +import setuptools._distutils.command.install_headers +import setuptools._distutils.command.clean try: from setuptools.modified import newer, newer_group @@ -34,15 +34,15 @@ # New command classes -class wx_smart_install_data(setuptools.command.install_data.install_data): +class wx_smart_install_data(setuptools._distutils.command.install_data.install_data): """need to change self.install_dir to the actual library dir""" def run(self): install_cmd = self.get_finalized_command('install') self.install_dir = getattr(install_cmd, 'install_lib') - return setuptools.command.install_data.install_data.run(self) + return setuptools._distutils.command.install_data.install_data.run(self) -class wx_extra_clean(setuptools.command.clean.clean): +class wx_extra_clean(setuptools._distutils.command.clean.clean): """ Also cleans stuff that this setup.py copies itself. If the --all flag was used also searches for .pyc, .pyd, .so files @@ -50,7 +50,7 @@ class wx_extra_clean(setuptools.command.clean.clean): def run(self): from distutils.filelist import FileList - setuptools.command.clean.clean.run(self) + setuptools._distutils.command.clean.clean.run(self) cfg = Config() if self.all: @@ -103,18 +103,18 @@ def initialize_options(self): self.install_path_file = 0 -class wx_install_headers(setuptools.command.install_headers.install_headers): +class wx_install_headers(setuptools._distutils.command.install_headers.install_headers): """ Install the header files to the WXPREFIX, with an extra dir per filename too """ def initialize_options(self): self.root = None - setuptools.command.install_headers.install_headers.initialize_options(self) + setuptools._distutils.command.install_headers.install_headers.initialize_options(self) def finalize_options(self): self.set_undefined_options('install', ('root', 'root')) - setuptools.command.install_headers.install_headers.finalize_options(self) + setuptools._distutils.command.install_headers.install_headers.finalize_options(self) def run(self): if os.name == 'nt': From 6ae4ae67aae362d4b3d0e2a6204a45972f37d4d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Mon, 13 Jan 2025 02:41:25 +0000 Subject: [PATCH 16/16] Use setuptools._distutils when no setuptools equivalent exists nor PEP 632 migration advice --- buildtools/config.py | 4 ++-- buildtools/distutils_hacks.py | 28 ++++++++++++++-------------- buildtools/sipdistutils.py | 5 ++++- setup.py | 12 ++++++------ wscript | 4 ++-- 5 files changed, 28 insertions(+), 25 deletions(-) diff --git a/buildtools/config.py b/buildtools/config.py index e0a39536a..082945320 100644 --- a/buildtools/config.py +++ b/buildtools/config.py @@ -22,7 +22,7 @@ import subprocess import platform -from distutils.file_util import copy_file +from setuptools._distutils.file_util import copy_file from pathlib import Path from typing import Union @@ -1080,7 +1080,7 @@ def getToolsPlatformName(useLinuxBits=False): def updateLicenseFiles(cfg): - from distutils.file_util import copy_file + from setuptools._distutils.file_util import copy_file # Copy the license files from wxWidgets mkpath('license') diff --git a/buildtools/distutils_hacks.py b/buildtools/distutils_hacks.py index 527f89326..efe6c6735 100644 --- a/buildtools/distutils_hacks.py +++ b/buildtools/distutils_hacks.py @@ -48,7 +48,7 @@ class wx_extra_clean(setuptools._distutils.command.clean.clean): --all flag was used also searches for .pyc, .pyd, .so files """ def run(self): - from distutils.filelist import FileList + from setuptools._distutils.filelist import FileList setuptools._distutils.command.clean.clean.run(self) @@ -150,9 +150,10 @@ def run(self): # -arch is specified in our compiler args then we need to strip all of # the -arch and -isysroot args provided by Python. -import distutils.unixccompiler -import distutils.sysconfig -from distutils.errors import DistutilsExecError, CompileError +import setuptools._distutils.unixccompiler +import setuptools._distutils.sysconfig +from setuptools.errors import CompileError +from setuptools._distutils.errors import DistutilsExecError def _darwin_compiler_fixup(compiler_so, cc_args): """ @@ -241,7 +242,7 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): except DistutilsExecError as msg: raise CompileError(msg) -_orig_parse_makefile = distutils.sysconfig.parse_makefile +_orig_parse_makefile = setuptools._distutils.sysconfig.parse_makefile def _parse_makefile(filename, g=None): rv = _orig_parse_makefile(filename, g) @@ -256,10 +257,10 @@ def _parse_makefile(filename, g=None): return rv -distutils.unixccompiler.UnixCCompiler = MyUnixCCompiler -distutils.unixccompiler._darwin_compiler_fixup = _darwin_compiler_fixup -distutils.unixccompiler._darwin_compiler = _darwin_compiler_fixup_24 -distutils.sysconfig.parse_makefile = _parse_makefile +setuptools._distutils.unixccompiler.UnixCCompiler = MyUnixCCompiler +setuptools._distutils.unixccompiler._darwin_compiler_fixup = _darwin_compiler_fixup +setuptools._distutils.unixccompiler._darwin_compiler = _darwin_compiler_fixup_24 +setuptools._distutils.sysconfig.parse_makefile = _parse_makefile # Inject a little code into the CCompiler class that will check if the object @@ -286,8 +287,7 @@ def _setup_compile(self, outdir, macros, incdirs, sources, depends, extra): # Another hack-job for the CygwinCCompiler class, this time replacing # the _compile function with one that will pass the -I flags to windres. -import distutils.cygwinccompiler -from distutils.errors import DistutilsExecError, CompileError +import setuptools._distutils.cygwinccompiler def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): if ext == '.rc' or ext == '.res': @@ -305,7 +305,7 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): except DistutilsExecError as msg: raise CompileError(msg) -distutils.cygwinccompiler.CygwinCCompiler._compile = _compile +setuptools._distutils.cygwinccompiler.CygwinCCompiler._compile = _compile #---------------------------------------------------------------------- @@ -317,8 +317,8 @@ def _compile(self, obj, src, ext, cc_args, extra_postargs, pp_opts): # a monkey-patch of the msvc9compiler.MSVCCompiler.initialize method. if os.name == 'nt' and sys.version_info >= (2,6): - import distutils.msvc9compiler - _orig_initialize = distutils.msvc9compiler.MSVCCompiler.initialize + import setuptools._distutils.msvc9compiler + _orig_initialize = setuptools._distutils.msvc9compiler.MSVCCompiler.initialize def _initialize(self, *args, **kw): rv = _orig_initialize(self, *args, **kw) diff --git a/buildtools/sipdistutils.py b/buildtools/sipdistutils.py index 5737bfaa4..6861405a2 100644 --- a/buildtools/sipdistutils.py +++ b/buildtools/sipdistutils.py @@ -5,7 +5,10 @@ # Based on Pyrex.Distutils, written by Graham Fawcett and Darrel Gallion. import setuptools.command.build_ext -from distutils.dep_util import newer, newer_group +try: + from setuptools.modified import newer, newer_group +except ImportError: + from distutils.dep_util import newer, newer_group import os import sys from hashlib import sha1 diff --git a/setup.py b/setup.py index 9537ee50d..2e6588fd2 100644 --- a/setup.py +++ b/setup.py @@ -298,9 +298,9 @@ def wx_copy_file(src, dst, preserve_mode=1, preserve_times=1, update=0, os.symlink(linkdst, dst) return (dst, 1) -import distutils.file_util -orig_copy_file = distutils.file_util.copy_file -distutils.file_util.copy_file = wx_copy_file +import setuptools._distutils.file_util +orig_copy_file = setuptools._distutils.file_util.copy_file +setuptools._distutils.file_util.copy_file = wx_copy_file @@ -309,9 +309,9 @@ def wx_copy_tree(src, dst, preserve_mode=1, preserve_times=1, return orig_copy_tree( src, dst, preserve_mode, preserve_times, 1, update, verbose, dry_run) -import distutils.dir_util -orig_copy_tree = distutils.dir_util.copy_tree -distutils.dir_util.copy_tree = wx_copy_tree +import setuptools._distutils.dir_util +orig_copy_tree = setuptools._distutils.dir_util.copy_tree +setuptools._distutils.dir_util.copy_tree = wx_copy_tree # Monkey-patch make_writeable too. Sometimes the link is copied before the diff --git a/wscript b/wscript index 79bdf3e15..9dda124e8 100644 --- a/wscript +++ b/wscript @@ -463,7 +463,7 @@ def my_check_python_headers(conf): env.append_value('CXXFLAGS_PYEXT', ['-fno-strict-aliasing']) if env.CC_NAME == "msvc": - from distutils.msvccompiler import MSVCCompiler + from setuptools._distutils.msvccompiler import MSVCCompiler dist_compiler = MSVCCompiler() dist_compiler.initialize() env.append_value('CFLAGS_PYEXT', dist_compiler.compile_options) @@ -618,7 +618,7 @@ def makeExtCopyRule(bld, name): # This is the task function to be called by the above rule. def copyFileToPkg(task): - from distutils.file_util import copy_file + from setuptools._distutils.file_util import copy_file from buildtools.config import opj src = task.inputs[0].abspath() tgt = task.outputs[0].abspath()