Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
46874ad3
Kaydet (Commit)
46874ad3
authored
Tem 27, 2012
tarafından
Richard Oudkerk
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Issue #15364: Fix sysconfig.get_config_var('srcdir') to be an absolute path.
üst
a61b4598
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
22 deletions
+92
-22
sysconfig.py
Lib/distutils/sysconfig.py
+17
-0
test_sysconfig.py
Lib/distutils/tests/test_sysconfig.py
+28
-0
sysconfig.py
Lib/sysconfig.py
+16
-22
test_sysconfig.py
Lib/test/test_sysconfig.py
+28
-0
NEWS
Misc/NEWS
+3
-0
No files found.
Lib/distutils/sysconfig.py
Dosyayı görüntüle @
46874ad3
...
...
@@ -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
...
...
Lib/distutils/tests/test_sysconfig.py
Dosyayı görüntüle @
46874ad3
...
...
@@ -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
...
...
Lib/sysconfig.py
Dosyayı görüntüle @
46874ad3
...
...
@@ -533,28 +533,22 @@ def get_config_vars(*args):
# the init-function.
_CONFIG_VARS
[
'userbase'
]
=
_getuserbase
()
if
'srcdir'
not
in
_CONFIG_VARS
:
_CONFIG_VARS
[
'srcdir'
]
=
_PROJECT_BASE
else
:
_CONFIG_VARS
[
'srcdir'
]
=
_safe_realpath
(
_CONFIG_VARS
[
'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
# from a different directory.
if
_PYTHON_BUILD
and
os
.
name
==
"posix"
:
base
=
_PROJECT_BASE
try
:
cwd
=
os
.
getcwd
()
except
OSError
:
cwd
=
None
if
(
not
os
.
path
.
isabs
(
_CONFIG_VARS
[
'srcdir'
])
and
base
!=
cwd
):
# srcdir is relative and we are not in the same directory
# as the executable. Assume executable is in the build
# directory and make srcdir absolute.
srcdir
=
os
.
path
.
join
(
base
,
_CONFIG_VARS
[
'srcdir'
])
_CONFIG_VARS
[
'srcdir'
]
=
os
.
path
.
normpath
(
srcdir
)
# 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'
]
=
_safe_realpath
(
srcdir
)
# OS X platforms require special customization to handle
# multi-architecture, multi-os-version installers
...
...
Lib/test/test_sysconfig.py
Dosyayı görüntüle @
46874ad3
...
...
@@ -340,6 +340,34 @@ class TestSysConfig(unittest.TestCase):
self
.
assertEqual
(
status
,
0
)
self
.
assertEqual
(
my_platform
,
test_platform
)
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
)
class
MakefileTests
(
unittest
.
TestCase
):
...
...
Misc/NEWS
Dosyayı görüntüle @
46874ad3
...
...
@@ -55,6 +55,9 @@ Core and Builtins
Library
-------
-
Issue
#
15364
:
Fix
sysconfig
.
get_config_var
(
'srcdir'
)
to
be
an
absolute
path
.
-
Issue
#
15041
:
update
"see also"
list
in
tkinter
documentation
.
-
Issue
#
15413
:
os
.
times
()
had
disappeared
under
Windows
.
...
...
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