]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44934: Add optional feature AppendPath to Windows MSI installer (GH-27889)
authorbneuburg <bastian.neuburger@gmail.com>
Tue, 18 Jan 2022 00:18:44 +0000 (01:18 +0100)
committerGitHub <noreply@github.com>
Tue, 18 Jan 2022 00:18:44 +0000 (00:18 +0000)
The option must be enabled from the command line

Doc/using/windows.rst
Doc/whatsnew/3.11.rst
Misc/NEWS.d/next/Windows/2021-09-01-10-48-11.bpo-44934.W1xPATH.rst [new file with mode: 0644]
Tools/msi/appendpath/appendpath.wixproj [new file with mode: 0644]
Tools/msi/appendpath/appendpath.wxs [new file with mode: 0644]
Tools/msi/appendpath/appendpath_en-US.wxl [new file with mode: 0644]
Tools/msi/bundle/Default.wxl
Tools/msi/bundle/bootstrap/PythonBootstrapperApplication.cpp
Tools/msi/bundle/bundle.targets
Tools/msi/bundle/bundle.wxs
Tools/msi/bundle/packagegroups/postinstall.wxs

index 68ee09c565e21f5d1924a37f192f9a746f27a5e2..041166f4f8584f262da10f71f2d3cb8b138286f2 100644 (file)
@@ -165,9 +165,13 @@ of available options is shown below.
 | CompileAll                | Compile all ``.py`` files to         | 0                        |
 |                           | ``.pyc``.                            |                          |
 +---------------------------+--------------------------------------+--------------------------+
-| PrependPath               | Add install and Scripts directories  | 0                        |
-|                           | to :envvar:`PATH` and ``.PY`` to     |                          |
-|                           | :envvar:`PATHEXT`                    |                          |
+| PrependPath               | Prepend install and Scripts          | 0                        |
+|                           | directories  to :envvar:`PATH` and   |                          |
+|                           | add ``.PY`` to :envvar:`PATHEXT`     |                          |
++---------------------------+--------------------------------------+--------------------------+
+| AppendPath                | Append install and Scripts           | 0                        |
+|                           | directories  to :envvar:`PATH` and   |                          |
+|                           | add ``.PY`` to :envvar:`PATHEXT`     |                          |
 +---------------------------+--------------------------------------+--------------------------+
 | Shortcuts                 | Create shortcuts for the interpreter,| 1                        |
 |                           | documentation and IDLE if installed. |                          |
index 96d6e26709342c0c488b19a42226f57b545682a3..5563e3d84de6d1a27a7d4491feb7d95429f1afd3 100644 (file)
@@ -200,6 +200,12 @@ Other CPython Implementation Changes
   have been removed as their values can be derived from ``exc_value``.
   (Contributed by Irit Katriel in :issue:`45711`.)
 
+* A new command line option for the Windows installer ``AppendPath`` has beend added.
+  It behaves similiar to ``PrependPath`` but appends the install and scripts directories
+  instead of prepending it.
+  (Contributed by Bastian Neuburger in :issue:`44934`.)
+
+
 New Modules
 ===========
 
diff --git a/Misc/NEWS.d/next/Windows/2021-09-01-10-48-11.bpo-44934.W1xPATH.rst b/Misc/NEWS.d/next/Windows/2021-09-01-10-48-11.bpo-44934.W1xPATH.rst
new file mode 100644 (file)
index 0000000..0f1c25a
--- /dev/null
@@ -0,0 +1 @@
+The installer now offers a command-line only option to add the installation directory to the end of :envvar:`PATH` instead of at the start.
diff --git a/Tools/msi/appendpath/appendpath.wixproj b/Tools/msi/appendpath/appendpath.wixproj
new file mode 100644 (file)
index 0000000..8970876
--- /dev/null
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+    <PropertyGroup>
+        <ProjectGuid>{12B59A06-37CC-4558-A9C8-DAE922E64EF3}</ProjectGuid>
+        <SchemaVersion>2.0</SchemaVersion>
+        <OutputName>appendpath</OutputName>
+        <OutputType>Package</OutputType>
+        <SuppressIces>ICE71</SuppressIces>
+    </PropertyGroup>
+    <Import Project="..\msi.props" />
+    <ItemGroup>
+        <Compile Include="*.wxs" />
+    </ItemGroup>
+    <ItemGroup>
+        <EmbeddedResource Include="*.wxl" />
+    </ItemGroup>
+    
+    <Import Project="..\msi.targets" />
+</Project>
diff --git a/Tools/msi/appendpath/appendpath.wxs b/Tools/msi/appendpath/appendpath.wxs
new file mode 100644 (file)
index 0000000..b972f61
--- /dev/null
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
+    <Product Id="*" Language="!(loc.LCID)" Name="!(loc.Title)" Version="$(var.Version)" Manufacturer="!(loc.Manufacturer)" UpgradeCode="$(var.UpgradeCode)">
+        <Package InstallerVersion="300" Compressed="yes" InstallScope="perUser" Platform="$(var.Platform)" />
+        
+        <PropertyRef Id="UpgradeTable" />
+        <PropertyRef Id="REGISTRYKEY" />
+        
+        <Feature Id="DefaultFeature" AllowAdvertise="no" Title="!(loc.Title)" Description="!(loc.Description)">
+            <Component Id="AppendPath_CU" Directory="InstallDirectory" Guid="*">
+                <Condition>NOT ALLUSERS=1</Condition>
+                <RegistryKey Root="HKCU" Key="[REGISTRYKEY]">
+                    <RegistryValue KeyPath="yes" Key="InstalledFeatures" Name="$(var.OptionalFeatureName)" Value="$(var.Version)" Type="string" />
+                </RegistryKey>
+                
+                <CreateFolder Directory="Scripts" />
+                <RemoveFolder Id="Remove_Scripts_CU" Directory="Scripts" On="uninstall" />
+                
+                <Environment Id="PATH_CU" Action="set" Name="PATH" Part="last" Value="[InstallDirectory]" />
+                <Environment Id="SCRIPTS_PATH_CU" Action="set" Name="PATH" Part="last" Value="[Scripts]" />
+            </Component>
+            <Component Id="AppendPath_LM" Directory="InstallDirectory" Guid="*">
+                <Condition>ALLUSERS=1</Condition>
+                <RegistryKey Root="HKLM" Key="[REGISTRYKEY]">
+                    <RegistryValue KeyPath="yes" Key="InstalledFeatures" Name="$(var.OptionalFeatureName)" Value="$(var.Version)" Type="string" />
+                </RegistryKey>
+                
+                <CreateFolder Directory="Scripts" />
+                <RemoveFolder Id="Remove_Scripts_LM" Directory="Scripts" On="uninstall" />
+                
+                <Environment Id="PATH_LM" Action="set" Name="PATH" Part="last" Value="[InstallDirectory]" System="yes" />
+                <Environment Id="SCRIPTS_PATH_LM" Action="set" Name="PATH" Part="last" Value="[Scripts]" System="yes" />
+                <Environment Id="PY_PATHEXT_LM" Action="set" Name="PATHEXT" Part="last" Value=".PY" System="yes" />
+                <Environment Id="PYW_PATHEXT_LM" Action="set" Name="PATHEXT" Part="last" Value=".PYW" System="yes" />
+            </Component>
+        </Feature>
+    </Product>
+</Wix>
+
diff --git a/Tools/msi/appendpath/appendpath_en-US.wxl b/Tools/msi/appendpath/appendpath_en-US.wxl
new file mode 100644 (file)
index 0000000..19a2e77
--- /dev/null
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<WixLocalization Culture="en-us" xmlns="http://schemas.microsoft.com/wix/2006/localization">
+    <String Id="Descriptor">Append to Path</String>
+    <String Id="ShortDescriptor">AppendPath</String>
+    <String Id="NoPython">No !(loc.ProductName) installation was detected.</String>
+</WixLocalization>
index 791ce6eab74745c756a9b0ce8f22b6c11367083e..053306b0d7dcf1372431eaec3a93f1af2904f81f 100644 (file)
@@ -84,6 +84,8 @@ Select Customize to review current options.</String>
   <String Id="ShortcutsLabel">Create shortcuts for installed applications</String>
   <String Id="PrependPathLabel">Add Python to &amp;environment variables</String>
   <String Id="ShortPrependPathLabel">Add &amp;Python [ShortVersion] to PATH</String>
+  <String Id="AppendPathLabel">Append Python to &amp;environment variables</String>
+  <String Id="ShortAppendPathLabel">Append &amp;Python [ShortVersion] to PATH</String>
   <String Id="InstallAllUsersLabel">Install for &amp;all users</String>
   <String Id="InstallLauncherAllUsersLabel">for &amp;all users (requires elevation)</String>
   <String Id="ShortInstallLauncherAllUsersLabel">Install &amp;launcher for all users (recommended)</String>
index 3c54e401330cfde05f6a2fcb1345380706224809..fdc2a21d83d5f3dc411aa83426f46506143d3589 100644 (file)
@@ -205,6 +205,7 @@ static struct { LPCWSTR regName; LPCWSTR variableName; } OPTIONAL_FEATURES[] = {
     { L"exe", L"Include_exe" },
     { L"lib", L"Include_lib" },
     { L"path", L"PrependPath" },
+    { L"appendpath", L"AppendPath" },
     { L"pip", L"Include_pip" },
     { L"tcltk", L"Include_tcltk" },
     { L"test", L"Include_test" },
index f882d2ee1f0c2b838d494c4fa9e6c1fe8b819acd..5d8ae6c1d7cbaa7e5c66763b7fc7d4b206cd45a0 100644 (file)
@@ -67,6 +67,7 @@
         <Package Include="..\exe\exe*.wixproj" />
         <Package Include="..\lib\lib*.wixproj" />
         <Package Include="..\path\path*.wixproj" />
+        <Package Include="..\appendpath\appendpath*.wixproj" />
         <Package Include="..\pip\pip*.wixproj" />
         <Package Include="..\tcltk\tcltk*.wixproj" />
         <Package Include="..\test\test*.wixproj" />
     </Target>
     
     <Import Project="..\msi.targets" />
-</Project>
\ No newline at end of file
+</Project>
index e2f871889340fb6bbb8f96efb2ec16a8a892846d..a145d840d3305d0010db7991ab0734d015a8d53d 100644 (file)
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0"?>
 <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
      xmlns:bal="http://schemas.microsoft.com/wix/BalExtension"
      xmlns:dep="http://schemas.microsoft.com/wix/DependencyExtension">
@@ -87,6 +87,7 @@
     <Variable Name="AssociateFiles" Value="1" bal:Overridable="yes" />
     <Variable Name="Shortcuts" Value="1" bal:Overridable="yes" />
     <Variable Name="PrependPath" Value="0" bal:Overridable="yes" />
+    <Variable Name="AppendPath" Value="0" bal:Overridable="yes" />
     <Variable Name="CompileAll" Value="0" bal:Overridable="yes" />
     
     <Variable Name="SimpleInstall" Value="0" bal:Overridable="yes" />
index 11ab673907054dc7d474287605e10837ee933127..64f42dd30e8ba0422aa2b3ee936edca9aca81d56 100644 (file)
                 <MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
                 <MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
             </MsiPackage>
+
+            <MsiPackage Id="appendpath_AllUsers"
+                        SourceFile="appendpath.msi"
+                        Compressed="$(var.CompressMSI)"
+                        DownloadUrl="$(var.DownloadUrl)"
+                        ForcePerMachine="yes"
+                        InstallCondition="InstallAllUsers and AppendPath and not LauncherOnly">
+                <MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
+                <MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
+            </MsiPackage>
+            <MsiPackage Id="appendpath_JustForMe"
+                        SourceFile="appendpath.msi"
+                        Compressed="$(var.CompressMSI)"
+                        DownloadUrl="$(var.DownloadUrl)"
+                        ForcePerMachine="no"
+                        InstallCondition="not InstallAllUsers and AppendPath and not LauncherOnly">
+                <MsiProperty Name="TARGETDIR" Value="[TargetDir]" />
+                <MsiProperty Name="OPTIONALFEATURESREGISTRYKEY" Value="[OptionalFeaturesRegistryKey]" />
+            </MsiPackage>
+
+
             
             <?define CompileAllCommand=-E -s -Wi "[TargetDir]\Lib\compileall.py" -f -x "bad_coding|badsyntax|site-packages|py2_|lib2to3\\tests|venv\\scripts" "[TargetDir]\Lib"?>
             <ExePackage Id="compileall_AllUsers"
                         InstallCondition="not InstallAllUsers and CompileAll and not LauncherOnly" />
         </PackageGroup>
     </Fragment>
-</Wix>
\ No newline at end of file
+</Wix>