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

setup.py: Get prefix directly from sys instead of distutils #4809

Merged
merged 3 commits into from
Jul 25, 2020

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Jul 23, 2020

For #4796.

distutils

setup.py does:

from distutils import sysconfig
prefix = sysconfig.get_config_var("prefix")

https://github.com/python/cpython/blob/master/Lib/distutils/sysconfig.py

get_config_var("prefix") calls get_config_vars().get("prefix"), which initialised it as
_config_vars['prefix'] = PREFIX, where PREFIX = os.path.normpath(sys.prefix)

sysconfig

There's also a sysconfig module in the stdlib:

This is almost identical to the one in distutils:

get_config_var("prefix") calls get_config_vars().get("prefix"), which initialised it as
_CONFIG_VARS['prefix'] = _PREFIX = _PREFIX, where PREFIX = os.path.normpath(sys.prefix)

https://github.com/python/cpython/blob/master/Lib/sysconfig.py

I tried our setup.py with:

-from distutils import sysconfig
+import sysconfig
 prefix = sysconfig.get_config_var("prefix")

Which passed on all CI jobs except MSYS MINGW32 and MINGW64 because the drive letter changed:

distutils sysconfig prefix:   C:/msys64/mingw64
stdlib    sysconfig prefix:   D:/msys64/mingw64

os.path.normpath(sys.prefix)

I didn't dig into why they're different, but can we skip distutils.sysconfig and sysconfig altogether and use os.path.normpath(sys.prefix) directly?

sys.prefix:                   C:/msys64/mingw64
os.path.normpath(sys.prefix): C:/msys64/mingw64

@radarhere
Copy link
Member

I've created hugovk#57 as a suggestion

@radarhere radarhere merged commit f611793 into python-pillow:master Jul 25, 2020
@hugovk hugovk deleted the rm-distutils-sysconfig branch July 25, 2020 12:52
@hugovk hugovk mentioned this pull request Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants