diff --git a/src/zc/buildout/buildout.py b/src/zc/buildout/buildout.py index de0b265ae4551e4ecc8aae10a40efc9fb3d72ed3..beb401833506c2bf63a2e5c11295bd827827db57 100644 --- a/src/zc/buildout/buildout.py +++ b/src/zc/buildout/buildout.py @@ -2156,6 +2156,13 @@ class _extends(object): 'No-longer supported "extended-by" option found in %s.' % filename) + # Find and expose _profile_base_location_ + for section in result.values(): + for value in section.values(): + if '${:_profile_base_location_}' in value: + section['_profile_base_location_'] = base + break + _annotate(result, filename) # Collect extends and unprocessed download options diff --git a/src/zc/buildout/tests/buildout.txt b/src/zc/buildout/tests/buildout.txt index f3393d96cb910a1c9f6b2298784a51038531c01d..c8802668365ae866a4413c51ab71eabf06d4f653 100644 --- a/src/zc/buildout/tests/buildout.txt +++ b/src/zc/buildout/tests/buildout.txt @@ -1285,6 +1285,102 @@ the current section. We can also use the special option, my_name debug recipe recipes:debug +It is possible to have access to profile base url from section by +using ${:_profile_base_location_}: + + >>> write(sample_buildout, 'buildout.cfg', + ... """ + ... [buildout] + ... develop = recipes + ... parts = data-dir debug + ... log-level = INFO + ... + ... [debug] + ... recipe = recipes:debug + ... profile_base_location = ${:_profile_base_location_} + ... + ... [data-dir] + ... recipe = recipes:mkdir + ... path = mydata + ... """) + + >>> print_(system(buildout), end='') + Develop: '/sample-buildout/recipes' + Uninstalling debug. + Updating data-dir. + Installing debug. + _profile_base_location_ /sample-buildout + profile_base_location /sample-buildout + recipe recipes:debug + +Keep in mind that in case of sections spaning across multiple profiles, +the topmost value will be presented: + + >>> write(sample_buildout, 'extended.cfg', + ... """ + ... [debug] + ... profile_base_location = ${:_profile_base_location_} + ... """) + + >>> write(sample_buildout, 'buildout.cfg', + ... """ + ... [buildout] + ... extends = extended.cfg + ... develop = recipes + ... parts = data-dir debug + ... log-level = INFO + ... + ... [debug] + ... recipe = recipes:debug + ... profile_base_location = ${:_profile_base_location_} + ... + ... [data-dir] + ... recipe = recipes:mkdir + ... path = mydata + ... """) + + >>> print_(system(buildout), end='') + Develop: '/sample-buildout/recipes' + Updating data-dir. + Updating debug. + _profile_base_location_ /sample-buildout + profile_base_location /sample-buildout + recipe recipes:debug + +But of course, in case if accessing happens in extended profile's section, +this profile's location will be exposed: + + >>> write(sample_buildout, 'extended.cfg', + ... """ + ... [debug] + ... profile_base_location = ${:_profile_base_location_} + ... """) + + >>> write(sample_buildout, 'buildout.cfg', + ... """ + ... [buildout] + ... extends = extended.cfg + ... develop = recipes + ... parts = data-dir debug + ... log-level = INFO + ... + ... [debug] + ... recipe = recipes:debug + ... + ... [data-dir] + ... recipe = recipes:mkdir + ... path = mydata + ... """) + + >>> print_(system(buildout), end='') + Develop: '/sample-buildout/recipes' + Updating data-dir. + Updating debug. + _profile_base_location_ /sample-buildout + profile_base_location /sample-buildout + recipe recipes:debug + >>> remove(sample_buildout, 'extended.cfg') + Automatic part selection and ordering -------------------------------------