Skip to content

module 'sys' has no attribute '_framework' (mac) #1342

@vazrupe

Description

@vazrupe

Feature

스크린샷 2019-09-05 오후 8 58 13

RustPython$ RUSTPYTHONPATH=`pwd`/Libs ./whats_left.sh

...

  File "/Users/vazrupe/workspace/RustPython/Lib/site.py", line 570, in <module>
    if not sys.flags.no_site:
  File "/Users/vazrupe/workspace/RustPython/Lib/site.py", line 556, in main
    ENABLE_USER_SITE = check_enableusersite()
  File "/Users/vazrupe/workspace/RustPython/Lib/site.py", line 312, in addusersitepackages
    user_site = getusersitepackages()
  File "/Users/vazrupe/workspace/RustPython/Lib/site.py", line 297, in getusersitepackages
    userbase = getuserbase() # this will also set USER_BASE
  File "/Users/vazrupe/workspace/RustPython/Lib/site.py", line 286, in getuserbase
    USER_BASE = _getuserbase()
  File "/Users/vazrupe/workspace/RustPython/Lib/site.py", line 257, in _getuserbase
    if sys.platform == "darwin" and sys._framework:
AttributeError: module 'sys' has no attribute '_framework'

RustPython and system Python have the following attributes:

RustPython$ cargo run -- -c 'import sys; print(sys._framework)'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'sys' has no attribute '_framework'
RustPython$ python3 --version
Python 3.7.4
RustPython$ python3 -c 'import sys; print(sys._framework)'
Python

Python Documentation

This attribute represents the name of the framework bundle on mac.

Here you can see that the framework name of the Python binary on mac is Python.

Instructions on how to replace this attribute with a different value can be found in the README in python/cpython. I could change to the following command:

$ git clone https://github.com/python/cpython
$ cd cpython
cpython$ ./configure --with-framework-name=example --enable-framework
cpython$ make frameworkinstall
cpython$ ls /Library/Frameworks/example.framework/Versions/Current/bin/
2to3			pip3			python3-config
2to3-3.9		pip3.9			python3.9
easy_install-3.9	pydoc3			python3.9-config
idle3			pydoc3.9
idle3.9			python3
cpython$ /Library/Frameworks/example.framework/Versions/Current/bin/python3
Python 3.9.0a0 (heads/master:29bb227a0c, Sep  5 2019, 23:11:17)
[Clang 10.0.1 (clang-1001.0.46.4)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys._framework
'example'

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-compatA discrepancy between RustPython and CPython

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions