-
Notifications
You must be signed in to change notification settings - Fork 313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix venv detection with venv and Rally execution on non master #449
Fix venv detection with venv and Rally execution on non master #449
Conversation
This commit fixes two issues. Firstly, let `./rally` start when executed for the first time with self update disabled (e.g. from a non master branch in a fork) by ensuring the `esrally` binary has been installed with setuptools. Secondly, fix virtualenv detection when pyenv is in use. On some configurations when pyenv is present, creating a Python3 virtualenv uses pyvenv instead of Python3's own virtualenv[1] which fails the current check for a virtualenv in the `run.sh` script. [1] https://legacy.python.org/dev/peps/pep-0405/ Closes elastic#447 Closes elastic#448
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. I left a few suggestions otherwise LGTM.
function install_esrally_with_setuptools() { | ||
# Check if optional parameter with Rally binary path, points to an existing executable file. | ||
if [[ -n $1 ]]; then | ||
if [[ -f $1 && -x $1 ]]; then return; fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to enclose the parameter in double quotes to avoid issues with spaces in path names? (i.e. "${1}"
?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Double quotes are needed only for the backwards compatible [
. Double square braces do not require double quoting for the variables.
run.sh
Outdated
# Attempt to update Rally itself by default but allow user to skip it. | ||
SELF_UPDATE=YES | ||
# Assume that the "main remote" is called "origin" | ||
REMOTE="origin" | ||
|
||
# While we could also check via the presence of `VIRTUAL_ENV` this is a bit more reliable. | ||
python3 -c 'import sys; print(sys.real_prefix)' >/dev/null 2>&1 && IN_VIRTUALENV=1 || IN_VIRTUALENV=0 | ||
# Check for both pyvenv and normal venv environments | ||
# https://legacy.python.org/dev/peps/pep-0405/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason why you linked to the legacy site instead of https://www.python.org/dev/peps/pep-0405/?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will address
run.sh
Outdated
python3 -c 'import sys; print(sys.real_prefix)' >/dev/null 2>&1 && IN_VIRTUALENV=1 || IN_VIRTUALENV=0 | ||
# Check for both pyvenv and normal venv environments | ||
# https://legacy.python.org/dev/peps/pep-0405/ | ||
if python3 -c 'import sys; sys.exit(0) if ".pyenv" in sys.base_prefix else exit(0) if hasattr(sys,"real_path") else exit(1)' >/dev/null 2>&1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the following would be a bit simpler?
import sys; exit(0) if ".pyenv" in sys.base_prefix or hasattr(sys,"real_path") else exit(1)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changing the logic entirely here as per our discussion.
With this commit we use the syntax `function X` instead of `function X()` which is more compatible and also works with older bash versions (such as the one on MacOS). See also the [GNU bash docs on shell functions](https://www.gnu.org/software/bash/manual/bash.html#Shell-Functions). Relates #449
This commit fixes two issues. Firstly, let
./rally
start whenexecuted for the first time with self update disabled (e.g. from a non
master branch in a fork) by ensuring the
esrally
binary has beeninstalled with setuptools.
Secondly, fix virtualenv detection when pyenv is in use. On some
configurations when pyenv is present, creating a Python3 virtualenv
uses pyvenv instead of Python3's own virtualenv[1] which fails the
current check for a virtualenv in the
run.sh
script.[1] https://legacy.python.org/dev/peps/pep-0405/
Closes #447
Closes #448