MCPcopy
hub / github.com/MagicStack/asyncpg / finalize_options

Method finalize_options

setup.py:151–232  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

149 self.define = ",".join(defines)
150
151 def finalize_options(self):
152 # finalize_options() may be called multiple times on the
153 # same command object, so make sure not to override previously
154 # set options.
155 if getattr(self, '_initialized', False):
156 return
157
158 if not self.cython_always:
159 self.cython_always = bool(os.environ.get(
160 "ASYNCPG_BUILD_CYTHON_ALWAYS"))
161
162 if self.cython_annotate is None:
163 self.cython_annotate = os.environ.get(
164 "ASYNCPG_BUILD_CYTHON_ANNOTATE")
165
166 if self.cython_directives is None:
167 self.cython_directives = os.environ.get(
168 "ASYNCPG_BUILD_CYTHON_DIRECTIVES")
169
170 need_cythonize = self.cython_always
171 cfiles = {}
172
173 for extension in self.distribution.ext_modules:
174 for i, sfile in enumerate(extension.sources):
175 if sfile.endswith('.pyx'):
176 prefix, ext = os.path.splitext(sfile)
177 cfile = prefix + '.c'
178
179 if os.path.exists(cfile) and not self.cython_always:
180 extension.sources[i] = cfile
181 else:
182 if os.path.exists(cfile):
183 cfiles[cfile] = os.path.getmtime(cfile)
184 else:
185 cfiles[cfile] = 0
186 need_cythonize = True
187
188 if need_cythonize:
189 import pkg_resources
190
191 # Double check Cython presence in case setup_requires
192 # didn't go into effect (most likely because someone
193 # imported Cython before setup_requires injected the
194 # correct egg into sys.path.
195 try:
196 import Cython
197 except ImportError:
198 raise RuntimeError(
199 'please install {} to compile asyncpg from source'.format(
200 CYTHON_DEPENDENCY))
201
202 cython_dep = pkg_resources.Requirement.parse(CYTHON_DEPENDENCY)
203 if Cython.__version__ not in cython_dep:
204 raise RuntimeError(
205 'asyncpg requires {}, got Cython=={}'.format(
206 CYTHON_DEPENDENCY, Cython.__version__
207 ))
208

Callers

nothing calls this directly

Calls 3

getMethod · 0.80
parseMethod · 0.80
lowerMethod · 0.80

Tested by

no test coverage detected