The Wayback Machine - https://web.archive.org/web/20211028052328/https://github.com/python/cpython/pull/27889
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-44934: Add optional feature AppendPath to Windows msi installer #27889

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

@bneuburg
Copy link

@bneuburg bneuburg commented Aug 22, 2021

Initial problem

Automatically adding Python to the PATH is convenient for Windows end users; this was achieved by the installer by prepending the Python Install and Scripts dir to PATH. However this might cause conflicts with system executables.

How to reproduce:

  1. Install Python msi system wide
  2. Choose Add Python to environment variables optional features
  3. Install impacket in a system context (e.g. administrativ shell, pip install impacket

Installing impacket in a system context drops - among others - the following Python scripts to the Scripts dir:

  • reg.py
  • ping.py

Some batch scripts using commands like

  • REG ADD HKEY_CURRENT_USER\Console /v Test /d "Test Data"
  • ping domain.controller

that expect to run C:\Windows\System32\reg.exe now run C:\Program Files\Python\Scripts\reg.py.

Conflicts with other use cases

After reporting my problem @zooba reasoned that Python developers might have different versions of Python installed and to make sure they always use the version installed last he chose to prepend those directories instead of appending them to PATH.

Proposed solution

In order to provide system administrators with a way to automatically add Python to PATH by appending it, @zooba suggested to create an command line only separate optional feature for this. Therefore - without any preexisting knowledge of msi or the WiX toolset - I browsed the existing code for the path optional feature and basically duplicated the occurences of that optional feature.

Possible problems

I did not introduce any layout in the GUI of the installer. I also didn't implement any checks if e.g. the path and appendpath optional feature are set simultaneousely when running the installer via CLI, thus a user might have 2 occurences of the install and scripts directory if they chosse to use both flags. @zooba said in the BPO report that this would probably be fine.

Also my PR might be very far from being able to succesfully compile since I have no prior experience of thw WiX toolset and couldn't get a clean build with the provided instructions in Tools/msi/README.txt on one of the free Windows 10 Edge Test VM even before modifying the source code. @zooba suggested to submit this PR anyway since the build pipeline would show if everything builds.

https://bugs.python.org/issue44934

bneuburg added 6 commits Aug 22, 2021
Copy/paste/modify the strings for PrependPathLabel and ShortPrependPath
label to introduce AppendPathLabel and ShortAppendPathLabel
Introduce the AppendPath variable in the file where PrependPath is declared
Assign a regname to the new variable in the OPTIONAL_FEATURES struct of
the main installer application
In order to build the new msi declare it as a package
Add the upcoming appendpath MSI and its systemwide/current user aliases
as a fragment in postinstall.wxs
This new msi is basically just a clone of the path msi with adapted
strings, i.e. replaced occurences of path with analog appendpath versions
@bneuburg bneuburg requested a review from as a code owner Aug 22, 2021
@the-knights-who-say-ni
Copy link

@the-knights-who-say-ni the-knights-who-say-ni commented Aug 22, 2021

Hello, and thanks for your contribution!

I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA).

CLA Missing

Our records indicate the following people have not signed the CLA:

@bneuburg

For legal reasons we need all the people listed to sign the CLA before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue.

If you have recently signed the CLA, please wait at least one business day
before our records are updated.

You can check yourself to see if the CLA has been received.

Thanks again for the contribution, we look forward to reviewing it!

Previously the Scripts and InstallDirectory were appended only for Local Machine installs, but prepended for Current User installs. This changes the current user install to the expected behaviour.
@zooba
Copy link
Member

@zooba zooba commented Aug 26, 2021

We'll also need a NEWS entry for this (click "Details" on the failed check), and add a short writeup to Doc/whatsnew/3.11.rst so that the people who read the docs find out.

@zooba
Copy link
Member

@zooba zooba commented Aug 26, 2021

Probably also worth doing a full text search of the repository for any other references in case they also need updating. Because this generates a file at the end of the deployment process, its name may have leaked all over the place.

@bneuburg
Copy link
Author

@bneuburg bneuburg commented Sep 2, 2021

Probably also worth doing a full text search of the repository for any other references in case they also need updating. Because this generates a file at the end of the deployment process, its name may have leaked all over the place.

Could you elaborate what I should search for exactly?

bneuburg added 4 commits Sep 2, 2021
New command line only option for Windows installer: AppendPath which behaves similar to PrependPath but appends the directories to the path instead of prepending them
Mention the AppendPath command line option for the Windows installer
Add the ApppendPath option to the table of supported command line options
@bneuburg
Copy link
Author

@bneuburg bneuburg commented Sep 2, 2021

We'll also need a NEWS entry for this (click "Details" on the failed check), and add a short writeup to Doc/whatsnew/3.11.rst so that the people who read the docs find out.

Since I currently can only access github from a browser I added the NEWS entry and Windows documentation update from the Web UI, hope it pans out.

@github-actions
Copy link

@github-actions github-actions bot commented Oct 3, 2021

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale label Oct 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants