-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Increase robustness of Python setup script (#1249)
We've previously run into some minor issues with the Python setup script. This is only natural because shell scripting is hell, but we can still try to make it a little more robust. To this end, this commit adds two new features to the setup script: 1. The setup script now supports ZSH as well as Bash, so it should also work on Mac operating systems. 2. The script now tells the user which version of Python the bindings were set up for, so they don't run into versioning conflicts.
- Loading branch information
1 parent
190d85b
commit de23d56
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,28 @@ | ||
python_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
# This file is part of the Acts project. | ||
# | ||
# Copyright (C) 2021-2022 CERN for the benefit of the Acts project | ||
# | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this | ||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
export PYTHONPATH=$python_dir:$PYTHONPATH | ||
# This script sets up the ACTS Python bindings in the environment in a somewhat | ||
# robust way. | ||
|
||
if [ -n "$ZSH_VERSION" ]; then | ||
export PYTHONPATH=${0:a:h}:$PYTHONPATH | ||
elif [ -n "$BASH_VERSION" ]; then | ||
python_dir=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
export PYTHONPATH=$python_dir:$PYTHONPATH | ||
else | ||
# If the current shell is not ZSH or Bash, we can't guarantee that the | ||
# script will work, so we throw an error. | ||
echo "ERROR: neither ZSH nor Bash was detected, other shells are not supported. The environment has not been modified." | ||
exit 1 | ||
fi | ||
|
||
# This message might seem excessive, but the Acts bindings are only installed | ||
# for one Python version, and it is not trivial for the user to find out which. | ||
# Thus, we let them know explicitly so they can more easily debug any potential | ||
# import errors. | ||
echo "INFO: Acts Python @Python_VERSION_MAJOR@.@Python_VERSION_MINOR@ bindings setup complete." |