◐ Shell
reader mode source ↗
Skip to content

bpo-31904: Fix site and sysconfig modules for VxWorks RTOS #21821

Merged
vstinner merged 1 commit into
python:masterfrom
Wind-River:fix-issue-31904-site
Dec 20, 2020
Merged

bpo-31904: Fix site and sysconfig modules for VxWorks RTOS #21821
vstinner merged 1 commit into
python:masterfrom
Wind-River:fix-issue-31904-site

Conversation

@pxinwr

@pxinwr pxinwr commented Aug 11, 2020

Copy link
Copy Markdown
Contributor

VxWorks RTOS has no home directory for users. Sure it can't recognize the "~" directory. sys.prefix is always set as "/usr" on VxWorks. So for site and sysconfig module, we just simply set the user base as sys.prefix for users. And user site packages path will be sys.prefix/lib/pythonX.Y/site-packages

https://bugs.python.org/issue31904

@pxinwr pxinwr force-pushed the fix-issue-31904-site branch from c7f2c40 to 2888670 Compare December 2, 2020 06:45

@vstinner vstinner 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.

Hide comment

What does os.path.expanduser('~') return on VxWorks?

Instead of changing sysconfig and site, maybe posixpath.expanduser() could get a special case to return sys.prefix?

@pxinwr

pxinwr commented Dec 4, 2020

Copy link
Copy Markdown
Contributor Author

What does os.path.expanduser('~') return on VxWorks?

It depends on whether user management feature is enabled or not on VxWorks. By default this feature is disabled. And expanduser() will encounter KeyError then returning the unchanged path. If user management feature is enabled, the pw_dir attribute will be None so that expanduser() will raise exception. So I created PR 23530 to fix this.

Instead of changing sysconfig and site, maybe posixpath.expanduser() could get a special case to return sys.prefix?

Looks sys.prefix is for system-wide settings whereas the return value of posixpath.expanduser() is used for user specific settings. If we return sys.prefix from posixpath.expanduser(), any chance things get mixed up to mess? Now I get stuck on which one, None or sys.prefix should be returned for user base and user site. What is your idea? If determined to None, ENABLE_USER_SITE should also be set to False. Since sys.prefix has been added to sys.path, so setting user base to None has no impact on sys.path.

@pxinwr pxinwr force-pushed the fix-issue-31904-site branch from eccff0c to 795f0e4 Compare December 7, 2020 10:49

@vstinner vstinner 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.

Hide comment

LGTM, this change looks reasonable.

The relationship between ENABLE_USER_SITE=False and (USER_SITE=None, USER_BASE=None) may be enhanced to make the code even more generic, but I don't see how it should be done. I'm fine with the current code. Also, sysconfig._getuserbase() doesn't have ENABLE_USER_SITE, so it's ok to use None as a marker "there is no user directory".

@vstinner

Copy link
Copy Markdown
Member

posixpath.expanduser() has been modified on VxWorks by PR #23530 (commit 75dabfe): return the path unmodified if pwd.getpwuid().pw_dir is None. This change doesn't help site/sysconfig, so this PR remains useful/relevant.

@vstinner

Copy link
Copy Markdown
Member

The second version of the PR is way better, thanks for the update.

@vstinner vstinner merged commit ab74c01 into python:master Dec 20, 2020
@pxinwr

pxinwr commented Dec 21, 2020

Copy link
Copy Markdown
Contributor Author

@vstinner Thanks for your effort.

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
@pxinwr pxinwr deleted the fix-issue-31904-site branch May 7, 2021 07:42
@kuhlenough kuhlenough mannequin mentioned this pull request Jan 12, 2024
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.

4 participants