File: cython_extra.py

package info (click to toggle)
xmms2 0.8%2Bdfsg-29
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 14,216 kB
  • sloc: ansic: 63,803; python: 15,537; cpp: 5,718; xml: 1,479; perl: 338; ruby: 243; makefile: 79; sh: 59; asm: 7
file content (60 lines) | stat: -rw-r--r-- 1,586 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# encoding: utf-8
# Extend waf cython tool features.

import re
from waflib import Configure
import subprocess

cython_ver_re = re.compile(b'Cython version ([0-9.]+)')
def check_cython_version(self, version=None, minver=None, maxver=None):
	log_s = []
	if version:
		log_s.append("version=%r"%version)
		minver=version
		maxver=version
	else:
		if minver:
			log_s.append("minver=%r"%minver)
		if maxver:
			log_s.append("maxver=%r"%maxver)
	if isinstance(minver, str):
		minver = minver.split('.')
	if isinstance(maxver, str):
		maxver = maxver.split('.')
	if minver:
		minver = tuple(map(int, minver))
	if maxver:
		maxver = tuple(map(int, maxver))

	if isinstance(self.env.CYTHON, list):
		cmdbin = " "
		cmdbin = cmdbin.join(self.env.CYTHON)
	else:
		cmdbin = self.env.CYTHON

	cmd = [cmdbin, '-V']
	o = subprocess.check_output(cmd, stderr=subprocess.STDOUT).strip()
	m = cython_ver_re.match(o)
	self.start_msg('Checking for cython version')
	if not m:
		self.end_msg('Not found', 'YELLOW')
		self.fatal("No version found")
	else:
		v = m.group(1)
		ver = tuple(map(int, v.split(b'.')))
		check = (not minver or minver <= ver) and (not maxver or maxver >= ver)
		self.to_log('  cython %s\n  -> %r\n' % (" ".join(log_s), v))
		if check:
			self.end_msg(v.decode("utf-8"))
			self.env.CYTHON_VERSION = ver
		else:
			self.end_msg('wrong version %s' % v, 'YELLOW')
			self.fatal("Bad cython version (%s)"%v)
	return True


def configure(conf):
	if not conf.env.CYTHON:
		conf.fatal("cython_extra requires the tool 'cython' to be loaded first.")
	Configure.conf(check_cython_version)