Skip to content

Commit

Permalink
Fix #166 (#168)
Browse files Browse the repository at this point in the history
* Fix #166
by modifying the permissions in files after pip install them
in site-packages in the natlink install folder.

* make change of acl with cacl.exe independent of language of windows system.
  • Loading branch information
dougransom authored Sep 23, 2023
1 parent dea86ad commit cf90158
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions InstallerSource/inno-setup-natlink.iss
Original file line number Diff line number Diff line change
@@ -1,15 +1,30 @@
;debugging tip
;Run the setup.exe program with /LOG. See inno setup docs.

#define MyGUID "{{dd990001-bb89-11d2-b031-0060088dc929}"
#define Bits "32bit"
#define SitePackagesDir "{app}\site-packages"
#define CoreDir "{app}\site-packages\natlink"
#define DistDir "{app}\dist"
#define WheelPath "{#DistDir}\{#PythonWheelName}"

;a well known SID for all users on a system.
;on an english system, (Get-LocalGroup users).SID will return this SID
#define AllowedUsersSid "S-1-5-32-545"

; It's important to look in the InstallPath subkey to check for installation
#define PythonInstallKey "Software\Python\PythonCore\" + PythonVersion + \
"-32\InstallPath"
#define PythonPathMyAppNameKey "Software\Python\PythonCore\" + PythonVersion + \
"-32\PythonPath\" + MyAppName
[Dirs]
;we would like all users to read and execute these folders.
;note pip replaces with what it thinks the permissions should be
;so we need an extra setp in [Run] to restore all users read and execute.
Name: {#CoreDir}; Permissions: users-readexec
Name: {#SitePackagesDir}; Permissions: users-readexec
Name: {#DistDir}; Permissions: users-readexec


[Setup]
AppId={#MyGUID}
Expand Down Expand Up @@ -92,10 +107,16 @@ Root: HKLM; Subkey: "{#PythonPathMyAppNameKey}"; ValueType: string; ValueData: "
Root: HKCU; Subkey: "{#PythonPathMyAppNameKey}"; ValueType: string; ValueData: "{#SitePackagesDir}"; Flags: uninsdeletekey noerror

[Run]
;debugging tip for this section: Run the setup.exe program with /LOG. See inno setup docs.

;register the pyd for corresponding version of Python
Filename: "{#PythonInstallPath}\\Scripts\\pip.exe"; Parameters: "-m pip install --upgrade pip"; StatusMsg: "Upgrade pip..."
Filename: "{#PythonInstallPath}\\Scripts\\pip.exe"; Parameters: "install --target ""{#SitePackagesDir}"" --upgrade ""{app}/dist/{#PythonWheelName}"" "; StatusMsg: "natlink {#PythonWheelName}"

;pip changes the permissions on files and folders, so we have to redo them. icacls is a built in windows program to change permissions.
;users need read and execute

Filename: "icacls.exe"; Parameters: " ""{#SitePackagesDir}"" /t /grant *{#AllowedUsersSid}:RX "; StatusMsg: "icacls.exe";
Filename: "regsvr32"; Parameters: "-s \""{#CoreDir}\{#NatlinkCorePyd}\""" ; StatusMsg: "regsvr32 {#NatlinkCorePyd}"
Filename: "{#PythonInstallPath}\\Scripts\\pip.exe"; Parameters: "install --upgrade natlinkcore"; StatusMsg: "natlinkcore"

Expand Down

1 comment on commit cf90158

@LexiconCode
Copy link
Member

@LexiconCode LexiconCode commented on cf90158 Sep 23, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One quick question, if the user upgrades pip after the installer has completed for example months later, will this issue reappear?

Please sign in to comment.