-
Notifications
You must be signed in to change notification settings - Fork 83
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
Port ctypesgen to argparse #161
Conversation
Thanks for re-running CI. Apparently |
Many thanks also for this contribution! I do not feel that alone anymore :-) . |
I have now applied black's patch. |
I've been listening to this conversation for a bit, and have some concerns about breaking existing code with radical (even if needed) changes.
If this truly has no behavioral effects, then wonderful!!
If not, then I would counsel caution concerning changes in something as basic and ubiquitous as strings. Don't misunderstand me - I dislike the current implementation...
Is this something which can be turned off or on by the user?
If not, can it be made so?
Thanks!
…On Sun, Nov 27, 2022, at 9:36 AM, Nicklas Larsson wrote:
Many thanks also for this contribution! I do not feel that alone anymore :-) .
I'd appreciate if you'd make Black content (even if I understand why you prefer keeping your one-line solution in this case).
—
Reply to this email directly, view it on GitHub <#161 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AAJTJI4ZAGJDEI7UP2QENLLWKOEYPANCNFSM6AAAAAASLUPSOA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
--
Alan Robertson
***@***.***
|
@Alan-R I think you are referring to the other PR #162, right? Assuming that's the case:
The strings PR does have intentional behavioral effects in that input strings need to be encoded excplicitly, and output strings need to be casted and decoded. It deliberately is a breaking change, and has been clearly described as such.
It's not optional ATM. I belive making it so would substantially complicate both the implementation and maintenance of ctypesgen. This PR here, on the other hand, should be much less controversial. It only moves away from a deprecated module and removes some code that is defunct (and perhaps always has been). That said, I would be glad if other users of ctypesgen could review and test the two changes and give their feedback. |
Unfortunately, from what i have seen on this project,
Absolutely makes sense! ❤️ As a maintainer yourself, Here's an idea.
...can understand the parts being modified in this PR / PR #162 , to such an extent that, ...and also commit to fixing any issue in the near future that might pop-up due to this PR / PR #162. @mara004 What do you think? PS: i will review the changes in this PR and PR #162 to the best of my knowledge this weekend. |
@TheCodeArtist I understand the issue with "drive-by" changes and the quest for continued maintenance. But there are some problems with what you're asking for, too:
It is however my intent is to continue to help with ctypesgen while I need it and have the required time/energy/knowledge. If any really serious problems should arise, then it's still possible to just revert the change and ask for a new PR to re-do it cleanly. Another note: If the requirements for a contribution are set too high, ctypesgen will become even more outdated over time and might eventually become unusable (e. g. if Python decide to get rid of optparse). |
I think this change to argparse is in perfectly in order. It is only a question of time before optparse will be gone. (A situation I found myself in recently with old code and Python 3.11). Besides there will not be no significant breaking changes for users. |
Thank You. ❤️ That's all one can ask/hope for.
Ya. Hopefully no other changes on top. 🤞
Absolutely! |
@nilason Thanks, take your time :) |
FYI, I recently had a conversation with Despite the warning on the documentation, PEP 594 lists optparse among the modules to keep ("Withdrawn deprecations"), and importing optparse does not even raise a deprecation warning. Apparently, it was/is disputed upstream whether optparse should be deprecated at all. Footnotes
|
This PR is open since Nov 2022, i. e. >6 months as of this writing. Any progress regarding the merge decision, also concerning #162? The thing is, I'd like to make some more changes on behalf of pypdfium2 (e.g. pypdfium2-team/pypdfium2#215) that I'm not able to isolate into separate master-based branches as they interfere with the same code areas as these patches. That said, the attempt to upstream the changes is getting an increasing burden, so I might eventually prefer to work independently in a fork that would enable me to apply more radical changes at a higher pace. |
I'm awfully sorry for this totally unintended delay into looking looking at this. Please rebase after merge of #166 .
That would be very unfortunate, better to focus the VERY few dev resources available/dedicated in one place. If nothing unexpected falls from above, I'll look at this the next few days. |
Thanks, didn't expect such a quick reply! Unfortunately I now realize I have already gone down experimenting in my pypdfium2 branch a bit too deeply. I can yet try to split out upstreamable patches for pypdfium2-team/pypdfium2#178 The problem is that ctypesgen has become a bit of a mess, so theoretically I'd like some cleanup and more radical, backwards incompatible changes, but that would be controversial and extremely hard to do with distinct PRs, meaning a lot more work and delay. |
It was a pretty straight forward rebase, with the minor addition of following changes: --- a/ctypesgen/__main__.py
+++ b/ctypesgen/__main__.py
@@ -243,8 +243,7 @@ def main(givenargs=None):
default=False,
help="Do not support extra C types built in to Python",
)
- op.add_option(
- "",
+ parser.add_argument(
"--no-load-library",
action="store_true",
dest="no_load_library",
-- but for some, to me, unknown reason I wasn't able to push the commits to your fork. Otherwise it looks good to me and passed all test I could throw at it without regression. |
That's strange, I don't know the reason either. I almost always permit pushes by project members when submitting a PR. |
Done, hope it works now. When you merge, please squash the commits. Thanks! |
@mara004 Thanks for your contribution! |
Thanks for merging! |
(options, args) = op.parse_args(givenargs) | ||
options.headers = args | ||
args.compile_libdirs += args.universal_libdirs | ||
args.runtime_libdirs += args.universal_libdirs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Turns out python list +=
actually mutates the list on the left (instead of making a new list), which can be problematic when ctypesgen is called repeatedly through the API: If the default []
is used, it is modified, so the next run's default compile/runtime libdirs would retain the previous run's universal libdirs.
Python's behavior of a += b
modifying while a = a + b
does not feels slightly confusing, though. Normally you'd expect both syntaxes to do the same thing.
Amends ctypesgen#161 See ctypesgen#161 (comment) for explanation
Amends #161 See #161 (comment) for explanation
This would address #159
It's still in an early state and I haven't tested most options yet, but the basic usage appears to work (and the test suite passes).