Merge "install under python3 by default when enabled"
This commit is contained in:
commit
011b2a51ae
39
inc/python
39
inc/python
@ -115,13 +115,12 @@ function check_python3_support_for_package_remote {
|
|||||||
echo $classifier
|
echo $classifier
|
||||||
}
|
}
|
||||||
|
|
||||||
# python3_enabled_for() checks if the service(s) specified as arguments are
|
# python3_enabled_for() assumes the service(s) specified as arguments are
|
||||||
# enabled by the user in ``ENABLED_PYTHON3_PACKAGES``.
|
# enabled for python 3 unless explicitly disabled. See python3_disabled_for().
|
||||||
#
|
#
|
||||||
# Multiple services specified as arguments are ``OR``'ed together; the test
|
# Multiple services specified as arguments are ``OR``'ed together; the test
|
||||||
# is a short-circuit boolean, i.e it returns on the first match.
|
# is a short-circuit boolean, i.e it returns on the first match.
|
||||||
#
|
#
|
||||||
# Uses global ``ENABLED_PYTHON3_PACKAGES``
|
|
||||||
# python3_enabled_for dir [dir ...]
|
# python3_enabled_for dir [dir ...]
|
||||||
function python3_enabled_for {
|
function python3_enabled_for {
|
||||||
local xtrace
|
local xtrace
|
||||||
@ -132,7 +131,9 @@ function python3_enabled_for {
|
|||||||
local dirs=$@
|
local dirs=$@
|
||||||
local dir
|
local dir
|
||||||
for dir in ${dirs}; do
|
for dir in ${dirs}; do
|
||||||
[[ ,${ENABLED_PYTHON3_PACKAGES}, =~ ,${dir}, ]] && enabled=0
|
if ! python3_disabled_for "${dir}"; then
|
||||||
|
enabled=0
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
$xtrace
|
$xtrace
|
||||||
@ -163,42 +164,29 @@ function python3_disabled_for {
|
|||||||
return $enabled
|
return $enabled
|
||||||
}
|
}
|
||||||
|
|
||||||
# enable_python3_package() adds the repositories passed as argument to the
|
# enable_python3_package() -- no-op for backwards compatibility
|
||||||
# ``ENABLED_PYTHON3_PACKAGES`` list, if they are not already present.
|
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
# enable_python3_package nova
|
# enable_python3_package nova
|
||||||
#
|
#
|
||||||
# Uses global ``ENABLED_PYTHON3_PACKAGES``
|
|
||||||
# enable_python3_package dir [dir ...]
|
# enable_python3_package dir [dir ...]
|
||||||
function enable_python3_package {
|
function enable_python3_package {
|
||||||
local xtrace
|
local xtrace
|
||||||
xtrace=$(set +o | grep xtrace)
|
xtrace=$(set +o | grep xtrace)
|
||||||
set +o xtrace
|
set +o xtrace
|
||||||
|
|
||||||
local tmpsvcs="${ENABLED_PYTHON3_PACKAGES}"
|
echo "It is no longer necessary to call enable_python3_package()."
|
||||||
local python3
|
|
||||||
for dir in $@; do
|
|
||||||
if [[ ,${DISABLED_PYTHON3_PACKAGES}, =~ ,${dir}, ]]; then
|
|
||||||
warn $LINENO "Attempt to enable_python3_package ${dir} when it has been disabled"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
if ! python3_enabled_for $dir; then
|
|
||||||
tmpsvcs+=",$dir"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
ENABLED_PYTHON3_PACKAGES=$(_cleanup_service_list "$tmpsvcs")
|
|
||||||
|
|
||||||
$xtrace
|
$xtrace
|
||||||
}
|
}
|
||||||
|
|
||||||
# disable_python3_package() prepares the services passed as argument to be
|
# disable_python3_package() adds the services passed as argument to
|
||||||
# removed from the ``ENABLED_PYTHON3_PACKAGES`` list, if they are present.
|
# the ``DISABLED_PYTHON3_PACKAGES`` list.
|
||||||
#
|
#
|
||||||
# For example:
|
# For example:
|
||||||
# disable_python3_package swift
|
# disable_python3_package swift
|
||||||
#
|
#
|
||||||
# Uses globals ``ENABLED_PYTHON3_PACKAGES`` and ``DISABLED_PYTHON3_PACKAGES``
|
# Uses global ``DISABLED_PYTHON3_PACKAGES``
|
||||||
# disable_python3_package dir [dir ...]
|
# disable_python3_package dir [dir ...]
|
||||||
function disable_python3_package {
|
function disable_python3_package {
|
||||||
local xtrace
|
local xtrace
|
||||||
@ -206,16 +194,11 @@ function disable_python3_package {
|
|||||||
set +o xtrace
|
set +o xtrace
|
||||||
|
|
||||||
local disabled_svcs="${DISABLED_PYTHON3_PACKAGES}"
|
local disabled_svcs="${DISABLED_PYTHON3_PACKAGES}"
|
||||||
local enabled_svcs=",${ENABLED_PYTHON3_PACKAGES},"
|
|
||||||
local dir
|
local dir
|
||||||
for dir in $@; do
|
for dir in $@; do
|
||||||
disabled_svcs+=",$dir"
|
disabled_svcs+=",$dir"
|
||||||
if python3_enabled_for $dir; then
|
|
||||||
enabled_svcs=${enabled_svcs//,$dir,/,}
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
DISABLED_PYTHON3_PACKAGES=$(_cleanup_service_list "$disabled_svcs")
|
DISABLED_PYTHON3_PACKAGES=$(_cleanup_service_list "$disabled_svcs")
|
||||||
ENABLED_PYTHON3_PACKAGES=$(_cleanup_service_list "$enabled_svcs")
|
|
||||||
|
|
||||||
$xtrace
|
$xtrace
|
||||||
}
|
}
|
||||||
@ -295,7 +278,7 @@ function pip_install {
|
|||||||
if python3_disabled_for ${package_dir##*/}; then
|
if python3_disabled_for ${package_dir##*/}; then
|
||||||
echo "Explicitly using $PYTHON2_VERSION version to install $package_dir based on DISABLED_PYTHON3_PACKAGES"
|
echo "Explicitly using $PYTHON2_VERSION version to install $package_dir based on DISABLED_PYTHON3_PACKAGES"
|
||||||
elif python3_enabled_for ${package_dir##*/}; then
|
elif python3_enabled_for ${package_dir##*/}; then
|
||||||
echo "Explicitly using $PYTHON3_VERSION version to install $package_dir based on ENABLED_PYTHON3_PACKAGES"
|
echo "Using $PYTHON3_VERSION version to install $package_dir based on default behavior"
|
||||||
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
|
sudo_pip="$sudo_pip LC_ALL=en_US.UTF-8"
|
||||||
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
|
cmd_pip=$(get_pip_command $PYTHON3_VERSION)
|
||||||
elif [[ -d "$package_dir" ]]; then
|
elif [[ -d "$package_dir" ]]; then
|
||||||
|
8
stackrc
8
stackrc
@ -129,15 +129,9 @@ fi
|
|||||||
# Control whether Python 3 should be used at all.
|
# Control whether Python 3 should be used at all.
|
||||||
export USE_PYTHON3=$(trueorfalse False USE_PYTHON3)
|
export USE_PYTHON3=$(trueorfalse False USE_PYTHON3)
|
||||||
|
|
||||||
# Control whether Python 3 is enabled for specific services by the
|
|
||||||
# base name of the directory from which they are installed. See
|
|
||||||
# enable_python3_package to edit this variable and use_python3_for to
|
|
||||||
# test membership.
|
|
||||||
export ENABLED_PYTHON3_PACKAGES="nova,glance,cinder,uwsgi,python-openstackclient,openstacksdk"
|
|
||||||
|
|
||||||
# Explicitly list services not to run under Python 3. See
|
# Explicitly list services not to run under Python 3. See
|
||||||
# disable_python3_package to edit this variable.
|
# disable_python3_package to edit this variable.
|
||||||
export DISABLED_PYTHON3_PACKAGES=""
|
export DISABLED_PYTHON3_PACKAGES="swift"
|
||||||
|
|
||||||
# When Python 3 is supported by an application, adding the specific
|
# When Python 3 is supported by an application, adding the specific
|
||||||
# version of Python 3 to this variable will install the app using that
|
# version of Python 3 to this variable will install the app using that
|
||||||
|
@ -12,14 +12,9 @@ source $TOP/tests/unittest.sh
|
|||||||
echo "Testing Python 3 functions"
|
echo "Testing Python 3 functions"
|
||||||
|
|
||||||
# Initialize variables manipulated by functions under test.
|
# Initialize variables manipulated by functions under test.
|
||||||
export ENABLED_PYTHON3_PACKAGES=""
|
|
||||||
export DISABLED_PYTHON3_PACKAGES=""
|
export DISABLED_PYTHON3_PACKAGES=""
|
||||||
|
|
||||||
assert_false "should not be enabled yet" python3_enabled_for testpackage1
|
assert_true "should be enabled by default" python3_enabled_for testpackage1
|
||||||
|
|
||||||
enable_python3_package testpackage1
|
|
||||||
assert_equal "$ENABLED_PYTHON3_PACKAGES" "testpackage1" "unexpected result"
|
|
||||||
assert_true "should be enabled" python3_enabled_for testpackage1
|
|
||||||
|
|
||||||
assert_false "should not be disabled yet" python3_disabled_for testpackage2
|
assert_false "should not be disabled yet" python3_disabled_for testpackage2
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user