MCPcopy Create free account
hub / github.com/python/cpython / get_extension_defn

Function get_extension_defn

Tools/freeze/checkextensions_win32.py:82–123  ·  view source on GitHub ↗
(moduleName, mapFileName, prefix)

Source from the content-addressed store, hash-verified

80 return ret
81
82def get_extension_defn(moduleName, mapFileName, prefix):
83 if win32api is None: return None
84 os.environ['PYTHONPREFIX'] = prefix
85 dsp = win32api.GetProfileVal(moduleName, "dsp", "", mapFileName)
86 if dsp=="":
87 return None
88
89 # We allow environment variables in the file name
90 dsp = win32api.ExpandEnvironmentStrings(dsp)
91 # If the path to the .DSP file is not absolute, assume it is relative
92 # to the description file.
93 if not os.path.isabs(dsp):
94 dsp = os.path.join( os.path.split(mapFileName)[0], dsp)
95 # Parse it to extract the source files.
96 sourceFiles = parse_dsp(dsp)
97 if sourceFiles is None:
98 return None
99
100 module = CExtension(moduleName, sourceFiles)
101 # Put the path to the DSP into the environment so entries can reference it.
102 os.environ['dsp_path'] = os.path.split(dsp)[0]
103 os.environ['ini_path'] = os.path.split(mapFileName)[0]
104
105 cl_options = win32api.GetProfileVal(moduleName, "cl", "", mapFileName)
106 if cl_options:
107 module.AddCompilerOption(win32api.ExpandEnvironmentStrings(cl_options))
108
109 exclude = win32api.GetProfileVal(moduleName, "exclude", "", mapFileName)
110 exclude = exclude.split()
111
112 if win32api.GetProfileVal(moduleName, "Unicode", 0, mapFileName):
113 module.AddCompilerOption('/D UNICODE /D _UNICODE')
114
115 libs = win32api.GetProfileVal(moduleName, "libs", "", mapFileName).split()
116 for lib in libs:
117 module.AddLinkerLib(win32api.ExpandEnvironmentStrings(lib))
118
119 for exc in exclude:
120 if exc in module.sourceFiles:
121 module.sourceFiles.remove(exc)
122
123 return module
124
125# Given an MSVC DSP file, locate C source files it uses
126# returns a list of source files.

Callers 1

checkextensionsFunction · 0.85

Calls 8

AddCompilerOptionMethod · 0.95
AddLinkerLibMethod · 0.95
parse_dspFunction · 0.85
CExtensionClass · 0.85
isabsMethod · 0.45
joinMethod · 0.45
splitMethod · 0.45
removeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…