Skip to content

Commit 17ba155

Browse files
committed
bpo-34977: Add Windows App Store package
1 parent 38df97a commit 17ba155

46 files changed

Lines changed: 2827 additions & 332 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
jobs:
2+
- job: Prebuild
3+
displayName: Pre-build checks
4+
5+
pool:
6+
vmImage: ubuntu-16.04
7+
8+
steps:
9+
- template: ./prebuild-checks.yml
10+
11+
12+
- job: Windows_Appx_Tests
13+
displayName: Windows Appx Tests
14+
dependsOn: Prebuild
15+
condition: and(succeeded(), eq(dependencies.Prebuild.outputs['tests.run'], 'true'))
16+
17+
pool:
18+
vmImage: vs2017-win2016
19+
20+
strategy:
21+
matrix:
22+
win64:
23+
arch: amd64
24+
buildOpt: '-p x64'
25+
testRunTitle: '$(Build.SourceBranchName)-win64-appx'
26+
testRunPlatform: win64
27+
maxParallel: 2
28+
29+
steps:
30+
- checkout: self
31+
clean: true
32+
fetchDepth: 5
33+
34+
- powershell: |
35+
# Relocate build outputs outside of source directory to make cleaning faster
36+
Write-Host '##vso[task.setvariable variable=Py_IntDir]$(Build.BinariesDirectory)\obj'
37+
# UNDONE: Do not build to a different directory because of broken tests
38+
Write-Host '##vso[task.setvariable variable=Py_OutDir]$(Build.SourcesDirectory)\PCbuild'
39+
Write-Host '##vso[task.setvariable variable=EXTERNAL_DIR]$(Build.BinariesDirectory)\externals'
40+
displayName: Update build locations
41+
42+
- script: PCbuild\build.bat -e $(buildOpt)
43+
displayName: 'Build CPython'
44+
45+
- script: python.bat PC\layout -vv -s "$(Build.SourcesDirectory)" -b "$(Py_OutDir)\$(arch)" -t "$(Py_IntDir)\layout-tmp-$(arch)" --copy "$(Py_IntDir)\layout-$(arch)" --precompile --preset-appx --include-tests
46+
displayName: 'Create APPX layout'
47+
48+
- script: .\python.exe -m test.pythoninfo
49+
workingDirectory: $(Py_IntDir)\layout-$(arch)
50+
displayName: 'Display build info'
51+
52+
- script: .\python.exe -m test -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results.xml" --tempdir "$(Py_IntDir)\tmp-$(arch)"
53+
workingDirectory: $(Py_IntDir)\layout-$(arch)
54+
displayName: 'Tests'
55+
env:
56+
PREFIX: $(Py_IntDir)\layout-$(arch)
57+
58+
- task: PublishTestResults@2
59+
displayName: 'Publish Test Results'
60+
inputs:
61+
testResultsFiles: '$(Build.BinariesDirectory)\test-results.xml'
62+
mergeTestResults: true
63+
testRunTitle: $(testRunTitle)
64+
platform: $(testRunPlatform)
65+
condition: succeededOrFailed()

Doc/make.bat

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,10 +117,12 @@ if not exist "%BUILDDIR%" mkdir "%BUILDDIR%"
117117

118118
if exist ..\Misc\NEWS (
119119
echo.Copying Misc\NEWS to build\NEWS
120+
if not exist build mkdir build
120121
copy ..\Misc\NEWS build\NEWS > nul
121122
) else if exist ..\Misc\NEWS.D (
122123
if defined BLURB (
123124
echo.Merging Misc/NEWS with %BLURB%
125+
if not exist build mkdir build
124126
%BLURB% merge -f build\NEWS
125127
) else (
126128
echo.No Misc/NEWS file and Blurb is not available.

Lib/test/test_venv.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,7 @@ def test_isolation(self):
243243
self.assertIn('include-system-site-packages = %s\n' % s, data)
244244

245245
@unittest.skipUnless(can_symlink(), 'Needs symlinks')
246+
@unittest.skipIf(os.name == 'nt', 'Symlinks are never used on Windows')
246247
def test_symlinking(self):
247248
"""
248249
Test symlinking works as expected

Lib/venv/__init__.py

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,11 @@ def create(self, env_dir):
6464
self.system_site_packages = False
6565
self.create_configuration(context)
6666
self.setup_python(context)
67+
if not self.upgrade:
68+
self.setup_scripts(context)
6769
if self.with_pip:
6870
self._setup_pip(context)
6971
if not self.upgrade:
70-
self.setup_scripts(context)
7172
self.post_setup(context)
7273
if true_system_site_packages:
7374
# We had set it to False before, now
@@ -158,14 +159,6 @@ def create_configuration(self, context):
158159
f.write('include-system-site-packages = %s\n' % incl)
159160
f.write('version = %d.%d.%d\n' % sys.version_info[:3])
160161

161-
if os.name == 'nt':
162-
def include_binary(self, f):
163-
if f.endswith(('.pyd', '.dll')):
164-
result = True
165-
else:
166-
result = f.startswith('python') and f.endswith('.exe')
167-
return result
168-
169162
def symlink_or_copy(self, src, dst, relative_symlinks_ok=False):
170163
"""
171164
Try symlinking a file, and if that fails, fall back to copying.
@@ -195,9 +188,9 @@ def setup_python(self, context):
195188
binpath = context.bin_path
196189
path = context.env_exe
197190
copier = self.symlink_or_copy
198-
copier(context.executable, path)
199191
dirname = context.python_dir
200192
if os.name != 'nt':
193+
copier(context.executable, path)
201194
if not os.path.islink(path):
202195
os.chmod(path, 0o755)
203196
for suffix in ('python', 'python3'):
@@ -209,26 +202,22 @@ def setup_python(self, context):
209202
if not os.path.islink(path):
210203
os.chmod(path, 0o755)
211204
else:
212-
# See bpo-34011. When using a proper install, we should only need to
213-
# copy the top-level of DLLs.
214-
include = self.include_binary
215-
files = [f for f in os.listdir(dirname) if include(f)]
216-
for f in files:
217-
src = os.path.join(dirname, f)
218-
dst = os.path.join(binpath, f)
219-
if dst != context.env_exe: # already done, above
220-
copier(src, dst)
221-
222-
# When creating from a build directory, we continue to copy all files.
205+
# For normal cases, the venvlauncher will be copied from
206+
# our scripts folder. For builds, we need to copy it
207+
# manually.
223208
if sysconfig.is_python_build(True):
224-
subdir = 'DLLs'
225-
dirname = os.path.join(dirname, subdir)
226-
if os.path.isdir(dirname):
227-
files = [f for f in os.listdir(dirname) if include(f)]
228-
for f in files:
229-
src = os.path.join(dirname, f)
230-
dst = os.path.join(binpath, f)
231-
copier(src, dst)
209+
suffix = '.exe'
210+
if context.python_exe.lower().endswith('_d.exe'):
211+
suffix = '_d.exe'
212+
213+
src = os.path.join(dirname, "venvlauncher" + suffix)
214+
dst = os.path.join(binpath, context.python_exe)
215+
copier(src, dst)
216+
217+
src = os.path.join(dirname, "venvwlauncher" + suffix)
218+
dst = os.path.join(binpath, "pythonw" + suffix)
219+
copier(src, dst)
220+
232221
# copy init.tcl over
233222
for root, dirs, files in os.walk(context.python_dir):
234223
if 'init.tcl' in files:
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Adds support for building a Windows App Store package

Modules/_testcapimodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4960,7 +4960,7 @@ static PyMethodDef TestMethods[] = {
49604960
{"get_mapping_items", get_mapping_items, METH_O},
49614961
{"test_pythread_tss_key_state", test_pythread_tss_key_state, METH_VARARGS},
49624962
{"hamt", new_hamt, METH_NOARGS},
4963-
{"bad_get", bad_get, METH_FASTCALL},
4963+
{"bad_get", (PyCFunction)bad_get, METH_FASTCALL},
49644964
{"EncodeLocaleEx", encode_locale_ex, METH_VARARGS},
49654965
{"DecodeLocaleEx", decode_locale_ex, METH_VARARGS},
49664966
{"get_global_config", get_global_config, METH_NOARGS},

PC/getpathp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,10 +536,16 @@ static _PyInitError
536536
get_program_full_path(const _PyCoreConfig *core_config,
537537
PyCalculatePath *calculate, _PyPathConfig *config)
538538
{
539+
const wchar_t *pyvenv_launcher;
539540
wchar_t program_full_path[MAXPATHLEN+1];
540541
memset(program_full_path, 0, sizeof(program_full_path));
541542

542-
if (!GetModuleFileNameW(NULL, program_full_path, MAXPATHLEN)) {
543+
/* The launcher may need to force the executable path to a
544+
* different environment, so override it here. */
545+
pyvenv_launcher = _wgetenv(L"__PYVENV_LAUNCHER__");
546+
if (pyvenv_launcher && pyvenv_launcher[0]) {
547+
wcscpy_s(program_full_path, MAXPATHLEN+1, pyvenv_launcher);
548+
} else if (!GetModuleFileNameW(NULL, program_full_path, MAXPATHLEN)) {
543549
/* GetModuleFileName should never fail when passed NULL */
544550
return _Py_INIT_ERR("Cannot determine program path");
545551
}

PC/icons/pythonwx150.png

8 KB
Loading

PC/icons/pythonwx44.png

2.18 KB
Loading

PC/icons/pythonx150.png

8.08 KB
Loading

0 commit comments

Comments
 (0)