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

Make post install an executable module #1855

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

Conversation

jenshnielsen
Copy link
Contributor

As discussed in #1850 this means that you can run post install as

python -m win32.lib.postinstall -install

without having to worry about path etc.

Let me know if this is a good location for the post install module.

Manually tested by executing pywin32_postinstall.py from the scripts module and python -m win32.lib.postinstall -install

Parsed arguments are: Namespace(install=True, remove=False, wait=None, silent=False, quiet=False, destination='C:\\Users\\Jens-work\\Miniconda3\\envs\\pywin32dev\\Lib\\site-packages')
Copied pythoncom39.dll to C:\Users\Jens-work\Miniconda3\envs\pywin32dev\pythoncom39.dll
Copied pywintypes39.dll to C:\Users\Jens-work\Miniconda3\envs\pywin32dev\pywintypes39.dll
You do not have the permissions to install COM objects.
The sample COM objects were not registered.
NOTE: PyWin32.chm can not be located, so has not been registered
Registered help file
Pythonwin has been registered in context menu
Can't install shortcuts - 'C:\\Users\\Jens-work\\AppData\\Roaming\\Microsoft\\Windows\\Start Menu\\Programs\\Python 3.9' is not a folder
The pywin32 extensions were successfully installed.

So post install can be executed as

`python -m win32.lib.postinstall`
@mhammond
Copy link
Owner

Thanks for that! I'm a bit short on time currently and planning a new release, so I plan on looking at this after I've done that.

@jenshnielsen
Copy link
Contributor Author

@mhammond Do you think you will have time to review this at some point? Happy to rebase if that is the case

Copy link
Owner

@mhammond mhammond left a comment

Choose a reason for hiding this comment

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

Very very sorry for the delay here, but I don't see a good reason not to go ahead with this.

if not is_bdist_wininst:
uninstall(args.destination)

from win32.lib.postinstall.pywin32_postinstall import main
Copy link
Owner

Choose a reason for hiding this comment

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

Do you mind adding a comment here explaining why this file exists at all, and how the preferred way of running it is now via -m ... etc? And ditto for the other.

@@ -0,0 +1,3 @@
from win32.lib.postinstall.pywin32_postinstall import main
Copy link
Owner

Choose a reason for hiding this comment

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

Do we really need the postinstall intermediate dir? Any reason not to just have pywin32_postinstall.py directly in win32/Lib?

Copy link
Collaborator

@Avasam Avasam Oct 15, 2024

Choose a reason for hiding this comment

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

I think this just acts as an alias for python -m win32.lib.pywin32_postinstall --> python -m win32.lib.postinstall. Not necessary imo.

Even moreso with pywin32.pth pointing to win32\lib, I think you can do python -m pywin32_postinstall

@jenshnielsen
Copy link
Contributor Author

@mhammond no worries I know how much work can be in maintaining an open source project. I will rebase and make the suggested changes asap

@Avasam
Copy link
Collaborator

Avasam commented Apr 14, 2024

@jenshnielsen There has been changes in pywin32_postinstall.py and your PR has conflicts now.

It's probably also a good idea to update documentation referencing the postinstall script.

@Avasam
Copy link
Collaborator

Avasam commented Oct 14, 2024

This is something I've been considering myself now that exe installers are no longer provided, calling setup.py directly is long-deprecated and wheels can't run postinstall scripts.

Ping @jenshnielsen if you're still interested in updating this PR. Otherwise I might pick it up eventually.

@jenshnielsen
Copy link
Contributor Author

@Avasam Sorry this dropped of my radar. Fell free to pick it up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants