Skip to content

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

Merged
radarhere merged 3 commits intopython-pillow:masterfrom
hugovk:rm-distutils-sysconfig
Jul 25, 2020
Merged

setup.py: Get prefix directly from sys instead of distutils#4809
radarhere merged 3 commits intopython-pillow:masterfrom
hugovk:rm-distutils-sysconfig

Conversation

@hugovk
Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants