defaults.cfg 2.7 KB
Newer Older
1 2
[buildout]
extends =
3
  gcc/buildout.cfg
4 5 6 7
  python-2.7/buildout.cfg
  python3/buildout.cfg
python = python

8 9 10 11 12
# Unless a software release needs several versions of either Python or GCC
# at the same time, the [pythonX.Y] & [gcc-X.Y] must not be referred directly,
# even if a component works only with specific versions.
# There may be exceptions in profiles that were written before this one.

13 14
[python]
recipe = slapos.recipe.build
15
part = python3
16 17 18 19 20 21 22 23 24 25
init =
  python = self.buildout[options['part']]
  for x in 'location', 'executable', 'version':
    options[x] = python[x]
update =
  import os
  path, os.environ['PYTHON'] = os.path.split(options['executable'])
  PATH = os.environ['PATH']
  if path not in PATH.split(os.pathsep):
    os.environ['PATH'] = path + os.pathsep + PATH
26 27 28
depends = ${gcc:recipe}

[gcc]
29 30 31 32 33 34
depends =
# requirements that are common to gcc & python
  ${gettext:recipe}
  ${perl:recipe}
# python requirements for which the compiler does not matter
  ${patch:recipe}
35 36
recipe = slapos.recipe.build
# Latest version provided by SlapOS.
Julien Muchembled's avatar
Julien Muchembled committed
37
part = gcc-8.5
38 39 40 41 42 43 44 45 46 47 48 49 50 51
# Minimum version for all components that might be required for
# slapos.rebootstrap (see https://bugs.python.org/issue34112 about Python 3.7+).
min_version = 5.4
init =
  import os, subprocess
  parse_version = lambda ver: tuple(map(int, ver.strip().split('.')))
  try:
    current = subprocess.check_output(('gcc', '-dumpfullversion'),
                                      stderr=subprocess.STDOUT,
                                      universal_newlines=True).strip()
  except subprocess.CalledProcessError: # BBB: old GCC
    current = subprocess.check_output(('gcc', '-dumpversion'),
                                      universal_newlines=True).strip()
  self.system_version = current
52 53
# If we're still going to use the same GCC,
# the conditions have no impact on the dependant parts.
54 55
  min_version = options.pop('min_version', None)
  max_version = options.pop('max_version', None)
56
###
57
  if (parse_version(min_version or current)
58 59 60 61 62 63
      <= parse_version(current)
      <= parse_version(max_version or current)):
    del options['part']
    for path in os.getenv('PATH', '').split(os.pathsep): # PY3: shutil.which
      gcc = os.path.join(path, 'gcc')
      if os.access(gcc, os.X_OK) and not os.path.isdir(gcc):
64
        options['prefix'] = os.path.dirname(os.path.normpath(path))
65 66 67 68 69 70 71 72 73 74
        break
  else:
    options['prefix'] = self.buildout[options['part']]['location']
  options.barrier()
update =
  if 'part' in options:
    import os
    env = os.environ
    env['PATH'] = os.pathsep.join((
      os.path.join(options['prefix'], 'bin'),
75
      os.path.join(self.buildout['binutils']['location'], 'bin'),
76 77 78 79
      env['PATH']
    ))
  else:
    print("Using system GCC (%s)" % self.system_version)