Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
95ba13fa
Commit
95ba13fa
authored
May 16, 2008
by
Thomas Heller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue 1793: Add ctypes.util.find_msvcrt() function (on Windows).
parent
3c4971c4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
0 deletions
+48
-0
Lib/ctypes/util.py
Lib/ctypes/util.py
+43
-0
Misc/NEWS
Misc/NEWS
+5
-0
No files found.
Lib/ctypes/util.py
View file @
95ba13fa
...
...
@@ -5,7 +5,50 @@ import sys, os
# find_library(name) returns the pathname of a library, or None.
if
os
.
name
==
"nt"
:
def
_get_build_version
():
"""Return the version of MSVC that was used to build Python.
For Python 2.3 and up, the version number is included in
sys.version. For earlier versions, assume the compiler is MSVC 6.
"""
# This function was copied from Lib/distutils/msvccompiler.py
prefix
=
"MSC v."
i
=
sys
.
version
.
find
(
prefix
)
if
i
==
-
1
:
return
6
i
=
i
+
len
(
prefix
)
s
,
rest
=
sys
.
version
[
i
:].
split
(
" "
,
1
)
majorVersion
=
int
(
s
[:
-
2
])
-
6
minorVersion
=
int
(
s
[
2
:
3
])
/
10.0
# I don't think paths are affected by minor version in version 6
if
majorVersion
==
6
:
minorVersion
=
0
if
majorVersion
>=
6
:
return
majorVersion
+
minorVersion
# else we don't know what version of the compiler this is
return
None
def
find_msvcrt
():
"""Return the name of the VC runtime dll"""
version
=
_get_build_version
()
if
version
is
None
:
# better be safe than sorry
return
None
if
version
<=
6
:
clibname
=
'msvcrt'
else
:
clibname
=
'msvcr%d'
%
(
version
*
10
)
# If python was built with in debug mode
import
imp
if
imp
.
get_suffixes
()[
0
][
0
]
==
'_d.pyd'
:
clibname
+=
'd'
return
clibname
+
'.dll'
def
find_library
(
name
):
if
name
in
(
'c'
,
'm'
):
return
find_msvcrt
()
# See MSDN for the REAL search order.
for
directory
in
os
.
environ
[
'PATH'
].
split
(
os
.
pathsep
):
fname
=
os
.
path
.
join
(
directory
,
name
)
...
...
Misc/NEWS
View file @
95ba13fa
...
...
@@ -41,6 +41,11 @@ Extension Modules
Library
-------
- Issue 1793: Function ctypes.util.find_msvcrt() added that returns
the name of the C runtime library that Python uses.
ctypes.util.find_library(name) now call this function when name is
'm' or 'c'.
- The Tkinter module has been made a package and renamed 'tkinter'. All
Tkinter-related modules (like Tix, ScrolledText, turtle etc.) are now
submodules of that package and have been renamed to conform to PEP 8
...
...
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