MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / finalize_options

Method finalize_options

setup.py:160–239  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

getMethod · 0.80
lowerMethod · 0.80

Tested by

no test coverage detected