github上Devstack的一些变动,截至8.20

从github下直接clone下来的代码在执行之前须要对一些文件进行改动,否则会出现关于REQUIREMENTS的错误


说明:代码前边是"-"号的,须要删除,代码前边是“+”号的,是须要加入上去的。注意区分哪些是凝视,哪些是代码,只是多解释了。


1./inc/python

66行,function pip_install_gr {     #这个函数内

# Wrapper for ``pip install`` to set cache and proxy environment variables
 # Uses globals ``OFFLINE``, ``PIP_VIRTUAL_ENV``,
-# ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``
+# ``PIP_UPGRADE``, ``TRACK_DEPENDS``, ``*_proxy``,
+# ``REQUIREMENTS_MODE``
 # pip_install package [package ...]
 function pip_install {
     local xtrace=$(set +o | grep xtrace)


103行。function pip_install { #这个函数内

 fi
     fi
 
+    cmd_pip="$cmd_pip install"
+
+    # Handle a constraints file, if needed.
+    if [ "$REQUIREMENTS_MODE" == "constraints" -a -n "$REQUIREMENTS_DIR" ]; then
+        cmd_pip="$cmd_pip -c $REQUIREMENTS_DIR/upper-constraints.txt"
+    fi
+
     local pip_version=$(python -c "import pip; \
                         print(pip.__version__.strip('.')[0])")
     if (( pip_version<6 )); then



116行。function pip_install { #这个函数内

https_proxy="${https_proxy:-}" \
         no_proxy="${no_proxy:-}" \
         PIP_FIND_LINKS=$PIP_FIND_LINKS \
-        $cmd_pip install $upgrade \
+        $cmd_pip $upgrade \
         $@
 
     # Also install test requirements



128行,function pip_install { #这个函数内

https_proxy=${https_proxy:-} \
             no_proxy=${no_proxy:-} \
             PIP_FIND_LINKS=$PIP_FIND_LINKS \
-            $cmd_pip install $upgrade \</span>
+            $cmd_pip $upgrade \</span>
             -r $test_req
     fi<span style="color:#aa22aa;">





215行,说明:这个函数我并没有在源文件里找到。不知道是不是须要自己手动加入,假设有知道结果的希望能够告诉我。

function setup_package_with_req_sync { #这个函数内

 # ``errexit`` requires us to trap the exit code when the repo is changed
     local update_requirements=$(cd $project_dir && git diff --exit-code >/dev/null || echo "changed")
 
-    if [[ $update_requirements != "changed" ]]; then</span>
+    if [[ $update_requirements != "changed" && "$REQUIREMENTS_MODE" != "constraints" ]]; then
         if is_in_projects_txt $project_dir; then
             (cd $REQUIREMENTS_DIR; \
                 ./.venv/bin/python update.py $project_dir)


2.  /lib/infra

33行。

<div class="diff ctx"># bring down global requirements</div><div class="diff ctx">     git_clone $REQUIREMENTS_REPO $REQUIREMENTS_DIR $REQUIREMENTS_BRANCH</div><div class="diff ctx">     [ ! -d $PIP_VIRTUAL_ENV ] && virtualenv $PIP_VIRTUAL_ENV</div><div class="diff add">+    # XXX: Remove when 7.1 is released.</div><div class="diff add">+    $REQUIREMENTS_DIR/.venv/bin/pip install -U git+https://github.com/pypa/pip@develop#egg=pip</div><div class="diff ctx">     # We don't care about testing git pbr in the requirements venv.</div><div class="diff ctx">     PIP_VIRTUAL_ENV=$PIP_VIRTUAL_ENV pip_install -U pbr</div><div class="diff ctx">     PIP_VIRTUAL_ENV=$PIP_VIRTUAL_ENV pip_install $REQUIREMENTS_DIR</div>


3../stack.sh


685行,

# Configure an appropriate Python environment
 if [[ "$OFFLINE" != "True" ]]; then
+    REQUIREMENTS_MODE=${REQUIREMENTS_MODE:-} \
     PYPI_ALTERNATIVE_URL=${PYPI_ALTERNATIVE_URL:-""} $TOP_DIR/tools/install_pip.sh
 fi


699行。

virtualenv --system-site-packages $DEST/.venv
     source $DEST/.venv/bin/activate
     $DEST/.venv/bin/pip freeze > $DEST/requires-pre-pip
+    # XXX: Remove when 7.1 is released.
+    $DEST/.venv/bin/pip install -U git+https://github.com/pypa/pip@develop#egg=pip
 fi
 
 # Do the ugly hacks for broken packages and distros



4.   ./stackrc

149行,

# Zero disables timeouts
 GIT_TIMEOUT=${GIT_TIMEOUT:-0}
 
+# Requirements enforcing mode
+#
+# - strict (default) : ensure projects.txt requirements files match
+#   what's in global requirements.
+#
+# - constraints : do not modify project requirements at all. Instead
+#   use upper-constraints.txt to constraint the versions of things installed
+#   via pip for all pip invocations made during stack.sh.
+REQUIREMENTS_MODE=${REQUIREMENTS_MODE:-strict}
 
 # Repositories
 # ------------


5.  /tools/build_wheel.sh

56行。

# Prepare the workspace
 TMP_VENV_PATH=$(mktemp -d tmp-venv-XXXX)
 virtualenv $TMP_VENV_PATH
+# Back this out when 7.1 is released.
+$TMP_VENV_PATH/bin/pip install -U git+https://github.com/pypa/pip@develop#egg=pip
 
 # Install modern pip and wheel
-PIP_VIRTUAL_ENV=$TMP_VENV_PATH pip_install -U pip wheel
+PIP_VIRTUAL_ENV=$TMP_VENV_PATH pip_install -U wheel
 
 # BUG: cffi has a lot of issues. It has no stable ABI, if installed
 # code is built with a different ABI than the one that's detected at



6. /tools/install_pip.sh

62行。

function install_get_pip {
 }
 
 
+function install_constraints_pip {
+    # Constraints requires pip 7.1.0 or newer. For now, when constraints are
+    # used, if -c isn't in the help, install develop.
+    if !(pip install -h | grep -- --constraint); then
+        sudo -H -E python -m pip install -U git+https://github.com/pypa/pip@develop#egg=pip
+    fi
+}
+
+
 function configure_pypi_alternative_url {
     PIP_ROOT_FOLDER="$HOME/.pip"
     PIP_CONFIG_FILE="$PIP_ROOT_FOLDER/pip.conf"



97行,

get_versions
 uninstall_package python-pip
 
 install_get_pip
+if [[ "$REQUIREMENTS_MODE" == "constraints" ]]; then
+    install_constraints_pip
+fi
 
 if [[ -n $PYPI_ALTERNATIVE_URL ]]; then
     configure_pypi_alternative_url


再说一下,改动代码的时候,加号和减号记得自己删除掉,别直接都粘贴上去了。


posted @ 2017-05-25 10:32  mfmdaoyou  阅读(202)  评论(0编辑  收藏  举报