Skip to content

Commit 49c52f9

Browse files
authored
Dropping support for Python 3.7 (#2207)
1 parent a940d68 commit 49c52f9

File tree

14 files changed

+23
-62
lines changed

14 files changed

+23
-62
lines changed

.github/workflows/download-arm64-libs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@
2828
VERSION += f"-rc{sys.version_info.serial}"
2929

3030
URL = f"https://www.nuget.org/api/v2/package/pythonarm64/{VERSION}"
31-
PATH = dest / f"pythonarm64.{VERSION}.zip"
31+
DEST_PATH = dest / f"pythonarm64.{VERSION}.zip"
3232

33-
if PATH.is_file():
34-
print("Skipping download because", PATH, "exists")
33+
if DEST_PATH.is_file():
34+
print("Skipping download because", DEST_PATH, "exists")
3535
else:
3636
print("Downloading", URL)
37-
urlretrieve(URL, PATH)
38-
print("Downloaded", PATH)
37+
urlretrieve(URL, DEST_PATH)
38+
print("Downloaded", DEST_PATH)
3939

40-
with ZipFile(PATH, "r") as zf:
40+
with ZipFile(DEST_PATH, "r") as zf:
4141
for name in zf.namelist():
4242
zip_path = pathlib.PurePath(name)
4343
if zip_path.parts[:2] == ("tools", "libs"):

.github/workflows/main.yml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
21+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
2222
architecture: ["x64", "x86"]
2323

2424
steps:
@@ -37,7 +37,7 @@ jobs:
3737
run: |
3838
python --version
3939
pip --version
40-
pip install --upgrade setuptools wheel
40+
pip install --upgrade setuptools>=74 wheel
4141
4242
- name: Build and install
4343
run: |
@@ -86,7 +86,7 @@ jobs:
8686
run: |
8787
python --version
8888
pip --version
89-
pip install --upgrade setuptools wheel
89+
pip install --upgrade setuptools>=74 wheel
9090
9191
- name: Obtain ARM64 library files
9292
run: |
@@ -117,7 +117,7 @@ jobs:
117117
cache-dependency-path: .github/workflows/main.yml
118118
- run: pip install clang-format pycln
119119
- run: pycln . --config=pycln.toml --check
120-
- uses: chartboost/ruff-action@v1
120+
- uses: astral-sh/ruff-action@v1
121121
with:
122122
version: "0.4.5"
123123
- uses: psf/black@stable
@@ -134,7 +134,6 @@ jobs:
134134
strategy:
135135
fail-fast: false
136136
matrix:
137-
# mypy 1.5 dropped support for Python 3.7
138137
# mypy won't understand "3.13-dev", keeping the CI simple by just omitting it
139138
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
140139
steps:
@@ -154,7 +153,7 @@ jobs:
154153
strategy:
155154
fail-fast: false
156155
matrix:
157-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
156+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13-dev"]
158157
steps:
159158
- uses: actions/checkout@v4
160159
- uses: actions/setup-python@v5

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ https://mhammond.github.io/pywin32_installers.html.
1414
Coming in build 309, as yet unreleased
1515
--------------------------------------
1616

17+
* Dropped support for Python 3.7 (#2207, @Avasam)
1718
* Implement record pointers as [in, out] method parameters of a Dispatch Interface (#2310)
1819
* Fix memory leak converting to PyObject from some SAFEARRAY elements (#2316)
1920
* Fix bug where makepy support was unnecessarily generated (#2354, #2353, @geppi)

Pythonwin/pywin/test/test_pywin.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ def setUpClass(cls):
4747
def _restore_oe():
4848
sys.stdout, sys.stderr = cls.std_oe_orig
4949

50-
if sys.version_info >= (3, 8):
51-
cls.addClassCleanup(_restore_oe)
50+
cls.addClassCleanup(_restore_oe)
5251
sys.argv[1:] = ["/new", src_dir + "\\_dbgscript.py"]
5352
if not _indebugger:
5453
thisApp.InitInstance()
@@ -65,7 +64,7 @@ def tearDownClass(cls):
6564
win32api.PostQuitMessage()
6665
win32gui.PumpWaitingMessages()
6766
cls.app.ExitInstance()
68-
sys.stdout, sys.stderr = cls.std_oe_orig # py3.7
67+
sys.stdout, sys.stderr = cls.std_oe_orig
6968

7069
def test_1_pydocs_and_finddlg(self):
7170
mf = win32ui.GetMainFrame()

build_all.bat

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
py -3.7-32 setup.py -q build
2-
@if errorlevel 1 goto failed
3-
py -3.7 setup.py -q build
4-
@if errorlevel 1 goto failed
51
py -3.8-32 setup.py -q build
62
@if errorlevel 1 goto failed
73
py -3.8 setup.py -q build

build_env.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ from the pywin32 directory.
149149
- Update `setuptools` and set the following environment variables to ensure it is used:
150150

151151
```shell
152-
set SETUPTOOLS_USE_DISTUTILS=1
153152
set DISTUTILS_USE_SDK=1
154153
```
155154

com/win32com/test/pippo_server.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ def Method3(self, in1):
4141

4242

4343
def BuildTypelib():
44-
if sys.version_info >= (3, 8):
45-
from setuptools.modified import newer
46-
else:
47-
from distutils.dep_util import newer
44+
from setuptools.modified import newer
4845

4946
this_dir = os.path.dirname(__file__)
5047
idl = os.path.abspath(os.path.join(this_dir, "pippo.idl"))

make_all.bat

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@ rem Now the binaries.
1313
rem Check /build_env.md#build-environment to make sure you have all the required components installed
1414

1515
rem (bdist_wininst needs --target-version to name the installers correctly!)
16-
py -3.7-32 setup.py -q bdist_wininst --skip-build --target-version=3.7
17-
py -3.7-32 setup.py -q bdist_wheel --skip-build
18-
py -3.7 setup.py -q bdist_wininst --skip-build --target-version=3.7
19-
py -3.7 setup.py -q bdist_wheel --skip-build
20-
2116
py -3.8-32 setup.py -q bdist_wininst --skip-build --target-version=3.8
2217
py -3.8-32 setup.py -q bdist_wheel --skip-build
2318
py -3.8 setup.py -q bdist_wininst --skip-build --target-version=3.8

mypy.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[mypy]
22
show_column_numbers = true
33
; Target the oldest supported version in editors and default CLI
4-
; mypy 1.5 dropped support for Python 3.7
54
python_version = 3.8
65

76
strict = true

pyrightconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"typeCheckingMode": "basic",
33
// Target the oldest supported version in editors and default CLI
4-
"pythonVersion": "3.7",
4+
"pythonVersion": "3.8",
55
// Keep it simple for now by allowing both mypy and pyright to use `type: ignore`
66
"enableTypeIgnoreComments": true,
77
// Exclude from scanning when running pyright

ruff.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
target-version = "py37" # Target the oldest supported version
1+
target-version = "py38" # Target the oldest supported version in editors and default CLI
22

33
[lint]
44
select = [

setup.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,14 @@
4040
from setuptools.command.build_ext import build_ext
4141
from setuptools.command.install import install
4242
from setuptools.command.install_lib import install_lib
43+
from setuptools.modified import newer_group
4344
from tempfile import gettempdir
4445
from typing import Iterable
4546

4647
from distutils import ccompiler
4748
from distutils._msvccompiler import MSVCCompiler
4849
from distutils.command.install_data import install_data
4950

50-
if sys.version_info >= (3, 8):
51-
from setuptools.modified import newer_group
52-
else:
53-
from distutils.dep_util import newer_group
54-
5551
build_id_patch = build_id
5652
if not "." in build_id_patch:
5753
build_id_patch += ".0"
@@ -868,12 +864,6 @@ def run(self):
868864
install.run(self)
869865
# Custom script we run at the end of installing - this is the same script
870866
# run by bdist_wininst
871-
# This child process won't be able to install the system DLLs until our
872-
# process has terminated (as distutils imports win32api!), so we must use
873-
# some 'no wait' executor - spawn seems fine! We pass the PID of this
874-
# process so the child will wait for us.
875-
# XXX - hmm - a closer look at distutils shows it only uses win32api
876-
# if _winreg fails - and this never should. Need to revisit this!
877867
# If self.root has a value, it means we are being "installed" into
878868
# some other directory than Python itself (eg, into a temp directory
879869
# for bdist_wininst to use) - in which case we must *not* run our
@@ -885,7 +875,8 @@ def run(self):
885875
if not os.path.isfile(filename):
886876
raise RuntimeError(f"Can't find '{filename}'")
887877
print("Executing post install script...")
888-
# What executable to use? This one I guess.
878+
# As of setuptools>=74.0.0, we no longer need to
879+
# be concerned about distutils calling win32api
889880
subprocess.Popen(
890881
[
891882
sys.executable,
@@ -905,8 +896,8 @@ def install(self):
905896
# This is crazy - in setuptools 61.1.0 (and probably some earlier versions), the
906897
# install_lib and build comments don't agree on where the .py files to install can
907898
# be found, so we end up with a warning logged:
908-
# `warning: my_install_lib: 'build\lib.win-amd64-3.7' does not exist -- no Python modules to install`
909-
# (because they are actually in `build\lib.win-amd64-cpython-37`!)
899+
# `warning: my_install_lib: 'build\lib.win-amd64-3.8' does not exist -- no Python modules to install`
900+
# (because they are actually in `build\lib.win-amd64-cpython-38`!)
910901
# It's not an error though, so we end up with .exe installers lacking our lib files!
911902
builder = self.get_finalized_command("build")
912903
if os.path.isdir(builder.build_platlib) and not os.path.isdir(self.build_dir):
@@ -2151,7 +2142,6 @@ def convert_optional_data_files(files):
21512142
"Intended Audience :: Developers",
21522143
"License :: OSI Approved :: Python Software Foundation License",
21532144
"Operating System :: Microsoft :: Windows",
2154-
"Programming Language :: Python :: 3.7",
21552145
"Programming Language :: Python :: 3.8",
21562146
"Programming Language :: Python :: 3.9",
21572147
"Programming Language :: Python :: 3.10",

win32/Lib/pywin32_bootstrap.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
# In short, there's a directory installed by pywin32 named 'pywin32_system32'
55
# with some important DLLs which need to be found by Python when some pywin32
66
# modules are imported.
7-
# If Python has `os.add_dll_directory()`, we need to call it with this path.
8-
# Otherwise, we add this path to PATH.
97

108

119
try:
@@ -19,11 +17,5 @@
1917
# https://docs.python.org/3/reference/import.html#__path__
2018
for path in pywin32_system32.__path__:
2119
if os.path.isdir(path):
22-
if hasattr(os, "add_dll_directory"):
23-
os.add_dll_directory(path)
24-
# This is to ensure the pywin32 path is in the beginning to find the
25-
# pywin32 DLLs first and prevent other PATH entries to shadow them
26-
elif not os.environ["PATH"].startswith(path):
27-
os.environ["PATH"] = os.environ["PATH"].replace(os.pathsep + path, "")
28-
os.environ["PATH"] = path + os.pathsep + os.environ["PATH"]
20+
os.add_dll_directory(path)
2921
break

win32/src/_win32sysloader.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,7 @@ static PyObject *PyLoadModule(PyObject *self, PyObject *args)
5252
if (!modName)
5353
return NULL;
5454

55-
// Python 3.7 vs 3.8 use different flags for LoadLibraryEx and we match them.
56-
// See github issue 1787.
57-
#if (PY_VERSION_HEX < 0x03080000)
58-
HINSTANCE hinst = LoadLibraryEx(modName, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
59-
#else
6055
HINSTANCE hinst = LoadLibraryEx(modName, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR);
61-
#endif
6256
PyMem_Free(modName);
6357
if (hinst == NULL) {
6458
Py_INCREF(Py_None);

0 commit comments

Comments
 (0)