Skip to content

Commit

Permalink
Merge pull request #387 from sclorg/pipenv_improvements
Browse files Browse the repository at this point in the history
[CRITICAL] Pipenv-related improvements
  • Loading branch information
frenzymadness authored Jun 17, 2020
2 parents ad559b7 + cc88a2e commit 0620214
Show file tree
Hide file tree
Showing 24 changed files with 212 additions and 65 deletions.
20 changes: 13 additions & 7 deletions 2.7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Note: while the examples in this README are calling `podman`, you can replace an
Description
-----------

Python 2.7 available as container is a base platform for
building and running various Python 2.7 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
Python 2.7 available as container is a base platform for
building and running various Python 2.7 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
on most platforms.

This container image includes an npm utility
Expand Down Expand Up @@ -123,11 +123,17 @@ file inside your source code repository.

* **ENABLE_PIPENV**

Set this variable to use [Pipenv](https://github.com/kennethreitz/pipenv),
Set this variable to use [Pipenv](https://github.com/pypa/pipenv),
the higher-level Python packaging tool, to manage dependencies of the application.
This should be used only if your project contains properly formated Pipfile
and Pipfile.lock. (Implies `UPGRADE_PIP_TO_LATEST` to satisfy dependencies of
Pipenv.)
* **PIN_PIPENV_VERSION**

Set this variable together with `ENABLE_PIPENV` to use a specific version of Pipenv.
If not set, the latest stable version from PyPI is installed.
For example `PIN_PIPENV_VERSION=2018.11.26` installs `pipenv==2018.11.26`.


* **ENABLE_INIT_WRAPPER**

Expand Down
16 changes: 14 additions & 2 deletions 2.7/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ function install_tool() {
pip install -U virtualenv
VENV_DIR=$HOME/.local/venvs/$1
virtualenv_bin "$VENV_DIR"
$VENV_DIR/bin/pip --isolated install -U $1$2 # Combines package name with [extras] if [extras] is defined as $2
# First, try to install the tool without --isolated which means that if you
# have your own PyPI mirror, it will take it from there. If this try fails, try it
# again with --isolated which ignores external pip settings (env vars, config file)
# and installs the tool from PyPI (needs internet connetion).
$VENV_DIR/bin/pip install -U $1$2 # Combines package name with [extras] or version specifier if is defined as $2```
if [ $? -ne 0 ]; then
echo "WARNING: Installation of $1 failed, trying again from official PyPI with pip --isolated install"
$VENV_DIR/bin/pip install -U $1$2 # Combines package name with [extras] or version specifier if is defined as $2```
fi
mkdir -p $HOME/.local/bin
ln -s $VENV_DIR/bin/$1 $HOME/.local/bin/$1
}
Expand Down Expand Up @@ -63,7 +71,11 @@ if [[ ! -z "$UPGRADE_PIP_TO_LATEST" || ! -z "$ENABLE_PIPENV" ]]; then
fi

if [[ ! -z "$ENABLE_PIPENV" ]]; then
install_tool "pipenv" "==2018.11.26"
if [[ ! -z "$PIN_PIPENV_VERSION" ]]; then
# Add == as a prefix to pipenv version, if defined
PIN_PIPENV_VERSION="==$PIN_PIPENV_VERSION"
fi
install_tool "pipenv" "$PIN_PIPENV_VERSION"
echo "---> Installing dependencies via pipenv ..."
if [[ -f Pipfile ]]; then
pipenv install --deploy
Expand Down
1 change: 1 addition & 0 deletions 2.7/test/pin-pipenv-version-test-app
11 changes: 7 additions & 4 deletions 2.7/test/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
#
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,npm-virtualenv-uwsgi,locale,mod-wsgi,pipenv,pipenv-and-micropipenv-should-fail}-test-app)
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,npm-virtualenv-uwsgi,locale,mod-wsgi,pipenv,pipenv-and-micropipenv-should-fail,pin-pipenv-version}-test-app)

# TODO: Make command compatible for Mac users
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"
Expand Down Expand Up @@ -86,7 +86,7 @@ check_result() {
# positive test & non-zero exit status = ERROR
# negative test & zero exit status = ERROR
local result="$1"
local test=${2:-positive} # if not defined, we expect possitive test type (zero exit code)
local type=${2:-positive} # if not defined, we expect possitive test type (zero exit code)
if [[ "$type" == "positive" && "$result" != "0" ]]; then
info "TEST FAILED (${type}), EXPECTED:0 GOT:${result}"
cleanup
Expand All @@ -102,13 +102,13 @@ wait_for_cid() {
local max_attempts=10
local sleep_time=1
local attempt=1
local result=1
info "Waiting for application container to start $CONTAINER_ARGS ..."
while [ $attempt -le $max_attempts ]; do
[ -f $cid_file ] && [ -s $cid_file ] && break
[ -f $cid_file ] && [ -s $cid_file ] && return 0
attempt=$(( $attempt + 1 ))
sleep $sleep_time
done
return 1
}

test_s2i_usage() {
Expand Down Expand Up @@ -172,6 +172,9 @@ test_application() {

# Wait for the container to write it's CID file
wait_for_cid
# Some test apps have tests in their startup code so we have to check
# that the container starts at all
check_result $?

test_scl_usage "python --version" "Python $VERSION." "${cid_file}"
check_result $?
Expand Down
20 changes: 13 additions & 7 deletions 3.6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Note: while the examples in this README are calling `podman`, you can replace an
Description
-----------

Python 3.6 available as container is a base platform for
building and running various Python 3.6 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
Python 3.6 available as container is a base platform for
building and running various Python 3.6 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
on most platforms.

This container image includes an npm utility
Expand Down Expand Up @@ -123,10 +123,16 @@ file inside your source code repository.

* **ENABLE_PIPENV**

Set this variable to use [Pipenv](https://github.com/kennethreitz/pipenv),
Set this variable to use [Pipenv](https://github.com/pypa/pipenv),
the higher-level Python packaging tool, to manage dependencies of the application.
This should be used only if your project contains properly formated Pipfile
and Pipfile.lock.
* **PIN_PIPENV_VERSION**

Set this variable together with `ENABLE_PIPENV` to use a specific version of Pipenv.
If not set, the latest stable version from PyPI is installed.
For example `PIN_PIPENV_VERSION=2018.11.26` installs `pipenv==2018.11.26`.

* **ENABLE_MICROPIPENV**

Set this variable to use [micropipenv](https://github.com/thoth-station/micropipenv),
Expand Down
16 changes: 14 additions & 2 deletions 3.6/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,15 @@ function install_tool() {
echo "---> Installing $1 packaging tool ..."
VENV_DIR=$HOME/.local/venvs/$1
virtualenv_bin "$VENV_DIR"
$VENV_DIR/bin/pip --isolated install -U $1$2 # Combines package name with [extras] if [extras] is defined as $2
# First, try to install the tool without --isolated which means that if you
# have your own PyPI mirror, it will take it from there. If this try fails, try it
# again with --isolated which ignores external pip settings (env vars, config file)
# and installs the tool from PyPI (needs internet connetion).
$VENV_DIR/bin/pip install -U $1$2 # Combines package name with [extras] or version specifier if is defined as $2```
if [ $? -ne 0 ]; then
echo "WARNING: Installation of $1 failed, trying again from official PyPI with pip --isolated install"
$VENV_DIR/bin/pip install -U $1$2 # Combines package name with [extras] or version specifier if is defined as $2```
fi
mkdir -p $HOME/.local/bin
ln -s $VENV_DIR/bin/$1 $HOME/.local/bin/$1
}
Expand Down Expand Up @@ -62,7 +70,11 @@ if [[ ! -z "$UPGRADE_PIP_TO_LATEST" ]]; then
fi

if [[ ! -z "$ENABLE_PIPENV" ]]; then
install_tool "pipenv" "==2018.11.26"
if [[ ! -z "$PIN_PIPENV_VERSION" ]]; then
# Add == as a prefix to pipenv version, if defined
PIN_PIPENV_VERSION="==$PIN_PIPENV_VERSION"
fi
install_tool "pipenv" "$PIN_PIPENV_VERSION"
echo "---> Installing dependencies via pipenv ..."
if [[ -f Pipfile ]]; then
pipenv install --deploy
Expand Down
1 change: 1 addition & 0 deletions 3.6/test/pin-pipenv-version-test-app
11 changes: 7 additions & 4 deletions 3.6/test/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
#
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,npm-virtualenv-uwsgi,locale,mod-wsgi,pipenv,pipenv-and-micropipenv-should-fail,micropipenv,micropipenv-requirements}-test-app)
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,npm-virtualenv-uwsgi,locale,mod-wsgi,pipenv,pipenv-and-micropipenv-should-fail,pin-pipenv-version,micropipenv,micropipenv-requirements}-test-app)

# TODO: Make command compatible for Mac users
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"
Expand Down Expand Up @@ -86,7 +86,7 @@ check_result() {
# positive test & non-zero exit status = ERROR
# negative test & zero exit status = ERROR
local result="$1"
local test=${2:-positive} # if not defined, we expect possitive test type (zero exit code)
local type=${2:-positive} # if not defined, we expect possitive test type (zero exit code)
if [[ "$type" == "positive" && "$result" != "0" ]]; then
info "TEST FAILED (${type}), EXPECTED:0 GOT:${result}"
cleanup
Expand All @@ -102,13 +102,13 @@ wait_for_cid() {
local max_attempts=10
local sleep_time=1
local attempt=1
local result=1
info "Waiting for application container to start $CONTAINER_ARGS ..."
while [ $attempt -le $max_attempts ]; do
[ -f $cid_file ] && [ -s $cid_file ] && break
[ -f $cid_file ] && [ -s $cid_file ] && return 0
attempt=$(( $attempt + 1 ))
sleep $sleep_time
done
return 1
}

test_s2i_usage() {
Expand Down Expand Up @@ -172,6 +172,9 @@ test_application() {

# Wait for the container to write it's CID file
wait_for_cid
# Some test apps have tests in their startup code so we have to check
# that the container starts at all
check_result $?

test_scl_usage "python --version" "Python $VERSION." "${cid_file}"
check_result $?
Expand Down
20 changes: 13 additions & 7 deletions 3.7/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Note: while the examples in this README are calling `podman`, you can replace an
Description
-----------

Python 3.7 available as container is a base platform for
building and running various Python 3.7 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
Python 3.7 available as container is a base platform for
building and running various Python 3.7 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
on most platforms.

This container image includes an npm utility
Expand Down Expand Up @@ -123,10 +123,16 @@ file inside your source code repository.

* **ENABLE_PIPENV**

Set this variable to use [Pipenv](https://github.com/kennethreitz/pipenv),
Set this variable to use [Pipenv](https://github.com/pypa/pipenv),
the higher-level Python packaging tool, to manage dependencies of the application.
This should be used only if your project contains properly formated Pipfile
and Pipfile.lock.
* **PIN_PIPENV_VERSION**

Set this variable together with `ENABLE_PIPENV` to use a specific version of Pipenv.
If not set, the latest stable version from PyPI is installed.
For example `PIN_PIPENV_VERSION=2018.11.26` installs `pipenv==2018.11.26`.

* **ENABLE_MICROPIPENV**

Set this variable to use [micropipenv](https://github.com/thoth-station/micropipenv),
Expand Down
16 changes: 14 additions & 2 deletions 3.7/s2i/bin/assemble
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,15 @@ function install_tool() {
echo "---> Installing $1 packaging tool ..."
VENV_DIR=$HOME/.local/venvs/$1
virtualenv_bin "$VENV_DIR"
$VENV_DIR/bin/pip --isolated install -U $1$2 # Combines package name with [extras] if [extras] is defined as $2
# First, try to install the tool without --isolated which means that if you
# have your own PyPI mirror, it will take it from there. If this try fails, try it
# again with --isolated which ignores external pip settings (env vars, config file)
# and installs the tool from PyPI (needs internet connetion).
$VENV_DIR/bin/pip install -U $1$2 # Combines package name with [extras] or version specifier if is defined as $2```
if [ $? -ne 0 ]; then
echo "WARNING: Installation of $1 failed, trying again from official PyPI with pip --isolated install"
$VENV_DIR/bin/pip install -U $1$2 # Combines package name with [extras] or version specifier if is defined as $2```
fi
mkdir -p $HOME/.local/bin
ln -s $VENV_DIR/bin/$1 $HOME/.local/bin/$1
}
Expand Down Expand Up @@ -58,7 +66,11 @@ if [[ ! -z "$UPGRADE_PIP_TO_LATEST" ]]; then
fi

if [[ ! -z "$ENABLE_PIPENV" ]]; then
install_tool "pipenv" "==2018.11.26"
if [[ ! -z "$PIN_PIPENV_VERSION" ]]; then
# Add == as a prefix to pipenv version, if defined
PIN_PIPENV_VERSION="==$PIN_PIPENV_VERSION"
fi
install_tool "pipenv" "$PIN_PIPENV_VERSION"
echo "---> Installing dependencies via pipenv ..."
if [[ -f Pipfile ]]; then
pipenv install --deploy
Expand Down
1 change: 1 addition & 0 deletions 3.7/test/pin-pipenv-version-test-app
11 changes: 7 additions & 4 deletions 3.7/test/run
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# IMAGE_NAME specifies a name of the candidate image used for testing.
# The image has to be available before this script is executed.
#
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,npm-virtualenv-uwsgi,locale,mod-wsgi,pipenv,pipenv-and-micropipenv-should-fail,micropipenv,micropipenv-requirements}-test-app)
declare -a WEB_APPS=({standalone,setup,setup-requirements,django,numpy,app-home,npm-virtualenv-uwsgi,locale,mod-wsgi,pipenv,pipenv-and-micropipenv-should-fail,pin-pipenv-version,micropipenv,micropipenv-requirements}-test-app)

# TODO: Make command compatible for Mac users
test_dir="$(readlink -zf $(dirname "${BASH_SOURCE[0]}"))"
Expand Down Expand Up @@ -86,7 +86,7 @@ check_result() {
# positive test & non-zero exit status = ERROR
# negative test & zero exit status = ERROR
local result="$1"
local test=${2:-positive} # if not defined, we expect possitive test type (zero exit code)
local type=${2:-positive} # if not defined, we expect possitive test type (zero exit code)
if [[ "$type" == "positive" && "$result" != "0" ]]; then
info "TEST FAILED (${type}), EXPECTED:0 GOT:${result}"
cleanup
Expand All @@ -102,13 +102,13 @@ wait_for_cid() {
local max_attempts=10
local sleep_time=1
local attempt=1
local result=1
info "Waiting for application container to start $CONTAINER_ARGS ..."
while [ $attempt -le $max_attempts ]; do
[ -f $cid_file ] && [ -s $cid_file ] && break
[ -f $cid_file ] && [ -s $cid_file ] && return 0
attempt=$(( $attempt + 1 ))
sleep $sleep_time
done
return 1
}

test_s2i_usage() {
Expand Down Expand Up @@ -172,6 +172,9 @@ test_application() {

# Wait for the container to write it's CID file
wait_for_cid
# Some test apps have tests in their startup code so we have to check
# that the container starts at all
check_result $?

test_scl_usage "python --version" "Python $VERSION." "${cid_file}"
check_result $?
Expand Down
20 changes: 13 additions & 7 deletions 3.8/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ Note: while the examples in this README are calling `podman`, you can replace an
Description
-----------

Python 3.8 available as container is a base platform for
building and running various Python 3.8 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
Python 3.8 available as container is a base platform for
building and running various Python 3.8 applications and frameworks.
Python is an easy to learn, powerful programming language. It has efficient high-level
data structures and a simple but effective approach to object-oriented programming.
Python's elegant syntax and dynamic typing, together with its interpreted nature,
make it an ideal language for scripting and rapid application development in many areas
on most platforms.

This container image includes an npm utility
Expand Down Expand Up @@ -123,10 +123,16 @@ file inside your source code repository.

* **ENABLE_PIPENV**

Set this variable to use [Pipenv](https://github.com/kennethreitz/pipenv),
Set this variable to use [Pipenv](https://github.com/pypa/pipenv),
the higher-level Python packaging tool, to manage dependencies of the application.
This should be used only if your project contains properly formated Pipfile
and Pipfile.lock.
* **PIN_PIPENV_VERSION**

Set this variable together with `ENABLE_PIPENV` to use a specific version of Pipenv.
If not set, the latest stable version from PyPI is installed.
For example `PIN_PIPENV_VERSION=2018.11.26` installs `pipenv==2018.11.26`.

* **ENABLE_MICROPIPENV**

Set this variable to use [micropipenv](https://github.com/thoth-station/micropipenv),
Expand Down
Loading

0 comments on commit 0620214

Please # to comment.