Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e87acc1

Browse files
committed
Issue #16116: Now uses corrected include and library paths when building C extensions in a venv.
1 parent e6e96ee commit e87acc1

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

Lib/distutils/command/build_ext.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ def finalize_options(self):
160160
if isinstance(self.include_dirs, str):
161161
self.include_dirs = self.include_dirs.split(os.pathsep)
162162

163+
# If in a virtualenv, add its include directory
164+
# Issue 16116
165+
if sys.exec_prefix != sys.base_exec_prefix:
166+
self.include_dirs.append(os.path.join(sys.exec_prefix, 'include'))
167+
163168
# Put the Python "system" include dir at the end, so that
164169
# any local include dirs take precedence.
165170
self.include_dirs.append(py_include)
@@ -190,6 +195,8 @@ def finalize_options(self):
190195
# must be the *native* platform. But we don't really support
191196
# cross-compiling via a binary install anyway, so we let it go.
192197
self.library_dirs.append(os.path.join(sys.exec_prefix, 'libs'))
198+
if sys.base_exec_prefix != sys.prefix: # Issue 16116
199+
self.library_dirs.append(os.path.join(sys.base_exec_prefix, 'libs'))
193200
if self.debug:
194201
self.build_temp = os.path.join(self.build_temp, "Debug")
195202
else:

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ Core and Builtins
4646
Library
4747
-------
4848

49+
- Issue #16116: Fix include and library paths to be correctwhen building C
50+
extensions in venvs.
51+
4952
- Issue #16245: Fix the value of a few entities in html.entities.html5.
5053

5154
- Issue #14398: Fix size truncation and overflow bugs in the bz2 module.

0 commit comments

Comments
 (0)