-
Notifications
You must be signed in to change notification settings - Fork 807
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
Installer should not create win32com/gen_py folder if it can't be written to by non-elevated processes #1143
Comments
It seems this folder -- |
Alternatively, deleting that directory should also work - win32com should then try and use the temp dir. I'll rename this issue to reflect that lib\site-packages\win32com\gen_py shouldn't be created by the installer if it is read-only for non-elevated processes. |
I think giving your regular user account full control over gen_py should also work; I just tried it. I figured if I was going to delete the folder I might as well try something less drastic. Obviously not a general solution. |
I'm also affected by this and don't have admin privileges, so none of the fixes help me. What environment variable do I set to control where the I've also posted this a question to StackOverflow (https://stackoverflow.com/q/65234005/2111778) |
All the logic exists in https://github.com/mhammond/pywin32/blob/master/com/win32com/__init__.py - look for |
I figured out the solution which is to set %TEMP%. I also wrote so much on StackOverflow |
Thanks for getting back! You mean |
Hi, we had the same problem in our company environment. During the installation of our product the gen_py folder was created by the installing admin and then a non admin user got an error using gen_py. I'll fixed this with a temporary write in my fork with commit e735c2d. Not beautiful but working. |
Thanks, but I understand that problem - just not clear how to solve it without something like your patch, which I'm not that keen on - I'd probably prefer something like having the installer not create it in the first place and have win32com.init check - that would at least only be a read in the general case. I'm not super keen on that though because it might still have the same issue in some cases (eg, if a first run outside the installer happened to be by an admin user, non-admin users would suffer the same fate). It might instead be better to deprecate having it anywhere other than %TEMP%. The comments above made me think that @xjcl had a slightly different problem and I was trying to confirm that. |
|
Maybe the
Generation simply tries to write to the locations in |
That sounds like a can of worms for little value, particularly when writing (eg, would we try and write to every location and take the first writable one? That non-determinism seems problematic. If not, then how would that admin one be setup? I just don't see the use-case that makes these complications worthwhile. That said though, I guess I'd review a PR which addressed those kinds of issues. |
Yes, the generation simply would go (only) to the first location which is successfully writable - trying the admin / install location first
Its deterministic - the shared install / admin location write would be preferred on write (but can principally be overriden for loading from user location.) Initial setup doesn't matter much: could be either delayed to the first generation; or there could be even a simple static win32com/gen_py/ folder installation ( with The approach is similar to sys.path, with system + user site installations. %PATH% mechanism, win32comext joining win32com etc. The extra complexity probably is: The for loop trying the generation location
So the alternative would be the single user writable location without sharing - must exist and be writable. %TEMP% is subject to random cleanup - so the application code must always ensure automatic re-creation. |
What I mean was that it's only deterministic while run with the same permissions - the initial problem here is that it's first run by a user with admin permissions then later run without them. IOW, which directory is writable can change from invocation to invocation, which doesn't seem ideal.
Yeah, good point - |
+1 for |
I seem to be having a problem with my install, though I installed from the most recent (correct) binary.
I am running Windows 10 64bit, Python 3.6.4 32bit, and have installed PyWin32 221 32bit from the exe.
Running the testall.py script (as well as a simple outlook script I was trying) results in a file not found error for a dicts.dat file. Navigating to the gen_py folder, I find that it is entirely empty. I've included the full trace below.
Can anyone figure out what I've done wrong?
The text was updated successfully, but these errors were encountered: