Skip to content

Expose PyConfig options for isolation and arg parsing.#596

Merged
bsteffensmeier merged 2 commits into
ninia:dev_4.3from
bsteffensmeier:more-pyconfig
Feb 24, 2025
Merged

Expose PyConfig options for isolation and arg parsing.#596
bsteffensmeier merged 2 commits into
ninia:dev_4.3from
bsteffensmeier:more-pyconfig

Conversation

@bsteffensmeier

Copy link
Copy Markdown
Member

This builds on the changes in #586 and further improves the compatibility with the c-api. In that change I hardcoded the option to disable argv parsing however there may be use cases where someone wants to enable that parsing. To keep things consistent with the c-api the option is exposed in Java and Jep will no longer set the value of that option unless it is set in Java.

This also exposes the ability to create an isolated python configuration. For backwards compatibility the default is to use a config which behaves like regular python but the c-api includes a function to create an isolated python so I thought it would be useful to allow that option in Java.

Comment thread src/main/c/Jep/pyembed.c
config.parse_argv = 0;
if (parseArgv >= 0) {
config.parse_argv = 0;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This confuses me. The options are 0 or 1, so how do you set it to 1 with this code? https://docs.python.org/3/c-api/init_config.html#c.PyConfig.parse_argv

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

That is definitely an oversight on my part. Thanks for pointing it out. I've fixed it in the latest commit.

@ndjensen ndjensen left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good.

@bsteffensmeier bsteffensmeier merged commit e751ba0 into ninia:dev_4.3 Feb 24, 2025
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