Skip to content

Commit 279359e

Browse files
authored
Merge pull request #3810 from bdbaddog/remove_pywin32_from_platform_win32
Final PR to remove last vestiges of pywin32 from SCons.
2 parents 19efacf + 8334884 commit 279359e

File tree

10 files changed

+25
-55
lines changed

10 files changed

+25
-55
lines changed

.appveyor/install.bat

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ for /F "tokens=*" %%g in ('C:\\%WINPYTHON%\\python.exe -c "import sys; print(sys
33
REM use mingw 32 bit until #3291 is resolved
44
set PATH=C:\\%WINPYTHON%;C:\\%WINPYTHON%\\Scripts;C:\\ProgramData\\chocolatey\\bin;C:\\MinGW\\bin;C:\\MinGW\\msys\\1.0\\bin;C:\\cygwin\\bin;C:\\msys64\\usr\\bin;C:\\msys64\\mingw64\\bin;%PATH%
55
C:\\%WINPYTHON%\\python.exe -m pip install -U --progress-bar off pip setuptools wheel
6-
C:\\%WINPYTHON%\\python.exe -m pip install -U --progress-bar off pypiwin32 coverage codecov
6+
C:\\%WINPYTHON%\\python.exe -m pip install -U --progress-bar off coverage codecov
77
set STATIC_DEPS=true & C:\\%WINPYTHON%\\python.exe -m pip install -U --progress-bar off lxml
88
REM install 3rd party tools to test with
99
choco install --allow-empty-checksums dmd ldc swig vswhere xsltproc winflexbison

CHANGES.txt

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@ RELEASE VERSION/DATE TO BE FILLED IN LATER
1717
From William Deegan:
1818
- Fix yacc tool, not respecting YACC set at time of tool initialization.
1919
- Refactor SCons.Tool to move all common shared and loadable module linking logic to SCons.Tool.linkCommon
20-
- Remove pywin32 usage from SCons.Util where it was used for accessing the registry. Python native winreg
21-
library already includes this functionality.
22-
- Remove using pywin32 to retrieve peak memory usage on Win32 for `--debug=memory`
20+
- Remove pywin32 imports from SCons.Script.Main. No longer needed.
21+
- Switch to use ctypes instead of pywin32 (requiring an extra pip install) - Fixes Github Issue #2291
22+
- pywin32 no longer necessary for SCons install. (pip install SCons will no longer also require pywin32 on win32)
23+
- Remove pywin32 usage from SCons.Util where it was used for accessing the registry. Python native winreg
24+
library already includes this functionality.
25+
- Remove using pywin32 to retrieve peak memory usage on Win32 for `--debug=memory`
2326

2427
From Michał Górny:
2528
- Fix dvipdf test failure due to passing incorrect flag to dvipdf.

README-SF.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,7 @@ Execution Requirements
4848
======================
4949

5050
Running SCons requires Python 3.5 or higher. There should be no other
51-
dependencies or requirements to run scons, although the pywin32 Python
52-
package is strongly recommended if running on Windows systems.
51+
dependencies or requirements to run scons.
5352

5453
The default SCons configuration assumes use of the Microsoft Visual C++
5554
compiler suite on Win32 systems, and assumes a C compiler named 'cc', a C++

README-package.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ Requirements
4545
------------
4646

4747
Running SCons requires Python 3.5 or higher. There should be no other
48-
dependencies or requirements to run SCons, although the pywin32 Python
49-
package is strongly recommended if running on Windows systems.
48+
dependencies or requirements to run SCons.
5049

5150

5251
By default, SCons knows how to search for available programming tools on

README.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ Execution Requirements
7373
======================
7474

7575
Running SCons requires Python 3.5 or higher. There should be no other
76-
dependencies or requirements to run scons, although the pywin32 Python
77-
package is strongly recommended if running on Windows systems.
76+
dependencies or requirements to run scons
7877

7978
The default SCons configuration assumes use of the Microsoft Visual C++
8079
compiler suite on Win32 systems, and assumes a C compiler named 'cc', a C++

SCons/Platform/win32.py

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,22 +43,6 @@
4343
r'C:\ProgramData\chocolatey\bin'
4444
]
4545

46-
try:
47-
import msvcrt
48-
import win32api
49-
import win32con
50-
except ImportError:
51-
parallel_msg = \
52-
"you do not seem to have the pywin32 extensions installed;\n" + \
53-
"\tparallel (-j) builds may not work reliably with open Python files."
54-
except AttributeError:
55-
parallel_msg = \
56-
"your pywin32 extensions do not support file handle operations;\n" + \
57-
"\tparallel (-j) builds may not work reliably with open Python files."
58-
else:
59-
parallel_msg = None
60-
61-
6246
if False:
6347
# Now swap out shutil.filecopy and filecopy2 for win32 api native CopyFile
6448
try:

SCons/Script/Main.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
import traceback
4747
import sysconfig
4848
import platform
49+
import threading
4950

5051
import SCons.CacheDir
5152
import SCons.Debug
@@ -80,17 +81,6 @@
8081
delayed_warnings = []
8182

8283

83-
def fetch_win32_parallel_msg():
84-
# A subsidiary function that exists solely to isolate this import
85-
# so we don't have to pull it in on all platforms, and so that an
86-
# in-line "import" statement in the _main() function below doesn't
87-
# cause warnings about local names shadowing use of the 'SCons'
88-
# global in nest scopes and UnboundLocalErrors and the like in some
89-
# versions (2.1) of Python.
90-
import SCons.Platform.win32
91-
return SCons.Platform.win32.parallel_msg
92-
93-
9484
def revert_io():
9585
# This call is added to revert stderr and stdout to the original
9686
# ones just in case some build rule or something else in the system
@@ -1281,16 +1271,19 @@ def tmtrace_cleanup(tfile):
12811271
# As of 3.7, python removed support for threadless platforms.
12821272
# See https://www.python.org/dev/peps/pep-0011/
12831273
is_37_or_later = sys.version_info >= (3, 7)
1284-
python_has_threads = sysconfig.get_config_var('WITH_THREAD') or is_pypy or is_37_or_later
1274+
# python_has_threads = sysconfig.get_config_var('WITH_THREAD') or is_pypy or is_37_or_later
1275+
1276+
# As of python 3.4 threading has a dummy_threading module for use when there is no threading
1277+
# it's get_ident() will allways return -1, while real threading modules get_ident() will
1278+
# always return a positive integer
1279+
python_has_threads = threading.get_ident() != -1
12851280
# to check if python configured with threads.
12861281
global num_jobs
12871282
num_jobs = options.num_jobs
12881283
jobs = SCons.Job.Jobs(num_jobs, taskmaster)
12891284
if num_jobs > 1:
12901285
msg = None
1291-
if sys.platform == 'win32':
1292-
msg = fetch_win32_parallel_msg()
1293-
elif jobs.num_jobs == 1 or not python_has_threads:
1286+
if jobs.num_jobs == 1 or not python_has_threads:
12941287
msg = "parallel builds are unsupported by this version of Python;\n" + \
12951288
"\tignoring -j or num_jobs option.\n"
12961289
if msg:

doc/man/scons.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -515,9 +515,7 @@ by appropriate setting of &consvars;.</para>
515515

516516
<para>&scons;
517517
requires Python 3.5 or higher.
518-
There should be no other dependencies or requirements to run &scons;,
519-
although the <package>pywin32</package> Python package is
520-
strongly recommended if running on Windows systems.
518+
There should be no other dependencies or requirements to run &scons;.
521519
</para>
522520

523521
</refsect1>

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ zip_safe = False
4242
python_requires = >=3.5
4343
install_requires =
4444
setuptools
45-
pywin32 >= 1.0;platform_system=="Windows"
4645

4746
setup_requires = setuptools
4847
include_package_data = True

test/option/debug-memory.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python
2+
# MIT License
23
#
3-
# __COPYRIGHT__
4+
# Copyright The SCons Foundation
45
#
56
# Permission is hereby granted, free of charge, to any person obtaining
67
# a copy of this software and associated documentation files (the
@@ -22,30 +23,25 @@
2223
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2324
#
2425

25-
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
26-
2726
"""
2827
Test that the --debug=memory option works.
2928
"""
3029

3130
import re
3231

3332
import TestSCons
33+
from TestCmd import IS_WINDOWS
3434

3535
test = TestSCons.TestSCons()
3636

37-
try:
38-
import resource
39-
except ImportError:
37+
if not IS_WINDOWS:
4038
try:
41-
import win32process
42-
import win32api
39+
import resource # noqa: F401
4340
except ImportError:
44-
x = "Python version has no 'resource' or 'win32api/win32process' module; skipping tests.\n"
41+
x = "Python version has no 'resource' skipping tests.\n"
4542
test.skip_test(x)
4643

4744

48-
4945
test.write('SConstruct', """
5046
DefaultEnvironment(tools=[])
5147
def cat(target, source, env):

0 commit comments

Comments
 (0)