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
e8e9d114
Kaydet (Commit)
e8e9d114
authored
Agu 13, 2000
tarafından
Greg Ward
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Overhauld 'check_config_h()': now returns a (status, details) tuple,
and is much better documented to boot.
üst
13980451
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
26 deletions
+45
-26
cygwinccompiler.py
Lib/distutils/cygwinccompiler.py
+45
-26
No files found.
Lib/distutils/cygwinccompiler.py
Dosyayı görüntüle @
e8e9d114
...
...
@@ -65,11 +65,13 @@ class CygwinCCompiler (UnixCCompiler):
UnixCCompiler
.
__init__
(
self
,
verbose
,
dry_run
,
force
)
check_result
=
check_config_h
()
self
.
debug_print
(
"Python's GCC status:
%
s"
%
check_result
)
if
check_result
[:
2
]
<>
"OK"
:
(
status
,
details
)
=
check_config_h
()
self
.
debug_print
(
"Python's GCC status:
%
s (details:
%
s)"
%
(
status
,
details
))
if
status
is
not
CONFIG_H_OK
:
self
.
warn
(
"Python's config.h doesn't seem to support your compiler. "
"Python's config.h doesn't seem to support your compiler. "
+
(
"Reason:
%
s."
%
details
)
+
"Compiling may fail because of undefined preprocessor macros."
)
(
self
.
gcc_version
,
self
.
ld_version
,
self
.
dllwrap_version
)
=
\
...
...
@@ -241,43 +243,60 @@ class Mingw32CCompiler (CygwinCCompiler):
# default, we should at least warn the user if he is using a unmodified
# version.
CONFIG_H_OK
=
"ok"
CONFIG_H_NOTOK
=
"not ok"
CONFIG_H_UNCERTAIN
=
"uncertain"
def
check_config_h
():
"""Checks if the GCC compiler is mentioned in config.h. If it is not,
compiling probably doesn't work.
"""Check if the current Python installation (specifically, config.h)
appears amenable to building extensions with GCC. Returns a tuple
(status, details), where 'status' is one of the following constants:
CONFIG_H_OK
all is well, go ahead and compile
CONFIG_H_NOTOK
doesn't look good
CONFIG_H_UNCERTAIN
not sure -- unable to read config.h
'details' is a human-readable string explaining the situation.
Note there are two ways to conclude "OK": either 'sys.version' contains
the string "GCC" (implying that this Python was built with GCC), or the
installed "config.h" contains the string "__GNUC__".
"""
# return values
# "OK, python was compiled with GCC"
# "OK, python's config.h mentions __GCC__"
# "uncertain, because we couldn't check it"
# "not OK, because we didn't found __GCC__ in config.h"
# You could check check_config_h()[:2] == "OK"
# XXX since this function also checks sys.version, it's not strictly a
# "config.h" check -- should probably be renamed...
from
distutils
import
sysconfig
import
string
,
sys
# if sys.version contains GCC then python was compiled with
# GCC, and the config.h file should be OK
if
-
1
==
string
.
find
(
sys
.
version
,
"GCC"
):
pass
# go to the next test
else
:
return
"OK, python was compiled with GCC"
if
string
.
find
(
sys
.
version
,
"GCC"
)
>=
0
:
return
(
CONFIG_H_OK
,
"sys.version mentions 'GCC'"
)
fn
=
sysconfig
.
get_config_h_filename
()
try
:
# It would probably better to read single lines to search.
# But we do this only once, and it is fast enough
f
=
open
(
sysconfig
.
get_config_h_filename
()
)
s
=
f
.
read
()
f
=
open
(
fn
)
s
=
f
.
read
()
f
.
close
()
# is somewhere a #ifdef __GNUC__ or something similar
if
-
1
==
string
.
find
(
s
,
"__GNUC__"
):
return
"not OK, because we didn't found __GCC__ in config.h"
else
:
return
"OK, python's config.h mentions __GCC__"
except
IOError
:
except
IOError
,
exc
:
# if we can't read this file, we cannot say it is wrong
# the compiler will complain later about this file as missing
pass
return
"uncertain, because we couldn't check it"
return
(
CONFIG_H_UNCERTAIN
,
"couldn't read '
%
s':
%
s"
%
(
fn
,
exc
.
strerror
))
else
:
# "config.h" contains an "#ifdef __GNUC__" or something similar
if
string
.
find
(
s
,
"__GNUC__"
)
>=
0
:
return
(
CONFIG_H_OK
,
"'
%
s' mentions '__GNUC__'"
%
fn
)
else
:
return
(
CONFIG_H_NOTOK
,
"'
%
s' does not mention '__GNUC__'"
%
fn
)
def
get_versions
():
""" Try to find out the versions of gcc, ld and dllwrap.
...
...
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