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

CCompiler self.include_dirs modified during each compile() #3591

Closed
mdavidsaver opened this issue Sep 14, 2022 · 1 comment · Fixed by pypa/distutils#199
Closed

CCompiler self.include_dirs modified during each compile() #3591

mdavidsaver opened this issue Sep 14, 2022 · 1 comment · Fixed by pypa/distutils#199

Comments

@mdavidsaver
Copy link

cf. 9f9a3e5

if include_dirs is None:
include_dirs = self.include_dirs
elif isinstance(include_dirs, (list, tuple)):
include_dirs = list(include_dirs) + (self.include_dirs or [])
else:
raise TypeError("'include_dirs' (if supplied) must be a list of strings")
# add include dirs for class
include_dirs += self.__class__.include_dirs

def _configure(cls, vc_env):
"""
Set class-level include/lib dirs.
"""
cls.include_dirs = cls._parse_path(vc_env.get('include', ''))
cls.library_dirs = cls._parse_path(vc_env.get('lib', ''))

With msvc, the class include_dirs is not empty, and will be appended to the instance include_dirs for each compile(..., include_dirs=None) (which is the default). With enough calls, an impressively long argument list accumulates, resulting in an error:

FileNotFoundError: [WinError 206] The filename or extension is too long

I think that one simple fix would be:

 if include_dirs is None: 
     include_dirs = self.include_dirs[:] # make a copy
@mrbean-bremen
Copy link
Contributor

This also broke our NumPy builds with Python 3.11 under Windows. The above-mentioned change fixes this. Would it help to make a PR with the fix?

mrbean-bremen added a commit to mrbean-bremen/setuptools that referenced this issue Jan 18, 2023
mrbean-bremen added a commit to mrbean-bremen/distutils that referenced this issue Jan 18, 2023
mrbean-bremen added a commit to mrbean-bremen/distutils that referenced this issue Jan 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants