virtualenv icon indicating copy to clipboard operation
virtualenv copied to clipboard

distutils/setuptools: need to provide _distutils_system_mod

Open 0-wiz-0 opened this issue 3 years ago • 3 comments

setuptools added support for a _distutils_system_mod override file to distutils. https://github.com/pypa/setuptools/pull/2896

This allows packaging systems to override particular distutils defaults with their preferred solution.

This is how pkgsrc uses the override file:

# _distutils_system_mod

import distutils.sysconfig


vars(distutils.sysconfig).update(
    _makefile_tmpl='config-{python_ver}{build_flags}',
    _sysconfig_name_tmpl='_sysconfigdata_{platform}',
)

Virtualenv does not seem to be aware of this file, and does not copy it in the virtual environments. Thus installing packages will fail in such virtual environments. Example bug report: https://github.com/joyent/pkgsrc/issues/323

The error is

  ModuleNotFoundError: No module named '_sysconfigdata__sunos5_'

because the override for _sysconfig_name_tmpl is not considered, because the _distutils_system_mod file is not available in the virtual environment.

Please copy this file (.../site-packages/_distutils_system_mod.py) if it is available.

0-wiz-0 avatar Mar 08 '22 08:03 0-wiz-0

A PR trying to achieve this would be welcome 👍 (with changelog entry and tests).

gaborbernat avatar Mar 08 '22 08:03 gaborbernat

@gaborbernat I know nothing about the codebase. Any pointers on where I should look first? Thanks.

0-wiz-0 avatar Mar 08 '22 09:03 0-wiz-0

Likely around here https://github.com/pypa/virtualenv/blob/main/src/virtualenv/create/via_global_ref/api.py#L93-L100

gaborbernat avatar Mar 08 '22 09:03 gaborbernat

With 3.12 no longer adding setuptools this is no longer valid.

gaborbernat avatar Jun 27 '23 03:06 gaborbernat