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 pywin32_postinstall and pywin32_testall into Console Scripts #2408

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

Conversation

Avasam
Copy link
Collaborator

@Avasam Avasam commented Oct 15, 2024

Probably a good idea to get postinstall tests first: #2392

Closes #1855 by obsoleting it. It integrates the same idea of moving the script into a pywin32 package so it can be run as a module (python -m win32.scripts.pywin32_postinstall -install), but with far less changes.
It also registers it as a console script, which means users can simply call pywin32_postinstall -install.

The same was done for pywin32_testall since it was also already shipped as a Script.

I've been doing some reading and if this works, it should be a really clean solution.
Doc: https://setuptools.pypa.io/en/latest/userguide/entry_point.html#console-scripts
Results:
image

Comment on lines +2225 to +2229
# This adds the scripts under Python3XX/Scripts, but doesn't actually do much
scripts=[
"win32/scripts/pywin32_postinstall.py",
"win32/scripts/pywin32_testall.py",
],
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I'm keeping this for now as to not break some poor sysadmin's workflow of looking in Python's Scripts folder 😉 (then again, they were probably using .exe installers, but it's barely 4 lines to keep the support)

@Avasam Avasam marked this pull request as ready for review October 18, 2024 17:33
@Avasam Avasam force-pushed the console_scripts branch 2 times, most recently from 2bda609 to 31eb27c Compare December 13, 2024 02:59
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.

I don't understand how the commit message relates to this PR, nor how the post_install script is run automatically?

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 14, 2024

nor how the postinstall script is run automatically?

It doesn't (and can't when shipped as a wheel due to the current wheel specifications). This is simply an easier way for users to run the postinstall script without having to know or navigate to their Python install's scripts or lib folder.

It integrates the same idea as #1855 of moving the script into a pywin32 package so it can be run as a module (python -m win32.scripts.pywin32_postinstall -install), but with far less changes.
It also registers it as a console script, which means users can simply call pywin32_postinstall -install.

The same was done for pywin32_testall since it was also already shipped as a Script.

(I've updated the PR description with this explanation)

@@ -52,7 +52,7 @@ jobs:
- name: Run tests
# Run the tests directly from the source dir so support files (eg, .wav files etc)
# can be found - they aren't installed into the Python tree.
run: python pywin32_testall.py -v -skip-adodbapi
run: python -m win32.scripts.pywin32_testall -v -skip-adodbapi
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Suggested change
run: python -m win32.scripts.pywin32_testall -v -skip-adodbapi
run: python win32/scripts/pywin32_testall.py -v -skip-adodbapi

The failing test https://github.com/mhammond/pywin32/actions/runs/12308761196/job/34354669586?pr=2408#step:7:316 and comment

# Run the tests directly from the source dir so support files (eg, .wav files etc)
# can be found - they aren't installed into the Python tree.

tell me that it maybe didn't even make sense that the test was shipped in the first place (or could be modified to skip some tests when not run from source)

@Avasam
Copy link
Collaborator Author

Avasam commented Dec 24, 2024

I fixed the location reference in pywin32_testall.py and now it's all passing ! I'll try to get #2392 working as well for safety.

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.

2 participants