Skip to content

[Feature Request] Public interface for _msvccompiler._get_vc_env #340

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

Open
ozanMSFT opened this issue Mar 11, 2025 · 2 comments
Open

[Feature Request] Public interface for _msvccompiler._get_vc_env #340

ozanMSFT opened this issue Mar 11, 2025 · 2 comments

Comments

@ozanMSFT
Copy link

ozanMSFT commented Mar 11, 2025

pytorch's repository is using an import of setuptools / distutil.

https://github.com/pytorch/pytorch/blob/main/tools/build_pytorch_libs.py#L17-L25

def _get_vc_env(vc_arch: str) -> dict[str, str]:
    try:
        from setuptools import distutils  # type: ignore[import]

        return distutils._msvccompiler._get_vc_env(vc_arch)  # type: ignore[no-any-return]
    except AttributeError:
        from setuptools._distutils import _msvccompiler  # type: ignore[import]

        return _msvccompiler._get_vc_env(vc_arch)  # type: ignore[no-any-return]

However, its location/implementation is being changed and causing the errors as follows:

AttributeError: module 'distutils._msvccompiler' has no attribute '_get_vc_env'

Example issues:
pypa/setuptools#4874
pytorch/pytorch#148877
pytorch/pytorch#141319


Could you please open a reliable public interface for _get_vc_env , so pytorch 's repository could be updated to use that import for the future versions?

@jaraco
Copy link
Member

jaraco commented Mar 23, 2025

Can you tell me more about the use-case(s) for this function? Does the setuptools.msvc module provide the necessary behaviors? Is _get_vc_env used to extract the inner details of the compiler or is it used simply to pass through to invocations of build tools?

@ozanMSFT
Copy link
Author

ozanMSFT commented Mar 27, 2025

Based on use case which I've provided in the description for the PyTorch:

It is being used to get necessary environment variables of MSVC as dictionary and it is being passed to cmake for further process.

As far as I see, setuptools.msvc module doesn't have a function to return environment variables as dictionary as _msvccompiler._get_vc_env(vc_arch) does.

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

No branches or pull requests

2 participants