Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
setuptools
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jérome Perrin
setuptools
Commits
1f80bd3a
Commit
1f80bd3a
authored
Jul 27, 2012
by
Richard Oudkerk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #15364: Fix sysconfig.get_config_var('srcdir') to be an absolute path.
parent
a0418246
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
0 deletions
+45
-0
sysconfig.py
sysconfig.py
+17
-0
tests/test_sysconfig.py
tests/test_sysconfig.py
+28
-0
No files found.
sysconfig.py
View file @
1f80bd3a
...
...
@@ -533,6 +533,23 @@ def get_config_vars(*args):
_config_vars['prefix'] = PREFIX
_config_vars['exec_prefix'] = EXEC_PREFIX
# Always convert srcdir to an absolute path
srcdir = _config_vars.get('srcdir', project_base)
if os.name == 'posix':
if python_build:
# If srcdir is a relative path (typically '.' or '..')
# then it should be interpreted relative to the directory
# containing Makefile.
base = os.path.dirname(get_makefile_filename())
srcdir = os.path.join(base, srcdir)
else:
# srcdir is not meaningful since the installation is
# spread about the filesystem. We choose the
# directory containing the Makefile since we know it
# exists.
srcdir = os.path.dirname(get_makefile_filename())
_config_vars['srcdir'] = os.path.abspath(os.path.normpath(srcdir))
# Convert srcdir into an absolute path if it appears necessary.
# Normally it is relative to the build directory. However, during
# testing, for example, we might be running a non-installed python
...
...
tests/test_sysconfig.py
View file @
1f80bd3a
...
...
@@ -53,6 +53,34 @@ class SysconfigTestCase(support.EnvironGuard,
self
.
assertTrue
(
isinstance
(
cvars
,
dict
))
self
.
assertTrue
(
cvars
)
def
test_srcdir
(
self
):
# See Issues #15322, #15364.
srcdir
=
sysconfig
.
get_config_var
(
'srcdir'
)
self
.
assertTrue
(
os
.
path
.
isabs
(
srcdir
),
srcdir
)
self
.
assertTrue
(
os
.
path
.
isdir
(
srcdir
),
srcdir
)
if
sysconfig
.
python_build
:
# The python executable has not been installed so srcdir
# should be a full source checkout.
Python_h
=
os
.
path
.
join
(
srcdir
,
'Include'
,
'Python.h'
)
self
.
assertTrue
(
os
.
path
.
exists
(
Python_h
),
Python_h
)
self
.
assertTrue
(
sysconfig
.
_is_python_source_dir
(
srcdir
))
elif
os
.
name
==
'posix'
:
self
.
assertEqual
(
sysconfig
.
get_makefile_filename
(),
srcdir
)
def
test_srcdir_independent_of_cwd
(
self
):
# srcdir should be independent of the current working directory
# See Issues #15322, #15364.
srcdir
=
sysconfig
.
get_config_var
(
'srcdir'
)
cwd
=
os
.
getcwd
()
try
:
os
.
chdir
(
'..'
)
srcdir2
=
sysconfig
.
get_config_var
(
'srcdir'
)
finally
:
os
.
chdir
(
cwd
)
self
.
assertEqual
(
srcdir
,
srcdir2
)
def
test_customize_compiler
(
self
):
# not testing if default compiler is not unix
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment