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

Drop Python built-in pwd module support #1883

Merged
merged 3 commits into from Oct 12, 2021
Merged

Conversation

ryanking13
Copy link
Member

This PR drops Python built-in pwd module support.
The pwd module is a Unix specific module which provides access to unix user account and passwd database.

Emscripten does not support pwd related syscalls (there is no user account in browser environment),
so currently calling pwd methods raises an error:

image

As CPython supports non-Unix environments (e.g. Windows), I believe dropping pwd module will cause no bad side effects.
I looked for some cases where CPython import pwd module. It handles error when pwd module is not available:

Note that other Unix specific modules like grp, spwd, syslog are already not included in pyodide.

This resolves #1857, so I think this is a fix.

@hoodmane
Copy link
Member

Thanks @ryanking13!

I was wondering if you could use Setup.local to do this rather than patching Setup but I found the following text in the docs:

you'll still have to edit Setup if you want to disable modules that are enabled by default, or if such modules need non-standard options.

Not sure if this is current info but I think it is and it means this is the right way to get rid of pwd.

@ryanking13
Copy link
Member Author

ryanking13 commented Oct 10, 2021

@hoodmane Thanks for the suggestion!

I was wondering if you could use Setup.local to do this rather than patching Setup

Maybe it is possible with a custom Setup.local file with disabled option.

I'll check whether it is possible.

# https://github.com/python/cpython/blob/3d1ca867ed0e3ae343166806f8ddd9739e568ab4/Modules/Setup#L19-L21
# Modules are not built at all, not by the Makefile,
# nor by the setup.py script, when they are preceded by a "*disabled*" tag
# line.

@ryanking13
Copy link
Member Author

Maybe it is possible with a custom Setup.local file with disabled option.

Well, I tested it, and sadly adding *disabled* option in Setup.local doesn't disable modules in Modules/Setup.
(It affects modules in setup.py, but not in Modules/Setup)

I'm not sure this is intended behavior or a bug.
But for now, I think patching Modules/Setup is the only way to get rid of core built-in modules like pwd.

@hoodmane
Copy link
Member

Thanks for checking.

Copy link
Member

@rth rth left a comment

Choose a reason for hiding this comment

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

Thanks @ryanking13 ! Please add it to the docs otherwise LGTM.

@ryanking13
Copy link
Member Author

@rth Updated docs!

@rth rth merged commit 754ae62 into pyodide:main Oct 12, 2021
@ryanking13 ryanking13 deleted the cpython/pwd branch June 13, 2022 05:31
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.

Fatal Error while untaring (using tarfile) downloaded tar gz file.
3 participants