Skip to content

Commit bb6d557

Browse files
committed
Add _dbg support for Windows, add more in-build testing (needs a new conda I fear due to using conda run there)
1 parent 3eaacb1 commit bb6d557

8 files changed

+1132
-51
lines changed

recipe/bld.bat

Lines changed: 68 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,32 +30,66 @@ if "%PY_INTERP_DEBUG%" neq "" (
3030
)
3131

3232

33-
if "%DEBUG_C%"=="yes" (
33+
if "%PY_INTERP_DEBUG%"=="yes" (
3434
set PGO=
3535
) else (
36-
set PGO=--pgo
36+
if "%DEBUG_C%"=="yes" (
37+
set PGO=
38+
) else (
39+
set PGO=--pgo
40+
)
3741
)
3842

39-
:: AP doesn't support PGO atm?
40-
set PGO=
41-
4243
cd PCbuild
4344

45+
:: Doesn't avoid the SDK problem.
46+
:: devenv /upgrade pcbuild.sln
47+
:: set __VCVARS_VERSION=%WindowsSDKVer%
48+
:: 14.16.27023
49+
:: echo ^<?xml version="1.0"?^> > my_props.props
50+
:: echo ^<PropertyGroup Label="Configuration"^> >> my_props.props
51+
:: echo ^<VCToolsVersion /^> >> my_props.props
52+
:: echo ^<PlatformToolset^>v141^</PlatformToolset^> >> my_props.props
53+
:: echo ^</PropertyGroup^> >> my_props.props
54+
:: type my_props.props
55+
:: call build.bat %PGO% %CONFIG% -m -e -v -p %PLATFORM% "/p:ForceImportBeforeCppTargets=%CD%\my_props.props" "/p:ForceImportAfterCppTargets=%CD%\my_props.props"
56+
57+
:: Twice because I am changing zipimport ATM.
58+
call build.bat %PGO% %CONFIG% -m -e -v -p %PLATFORM%
4459
call build.bat %PGO% %CONFIG% -m -e -v -p %PLATFORM%
4560
if errorlevel 1 exit 1
4661
cd ..
4762

4863
:: Populate the root package directory
4964
for %%x in (python38%_D%.dll python3%_D%.dll python%_D%.exe pythonw%_D%.exe venvlauncher%_D%.exe venvwlauncher%_D%.exe) do (
65+
echo Copying: %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x to %PREFIX%
5066
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x %PREFIX%
5167
if errorlevel 1 exit 1
5268
)
5369

70+
:: If _d appears anywhere other than at the end of the filename then this will break.
71+
if "%_D%"=="_d" (
72+
for %%x in (python38%_D%.dll python3%_D%.dll python%_D%.exe pythonw%_D%.exe venvlauncher%_D%.exe venvwlauncher%_D%.exe) do (
73+
set _TMP=%%x
74+
call set _DST=%%_TMP:_D=%%
75+
echo Copying: %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x to !_DST!
76+
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x %PREFIX%\!_DST!
77+
if errorlevel 1 exit 1
78+
)
79+
)
80+
5481
for %%x in (python%_D%.pdb python38%_D%.pdb pythonw%_D%.pdb) do (
82+
echo Copying: %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x %PREFIX%
5583
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x %PREFIX%
5684
if errorlevel 1 exit 1
5785
)
5886

87+
for %%x in (*.pdb) do (
88+
echo Copying PDB: %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x to %PREFIX%\DLLs
89+
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\%%x %PREFIX%\DLLs
90+
if errorlevel 1 exit 1
91+
)
92+
5993
copy %SRC_DIR%\LICENSE %PREFIX%\LICENSE_PYTHON.txt
6094
if errorlevel 1 exit 1
6195

@@ -139,7 +173,14 @@ copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\python3%_D%.lib %PREFIX%\libs\
139173
if errorlevel 1 exit 1
140174
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\_tkinter%_D%.lib %PREFIX%\libs\
141175
if errorlevel 1 exit 1
142-
176+
if "%_D%"=="_d" (
177+
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\python38%_D%.lib %PREFIX%\libs\python38.lib
178+
if errorlevel 1 exit 1
179+
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\python3%_D%.lib %PREFIX%\libs\python3.lib
180+
if errorlevel 1 exit 1
181+
copy /Y %SRC_DIR%\PCbuild\%BUILD_PATH%\_tkinter%_D%.lib %PREFIX%\libs\_tkinter.lib
182+
if errorlevel 1 exit 1
183+
)
143184

144185
:: Populate the Lib directory
145186
del %PREFIX%\libs\libpython*.a
@@ -166,30 +207,39 @@ if errorlevel 1 exit 1
166207
rd /s /q %PREFIX%\Lib\lib2to3\tests\
167208
if errorlevel 1 exit 1
168209

169-
:: We need our Python to be found!
210+
:: We need our Python to be found
170211
if "%_D%" neq "" copy %PREFIX%\python%_D%.exe %PREFIX%\python.exe
212+
if "%_D%" neq "" copy %PREFIX%\python%_D%.pdb %PREFIX%\python.pdb
171213

172214
%PREFIX%\python.exe -Wi %PREFIX%\Lib\compileall.py -f -q -x "bad_coding|badsyntax|py2_" %PREFIX%\Lib
173215
if errorlevel 1 exit 1
174216

175217
:: Pickle lib2to3 Grammar
176218
%PREFIX%\python.exe -m lib2to3 --help
177219

178-
:: Some quick tests for common failures
179-
echo "Testing print() does not print: Hello"
180-
%CONDA_EXE% run -p %PREFIX% cd %PREFIX% & %PREFIX%\python.exe -c "print()" 2>&1 | findstr /r /c:"Hello"
220+
echo CONDA_EXE is %CONDA_EXE%
221+
echo where conda is
222+
where conda
223+
echo where python is
224+
where python
225+
226+
echo "Testing print() does not print Hello"
227+
conda run -p %PREFIX% python -c "print()" 2>&1 | findstr /r /c:"Hello"
181228
if %errorlevel% neq 1 exit /b 1
182229

183-
echo "Testing print('Hello') prints: Hello"
184-
%CONDA_EXE% run -p %PREFIX% cd %PREFIX% & %PREFIX%\python.exe "print('Hello')" 2>&1 | findstr /r /c:"Hello"
230+
echo "Testing print('Hello') prints Hello"
231+
conda run -p %PREFIX% python -c "print('Hello')" 2>&1 | findstr /r /c:"Hello"
185232
if %errorlevel% neq 0 exit /b 1
186233

187-
echo "Testing import of os (no DLL needed) does not print: The specified module could not be found"
188-
%CONDA_EXE% run -p %PREFIX% cd %PREFIX% & %PREFIX%\python.exe -v -c "import os" 2>&1
189-
%CONDA_EXE% run -p %PREFIX% cd %PREFIX% & %PREFIX%\python.exe -v -c "import os" 2>&1 | findstr /r /c:"The specified module could not be found"
234+
echo "Testing import of os does not print The specified module could not be found"
235+
conda run -p %PREFIX% python -v -c "import os" 2>&1
236+
conda run -p %PREFIX% python -v -c "import os" 2>&1 | findstr /r /c:"The specified module could not be found"
190237
if %errorlevel% neq 1 exit /b 1
191238

192-
echo "Testing import of _sqlite3 (DLL located via PATH needed) does not print: The specified module could not be found"
193-
%CONDA_EXE% run -p %PREFIX% cd %PREFIX% & %PREFIX%\python.exe -v -c "import _sqlite3" 2>&1
194-
%CONDA_EXE% run -p %PREFIX% cd %PREFIX% & %PREFIX%\python.exe -v -c "import _sqlite3" 2>&1 | findstr /r /c:"The specified module could not be found"
239+
:: echo "Waiting for 60 seconds. Recommend you run procmon to figure out why the impeding import of _sqlite3 fails (on Win 32, python 3.7 building 3.8)"
240+
:: waitfor SomethingThatIsNeverHappening /t 60 2>NUL
241+
242+
echo "Testing import of _sqlite3 prints The specified module could not be found"
243+
conda run -p %PREFIX% python -v -c "import _sqlite3" 2>&1
244+
conda run -p %PREFIX% python -v -c "import _sqlite3" 2>&1 | findstr /r /c:"The specified module could not be found"
195245
if %errorlevel% neq 1 exit /b 1

recipe/build.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,13 @@ if [[ ${_OPTIMIZED} == yes ]]; then
224224
_MAKE_TARGET=profile-opt
225225
# To speed up build times during testing (1):
226226
if [[ ${QUICK_BUILD} == yes ]]; then
227-
# TODO :: It seems this is just profiling everything, on Windows, only 40 odd tests are
228-
# run while on Unix, all 400+ are run, making this slower and less well curated
229227
_PROFILE_TASK+=(PROFILE_TASK="-m test --pgo")
230228
else
231-
_PROFILE_TASK+=(PROFILE_TASK="-m test --pgo-extended")
229+
# TODO :: Run some benchmarks on these to see which is better.
230+
# :: We decided to go with the faster-to-build option for now
231+
# :: --pgo-extended runs 10 times as many tests as --pgo does.
232+
# _PROFILE_TASK+=(PROFILE_TASK="-m test --pgo-extended")
233+
_PROFILE_TASK+=(PROFILE_TASK="-m test --pgo")
232234
fi
233235
if [[ ${CC} =~ .*gcc.* ]]; then
234236
LTO_CFLAGS+=(-fuse-linker-plugin)

recipe/meta.yaml

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{% set base_version = "3.8.1" %}
22
{% set version = base_version %}
33
{% set linkage_nature = os.environ.get('PY_INTERP_LINKAGE_NATURE', '') %}
4-
{% set debug = os.environ.get('PY_INTERP_DEBUG', '') %}
54
{% if linkage_nature != '' %}
65
{% set linkage_nature = "_" ~ linkage_nature %}
76
{% endif %}
7+
{% set debug = os.environ.get('PY_INTERP_DEBUG', '') %}
88
{% if debug != '' %}
9-
{% set debug = "_d" ~ debug %}
9+
{% set debug = "_dbg" %}
1010
{% endif %}
1111

1212
package:
@@ -44,6 +44,8 @@ source:
4444
- patches/0021-roll-back-2e33ecd-for-py_compile.main.patch
4545
# Python 3.8 is pretty broken without this.
4646
- patches/0022-Add-CondaEcosystemModifyDllSearchPath.patch
47+
- patches/0025-egg-debugging-with-Windows-debug-builds.patch
48+
- patches/0026-Revert-part-of-https-bugs.python.org-issue33895-http.patch
4749

4850
# TODO :: Depend on our own packages for these:
4951
- url: https://github.com/python/cpython-source-deps/archive/xz-5.2.2.zip # [win]
@@ -78,7 +80,7 @@ source:
7880

7981

8082
build:
81-
number: 3
83+
number: 8
8284
# Windows has issues updating python if conda is using files itself.
8385
# Copy rather than link.
8486
no_link:
@@ -99,10 +101,9 @@ build:
99101
# - lib/libpython3.dylib # [osx]
100102
# match python.org compiler standard
101103
skip: True # [win and int(float(vc)) < 14]
102-
# Would like to be able to append to the calculated build string here, ping @msarahan, is this possible?
103-
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}{{ debug }}_cpython
104+
string: h{{ PKG_HASH }}_{{ PKG_BUILDNUM }}{{ linkage_nature }}_cpython{{ debug }}
104105
run_exports:
105-
- python_abi 3.8.* cp38
106+
- python_abi 3.8.* cp38{{ debug }}
106107
script_env:
107108
- PY_INTERP_LINKAGE_NATURE
108109
- PY_INTERP_DEBUG
@@ -123,12 +124,12 @@ requirements:
123124
- make # [not win]
124125
- pkg-config # [not win]
125126
# configure script looks for llvm-ar for lto
127+
{% if 'conda-forge' in channel_targets %}
126128
- llvm-tools # [osx]
129+
{% endif %}
127130
- patch # [not win]
128131
- m2-patch # [win]
129-
- posix # [win]
130-
- ld_impl_{{target_platform}} # [linux]
131-
- binutils_impl_{{target_platform}} >=2.33.1 # [linux]
132+
- m2-gcc-libs # [win]
132133
host:
133134
- bzip2 # [not win]
134135
- sqlite
@@ -137,13 +138,21 @@ requirements:
137138
- openssl
138139
- readline # [not win]
139140
- tk # [not win]
140-
- ncurses # [linux]
141+
- ncurses # [not win]
141142
- libffi # [not win]
143+
{% if 'conda-forge' not in channel_targets %}
144+
- binutils_impl_{{target_platform}} # [linux and aarch64]
145+
- ld_impl_{{target_platform}} # [linux and not aarch64]
146+
{% else %}
142147
- ld_impl_{{target_platform}} # [linux]
148+
{% endif %}
143149
run:
150+
{% if 'conda-forge' not in channel_targets %}
151+
- binutils_impl_{{target_platform}} # [linux and aarch64]
152+
- ld_impl_{{target_platform}} # [linux and not aarch64]
153+
{% else %}
144154
- ld_impl_{{target_platform}} # [linux]
145-
run_constrained:
146-
- python_abi 3.8.* cp38
155+
{% endif %}
147156

148157
test:
149158
requires:
@@ -178,15 +187,18 @@ test:
178187
- python -c "import foobar"
179188
- popd
180189
- pushd distutils.cext
181-
- python setup.py install -v -v
182-
- python -c "import greet; greet.greet('Python user')" | rg "Hello Python"
190+
# --single-version-externally-managed because .egg files with compiled code do not work on Windows (Python 3.8) when Py_DEBUG (this should be investigated)
191+
- python setup.py install -v -v # [(not win) or environ.get('PY_INTERP_DEBUG') == '']
192+
- python setup.py install --single-version-externally-managed --record=record.txt -v -v # [win and environ.get('PY_INTERP_DEBUG') != '']
193+
- python -v -v -v -c "import greet"
194+
- python -v -v -v -c "import greet; greet.greet('Python user')" | rg "Hello Python"
183195
- popd
184196
- pushd prefix-replacement # [unix]
185197
- bash build-and-test.sh # [unix]
186198
- popd # [unix]
187199
- pushd cmake
188-
- cmake -GNinja -DPY_VER={{ version }}
189-
# --trace --debug-output --debug-trycompile .
200+
- cmake -GNinja -DPY_VER={{ version }} .
201+
# --trace --debug-output --debug-trycompile
190202
- popd
191203
- popd
192204

recipe/patches/0022-Add-CondaEcosystemModifyDllSearchPath.patch

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
1-
From 6c67f1126dc91ad94f735b20e2dda4bb7c54f472 Mon Sep 17 00:00:00 2001
1+
From bd510e850256e4711b3e7d9a2ba089f32d3a0eea Mon Sep 17 00:00:00 2001
22
From: Ray Donnelly <[email protected]>
33
Date: Tue, 24 Dec 2019 18:37:17 +0100
4-
Subject: [PATCH 22/22] Add CondaEcosystemModifyDllSearchPath()
4+
Subject: [PATCH 22/24] Add CondaEcosystemModifyDllSearchPath()
55

66
This changes the DLL search order so that C:\Windows\System32 does not
77
get searched in before entries in PATH.
88

99
Reviewed by Kai Tietz 7.2.2019
1010

1111
Updated a bit to include other directories.
12+
13+
Made fwprintfs breakpointable
1214
---
13-
Modules/main.c | 384 +++++++++++++++++++++++++++++++++++++++++++
15+
Modules/main.c | 391 +++++++++++++++++++++++++++++++++++++++++++
1416
Python/dynload_win.c | 7 +-
15-
2 files changed, 389 insertions(+), 2 deletions(-)
17+
2 files changed, 396 insertions(+), 2 deletions(-)
1618

1719
diff --git a/Modules/main.c b/Modules/main.c
18-
index 0d2cf3ab82..a8cd6dd89a 100644
20+
index 0d2cf3ab82..fcf9811aaf 100644
1921
--- a/Modules/main.c
2022
+++ b/Modules/main.c
2123
@@ -20,6 +20,10 @@
@@ -38,7 +40,7 @@ index 0d2cf3ab82..a8cd6dd89a 100644
3840
/* --- pymain_init() ---------------------------------------------- */
3941

4042
static PyStatus
41-
@@ -658,10 +664,388 @@ Py_RunMain(void)
43+
@@ -658,10 +664,395 @@ Py_RunMain(void)
4244
return exitcode;
4345
}
4446

@@ -275,7 +277,8 @@ index 0d2cf3ab82..a8cd6dd89a 100644
275277
+ {
276278
+ if (_wgetenv(L"CONDA_DLL_SEARCH_MODIFICATION_NEVER_CACHE") == NULL)
277279
+ {
278-
+ if (debug_it) fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: INFO :: Values unchanged\n");
280+
+ if (debug_it)
281+
+ fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: INFO :: Values unchanged\n");
279282
+ return 0;
280283
+ }
281284
+ }
@@ -295,7 +298,8 @@ index 0d2cf3ab82..a8cd6dd89a 100644
295298
+ {
296299
+ size_t len = wcslen(path_env);
297300
+ wchar_t *path = (wchar_t *)alloca((len + 1) * sizeof(wchar_t));
298-
+ if (debug_it) fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: PATH=%ls\n\b", path_env);
301+
+ if (debug_it)
302+
+ fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: PATH=%ls\n\b", path_env);
299303
+ memcpy(path, path_env, (len + 1) * sizeof(wchar_t));
300304
+ /* Convert any / to \ */
301305
+ /* Replace slash with backslash */
@@ -364,7 +368,8 @@ index 0d2cf3ab82..a8cd6dd89a 100644
364368
+ }
365369
+ }
366370
+#endif /* defined(HARDCODE_CONDA_PATHS) */
367-
+ if (debug_it) fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls)\n", path_entries[i]);
371+
+ if (debug_it)
372+
+ fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls)\n", path_entries[i]);
368373
+ pAddDllDirectory(path_entries[i]);
369374
+ }
370375
+ }
@@ -374,10 +379,12 @@ index 0d2cf3ab82..a8cd6dd89a 100644
374379
+ {
375380
+ for (j = NUM_CONDA_PATHS-1, p_conda_path = &condaPaths[NUM_CONDA_PATHS-1]; j > -1; --j, --p_conda_path)
376381
+ {
377-
+ if (debug_it) fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: p_conda_path->p_name = %ls, foundCondaPath[%zd] = %d\n", p_conda_path->p_name, j, foundCondaPath[j]);
382+
+ if (debug_it)
383+
+ fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: p_conda_path->p_name = %ls, foundCondaPath[%zd] = %d\n", p_conda_path->p_name, j, foundCondaPath[j]);
378384
+ if (!foundCondaPath[j])
379385
+ {
380-
+ if (debug_it) fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls - ExePrefix)\n", p_conda_path->p_name);
386+
+ if (debug_it)
387+
+ fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls - ExePrefix)\n", p_conda_path->p_name);
381388
+ pAddDllDirectory(p_conda_path->p_name);
382389
+ }
383390
+ }
@@ -391,14 +398,16 @@ index 0d2cf3ab82..a8cd6dd89a 100644
391398
+ free(sv_added_cwd);
392399
+ }
393400
+ sv_added_cwd = _wcsdup(p_cwd);
394-
+ if (debug_it) fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls - CWD)\n", sv_added_cwd);
401+
+ if (debug_it)
402+
+ fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls - CWD)\n", sv_added_cwd);
395403
+ pAddDllDirectory(sv_added_cwd);
396404
+ }
397405
+
398406
+ if (add_windows_directory)
399407
+ {
400408
+ sv_added_windows_directory = &sv_windows_directory[0];
401-
+ if (debug_it) fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls - WinDir)\n", sv_windows_directory);
409+
+ if (debug_it)
410+
+ fwprintf(stderr, L"CondaEcosystemModifyDllSearchPath() :: AddDllDirectory(%ls - WinDir)\n", sv_windows_directory);
402411
+ pAddDllDirectory(sv_windows_directory);
403412
+ }
404413
+ else
@@ -448,5 +457,5 @@ index 6deba1134e..56d8913455 100644
448457
#if HAVE_SXS
449458
_Py_DeactivateActCtx(cookie);
450459
--
451-
2.24.0
460+
2.25.0
452461

0 commit comments

Comments
 (0)