Skip to content

Commit 0430e68

Browse files
committed
Initial code import. For earlier history, see https://github.com/zooba/pymanager
0 parents  commit 0430e68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+39773
-0
lines changed

.github/workflows/build.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: 'Build and Test'
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
env:
10+
PIP_DISABLE_PIP_VERSION_CHECK: true
11+
PIP_NO_COLOR: true
12+
PIP_NO_INPUT: true
13+
PIP_PROGRESS_BAR: off
14+
PIP_REQUIRE_VIRTUALENV: false
15+
PIP_VERBOSE: true
16+
PYMSBUILD_VERBOSE: true
17+
18+
19+
jobs:
20+
build:
21+
runs-on: windows-latest
22+
23+
steps:
24+
- uses: actions/checkout@v2
25+
26+
- name: 'Remove existing PyManager install'
27+
run: |
28+
# Ensure we aren't currently installed
29+
$msix = Get-AppxPackage PythonSoftwareFoundation.PythonManager -EA SilentlyContinue
30+
if ($msix) {
31+
"Removing $($msix.Name)"
32+
Remove-AppxPackage $msix
33+
}
34+
shell: powershell
35+
36+
- name: Set up Python 3.14
37+
uses: actions/setup-python@v2
38+
with:
39+
python-version: 3.14-dev
40+
41+
- name: Install build dependencies
42+
run: python -m pip install pymsbuild
43+
44+
- name: 'Install test runner'
45+
run: python -m pip install pytest
46+
47+
- name: 'Build test module'
48+
run: python -m pymsbuild -c _msbuild_test.py
49+
50+
- name: 'Run pre-test'
51+
run: python -m pytest -vv
52+
53+
- name: 'Build package'
54+
run: python make.py
55+
env:
56+
PYMSBUILD_TEMP_DIR: ${{ runner.temp }}/bin
57+
PYMSBUILD_DIST_DIR: ${{ runner.temp }}/dist
58+
PYMSBUILD_LAYOUT_DIR: ${{ runner.temp }}/layout
59+
TEST_MSIX_DIR: ${{ runner.temp }}/test_msix
60+
61+
- name: 'Build MSIX package'
62+
run: python make-msix.py
63+
env:
64+
PYMSBUILD_TEMP_DIR: ${{ runner.temp }}/bin
65+
PYMSBUILD_DIST_DIR: ${{ runner.temp }}/dist
66+
PYMSBUILD_LAYOUT_DIR: ${{ runner.temp }}/layout
67+
TEST_MSIX_DIR: ${{ runner.temp }}/test_msix
68+
69+
- name: 'Build MSI package'
70+
run: python make-msi.py
71+
env:
72+
PYMSBUILD_TEMP_DIR: ${{ runner.temp }}/bin
73+
PYMSBUILD_DIST_DIR: ${{ runner.temp }}/dist
74+
PYMSBUILD_LAYOUT_DIR: ${{ runner.temp }}/layout
75+
TEST_MSIX_DIR: ${{ runner.temp }}/test_msix
76+
77+
- name: 'Register unsigned MSIX'
78+
run: |
79+
$msix = dir "${env:PYMSBUILD_DIST_DIR}\*.msix" `
80+
| ?{ -not ($_.BaseName -match '.+-store') } `
81+
| select -first 1
82+
cp $msix "${msix}.zip"
83+
Expand-Archive "${msix}.zip" (mkdir -Force $env:TEST_MSIX_DIR)
84+
Add-AppxPackage -Register "${env:TEST_MSIX_DIR}\appxmanifest.xml"
85+
Get-AppxPackage PythonSoftwareFoundation.PythonManager
86+
env:
87+
PYMSBUILD_TEMP_DIR: ${{ runner.temp }}/bin
88+
PYMSBUILD_DIST_DIR: ${{ runner.temp }}/dist
89+
PYMSBUILD_LAYOUT_DIR: ${{ runner.temp }}/layout
90+
TEST_MSIX_DIR: ${{ runner.temp }}/test_msix
91+
shell: powershell
92+
93+
- name: 'Ensure global commands are present'
94+
run: |
95+
gcm pymanager
96+
gcm pywmanager
97+
# These are likely present due to the machine configuration,
98+
# but we'll check for them anyway.
99+
gcm py
100+
gcm python
101+
gcm pyw
102+
gcm pythonw
103+
104+
- name: 'Show help output'
105+
run: pymanager
106+
107+
- name: 'Install default runtime'
108+
run: pymanager install default
109+
env:
110+
PYMANAGER_DEBUG: true
111+
112+
- name: 'List installed runtimes'
113+
run: pymanager list
114+
env:
115+
PYMANAGER_DEBUG: true
116+
117+
- name: 'List installed runtimes (legacy)'
118+
run: pymanager --list-paths
119+
env:
120+
PYMANAGER_DEBUG: true
121+
122+
- name: 'Launch default runtime'
123+
run: pymanager exec -m site
124+
125+
- name: 'Emulate first launch'
126+
run: |
127+
$i = (mkdir -force test_installs)
128+
ConvertTo-Json @{
129+
install_dir="$i";
130+
download_dir="$i\_cache";
131+
global_dir="$i\_bin";
132+
} | Out-File $env:PYTHON_MANAGER_CONFIG -Encoding utf8
133+
pymanager exec
134+
if ($?) { pymanager list }
135+
env:
136+
PYTHON_MANAGER_INCLUDE_UNMANAGED: false
137+
PYTHON_MANAGER_CONFIG: .\test-config.json
138+
PYMANAGER_DEBUG: true
139+
140+
- name: 'Offline bundle download and install'
141+
run: |
142+
pymanager list --online 3 3-32 3-64 3-arm64
143+
pymanager install --download .\bundle 3 3-32 3-64 3-arm64
144+
pymanager list --source .\bundle
145+
pymanager install --source .\bundle 3 3-32 3-64 3-arm64
146+
env:
147+
PYMANAGER_DEBUG: true
148+
149+
- name: 'Remove MSIX'
150+
run: |
151+
Get-AppxPackage PythonSoftwareFoundation.PythonManager | Remove-AppxPackage
152+
shell: powershell

.gitignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/bin/
2+
/build/
3+
/dist/
4+
/download/
5+
/env*/
6+
/python-manager/
7+
/pythons/
8+
9+
# Can't seem to stop WiX from creating this directory...
10+
/src/pymanager/obj
11+
12+
*.exe
13+
*.pyc
14+
*.pyd
15+
*.pdb
16+
*.so
17+
*.dylib
18+
*.msix
19+
*.appxsym
20+
*.zip
21+
*.msi
22+
__pycache__

LICENSE

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
PYTHON SOFTWARE FOUNDATION LICENSE VERSION 2
2+
--------------------------------------------
3+
4+
1. This LICENSE AGREEMENT is between the Python Software Foundation
5+
("PSF"), and the Individual or Organization ("Licensee") accessing and
6+
otherwise using this software ("Python") in source or binary form and
7+
its associated documentation.
8+
9+
2. Subject to the terms and conditions of this License Agreement, PSF hereby
10+
grants Licensee a nonexclusive, royalty-free, world-wide license to reproduce,
11+
analyze, test, perform and/or display publicly, prepare derivative works,
12+
distribute, and otherwise use Python alone or in any derivative version,
13+
provided, however, that PSF's License Agreement and PSF's notice of copyright,
14+
i.e., "Copyright (c) 2001 Python Software Foundation; All Rights Reserved"
15+
are retained in Python alone or in any derivative version prepared by Licensee.
16+
17+
3. In the event Licensee prepares a derivative work that is based on
18+
or incorporates Python or any part thereof, and wants to make
19+
the derivative work available to others as provided herein, then
20+
Licensee hereby agrees to include in any such work a brief summary of
21+
the changes made to Python.
22+
23+
4. PSF is making Python available to Licensee on an "AS IS"
24+
basis. PSF MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR
25+
IMPLIED. BY WAY OF EXAMPLE, BUT NOT LIMITATION, PSF MAKES NO AND
26+
DISCLAIMS ANY REPRESENTATION OR WARRANTY OF MERCHANTABILITY OR FITNESS
27+
FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF PYTHON WILL NOT
28+
INFRINGE ANY THIRD PARTY RIGHTS.
29+
30+
5. PSF SHALL NOT BE LIABLE TO LICENSEE OR ANY OTHER USERS OF PYTHON
31+
FOR ANY INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES OR LOSS AS
32+
A RESULT OF MODIFYING, DISTRIBUTING, OR OTHERWISE USING PYTHON,
33+
OR ANY DERIVATIVE THEREOF, EVEN IF ADVISED OF THE POSSIBILITY THEREOF.
34+
35+
6. This License Agreement will automatically terminate upon a material
36+
breach of its terms and conditions.
37+
38+
7. Nothing in this License Agreement shall be deemed to create any
39+
relationship of agency, partnership, or joint venture between PSF and
40+
Licensee. This License Agreement does not grant permission to use PSF
41+
trademarks or trade name in a trademark sense to endorse or promote
42+
products or services of Licensee, or any third party.
43+
44+
8. By copying, installing or otherwise using Python, Licensee
45+
agrees to be bound by the terms and conditions of this License
46+
Agreement.

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# Python Install Manager
2+
3+
This is the source code for the Python Install Manager app.
4+
5+
For information about how to use the Python install manager,
6+
including troubleshooting steps,
7+
please refer to the documentation at
8+
[docs.python.org/using/windows](https://docs.python.org/3.14/using/windows.html).
9+
10+
The original PEP leading to this tool was
11+
[PEP 773](https://peps.python.org/pep-0773/).
12+
13+
14+
# Build
15+
16+
To build and run locally requires [`pymsbuild`](https://pypi.org/project/pymsbuild)
17+
and a Visual Studio installation that includes the C/C++ compilers.
18+
19+
```
20+
> python -m pip install pymsbuild
21+
> python -m pymsbuild
22+
> python-manager\py.exe ...
23+
```
24+
25+
Any modification to a source file requires rebuilding.
26+
The `.py` files are packaged into an extension module.
27+
However, see the following section on tests, as test runs do not require a full
28+
build.
29+
30+
For additional output, set `%PYMANAGER_DEBUG%` to force debug-level output.
31+
This is the equivalent of passing `-vv`, though it also works for contexts that
32+
do not accept options (such as launching a runtime).
33+
34+
# Tests
35+
36+
To run the test suite locally:
37+
38+
```
39+
> python -m pip install pymsbuild pytest
40+
> python -m pymsbuild -c _msbuild_test.py
41+
> python -m pytest
42+
```
43+
44+
This builds the native components separately so that you can quickly iterate on
45+
the Python code. Any updates to the C++ files will require running the
46+
``pymsbuild`` step again.
47+
48+
# Package
49+
50+
To produce an (almost) installer app package:
51+
52+
```
53+
> python -m pip install pymsbuild
54+
> python make-all.py
55+
```
56+
57+
This will rebuild the project and produce MSIX, APPXSYM and MSI packages.
58+
59+
You will need to sign the MSIX package before you can install it. This can be a
60+
self-signed certificate, but it must be added to your Trusted Publishers.
61+
Alternatively, rename the file to ``.zip`` and extract it to a directory, and
62+
run ``Add-AppxPackage -Register <path to dir>\appxmanifest.xml`` to do a
63+
development install. This should add the global aliases and allow you to test
64+
as if it was properly installed.
65+
66+
# Contributions
67+
68+
Contributions are welcome under all the same conditions as for CPython.
69+
70+
# Release Schedule
71+
72+
As this project is currently considered to be in prerelease stage,
73+
the release schedule is "as needed".
74+
75+
The release manager for the Python Install Manager on Windows is whoever is the
76+
build manager for Windows for CPython.
77+
78+
# Copyright and License Information
79+
80+
Copyright © 2025 Python Software Foundation. All rights reserved.
81+
82+
See the `LICENSE <https://github.com/python/pymanager/blob/main/LICENSE>`_ for
83+
information on the history of this software, terms & conditions for usage, and a
84+
DISCLAIMER OF ALL WARRANTIES.
85+
86+
All trademarks referenced herein are property of their respective holders.

0 commit comments

Comments
 (0)