Lines Matching refs:self

163     def __init__(self, version, args):
164 self.version = version
165 self.args = args
167 self.install_dir = os.path.join(
168 os.path.join(args.base_directory, self.library.lower()), version
171 self.src_dir = os.path.join(args.base_directory, 'src')
172 self.src_file = os.path.join(
173 self.src_dir, self.src_template.format(version))
175 self.build_dir = os.path.join(
176 self.src_dir, self.build_template.format(version))
177 self.system = args.system
179 def __str__(self):
180 return "<{0.__class__.__name__} for {0.version}>".format(self)
182 def __eq__(self, other):
186 self.library == other.library
187 and self.version == other.version
190 def __hash__(self):
191 return hash((self.library, self.version))
194 def short_version(self):
199 def openssl_cli(self):
201 return os.path.join(self.install_dir, "bin", "openssl")
204 def openssl_version(self):
206 cmd = [self.openssl_cli, "version"]
207 return self._subprocess_output(cmd)
210 def pyssl_version(self):
216 return self._subprocess_output(cmd)
219 def include_dir(self):
220 return os.path.join(self.install_dir, "include")
223 def lib_dir(self):
224 return os.path.join(self.install_dir, "lib")
227 def has_openssl(self):
228 return os.path.isfile(self.openssl_cli)
231 def has_src(self):
232 return os.path.isfile(self.src_file)
234 def _subprocess_call(self, cmd, env=None, **kwargs):
238 def _subprocess_output(self, cmd, env=None, **kwargs):
242 env["LD_LIBRARY_PATH"] = self.lib_dir
246 def _download_src(self):
248 src_dir = os.path.dirname(self.src_file)
252 for url_template in self.url_templates:
253 url = url_template.format(v=self.version, s=self.short_version)
268 log.info("Storing {}".format(self.src_file))
269 with open(self.src_file, "wb") as f:
272 def _unpack_src(self):
275 if os.path.isdir(self.build_dir):
276 shutil.rmtree(self.build_dir)
277 os.makedirs(self.build_dir)
279 tf = tarfile.open(self.src_file)
280 name = self.build_template.format(self.version)
290 log.info("Unpacking files to {}".format(self.build_dir))
291 tf.extractall(self.build_dir, members)
293 def _build_src(self, config_args=()):
295 log.info("Running build in {}".format(self.build_dir))
296 cwd = self.build_dir
300 "--prefix={}".format(self.install_dir)
305 env["LD_RUN_PATH"] = self.lib_dir
306 if self.system:
307 env['SYSTEM'] = self.system
308 self._subprocess_call(cmd, cwd=cwd, env=env)
309 if self.depend_target:
310 self._subprocess_call(
311 ["make", "-j1", self.depend_target], cwd=cwd, env=env
313 self._subprocess_call(["make", f"-j{self.jobs}"], cwd=cwd, env=env)
315 def _make_install(self):
316 self._subprocess_call(
317 ["make", "-j1", self.install_target],
318 cwd=self.build_dir
320 self._post_install()
321 if not self.args.keep_sources:
322 shutil.rmtree(self.build_dir)
324 def _post_install(self):
327 def install(self):
328 log.info(self.openssl_cli)
329 if not self.has_openssl or self.args.force:
330 if not self.has_src:
331 self._download_src()
333 log.debug("Already has src {}".format(self.src_file))
334 self._unpack_src()
335 self._build_src()
336 self._make_install()
338 log.info("Already has installation {}".format(self.install_dir))
340 version = self.openssl_version
341 if self.version not in version:
344 def recompile_pymods(self):
345 log.warning("Using build from {}".format(self.build_dir))
347 for fname in self.module_files:
352 if filename.startswith(self.module_libs):
357 env["CPPFLAGS"] = "-I{}".format(self.include_dir)
358 env["LDFLAGS"] = "-L{}".format(self.lib_dir)
360 env["LD_RUN_PATH"] = self.lib_dir
364 self._subprocess_call(cmd, env=env)
365 self.check_imports()
367 def check_imports(self):
369 self._subprocess_call(cmd)
371 def check_pyssl(self):
372 version = self.pyssl_version
373 if self.version not in version:
376 def run_python_tests(self, tests, network=True):
391 self._subprocess_call(cmd, stdout=None)
406 def _post_install(self):
407 if self.version.startswith("3."):
408 self._post_install_3xx()
410 def _build_src(self, config_args=()):
411 if self.version.startswith("3."):
415 def _post_install_3xx(self):
418 self._subprocess_call(
420 cwd=self.build_dir
422 if not os.path.isdir(self.lib_dir):
424 lib64 = self.lib_dir + "64"
425 os.symlink(lib64, self.lib_dir)
428 def short_version(self):
430 mo = re.search(r"^(\d+)\.(\d+)\.(\d+)", self.version)