-
Notifications
You must be signed in to change notification settings - Fork 1
Dingpf/python_venv #51
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
4c5327b
Initial commit to address issue #50
dingp 660caeb
initial complete version of setup_python_env
dingp 3cbae68
print out more status info in setup_python_venv
dingp fe175be
calling setup_python_venv in quick-start.sh
dingp 8987be6
changed the checkout branch of daq-buildtools to be python-venv; will…
dingp 318723e
changed the checkout branch of daq-buildtools to be python-venv; will…
dingp 68e71d8
use symlink to setup_python_venv
dingp 9210abb
add overwriting flag in setup_python_env for handling local copy of p…
4ec2be3
add moo into the requirements.txt with URL to its github repo; remove…
3de2fa3
revert changes for moo in requirements.txt and its handling in setup_…
9313c1b
revert changes for moo in requirements.txt and its handling in setup_…
4072c7c
Update pyvenv_requirements.txt
dingp f0694cd
fix a bug when checking if overwriting local copies of requirements.t…
28b3045
JCF: change the on-error exits in setup_python_venv to returns since …
f34de8a
JCF: Revert "changed the checkout branch of daq-buildtools to be pyth…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
anyconfig==0.9.11 | ||
attrs==20.2.0 | ||
click==7.1.2 | ||
et-xmlfile==1.0.1 | ||
fastjsonschema==2.14.5 | ||
jdcal==1.4.1 | ||
Jinja2==2.11.2 | ||
jsonnet==0.16.0 | ||
jsonpointer==2.0 | ||
jsonschema==3.2.0 | ||
MarkupSafe==1.1.1 | ||
numpy==1.19.4 | ||
openpyxl==3.0.5 | ||
pyrsistent==0.17.3 | ||
six==1.15.0 | ||
# Comment out moo, as by default PyPI's moo will be picked up. | ||
# moo==0.2.0 | ||
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#!/bin/bash | ||
|
||
WORK_DIR=$PWD | ||
timenow="date \"+%D %T\"" | ||
|
||
requirements_edit_overwrite=true | ||
|
||
### | ||
# Default virtual env name | ||
### | ||
VENV_NAME="moo_venv" | ||
|
||
### | ||
# Check if inside a virtualenv already | ||
### | ||
if [[ "$VIRTUAL_ENV" != "" ]] | ||
then | ||
echo "ERROR: [`eval $timenow`]: You are already in a virtual env. Please deactivate first." | ||
exit 11 | ||
fi | ||
|
||
### | ||
# Check if python from cvmfs has been set up. | ||
# Add version check in the future. | ||
### | ||
if [ -z "$SETUP_PYTHON" ]; then | ||
echo "INFO [`eval $timenow`]: Python UPS product is not set, setting it from cvmfs now." | ||
setup python | ||
if [[ $? != "0" ]]; then | ||
echo "ERROR [`eval $timenow`]: setup python failed, please check if you have sourced the \"setup_build_environment\" script and run this script again." | ||
exit 10 | ||
fi | ||
else | ||
echo "INFO [`eval $timenow`]: Python UPS product $PYTHON_VERSION has been set up." | ||
fi | ||
|
||
### | ||
# Check existance/create the default virtual_env | ||
### | ||
if [ -f "$WORK_DIR/$VENV_NAME/pyvenv.cfg" ]; then | ||
echo "INFO [`eval $timenow`]: virtual_env $VENV_NAME already exists. " | ||
cat "$WORK_DIR/$VENV_NAME/pyvenv.cfg" | ||
else | ||
echo "INFO [`eval $timenow`]: creating virtual_env $VENV_NAME. " | ||
python -m venv $VENV_NAME | ||
fi | ||
|
||
### | ||
# Activate the venv | ||
### | ||
echo "INFO [`eval $timenow`]: activating virtual_env $VENV_NAME. " | ||
source $WORK_DIR/$VENV_NAME/bin/activate | ||
|
||
### | ||
# Install required modules except moo | ||
### | ||
if [ -f "$WORK_DIR/pyvenv_requirements.txt" ]; then | ||
echo "INFO [`eval $timenow`]: found existing requirements file: $WORK_DIR/pyvenv_requirements.txt" | ||
if [ $requirements_edit_overwrite ]; then | ||
curl -o $WORK_DIR/.tmp_python_setup https://raw.githubusercontent.com/DUNE-DAQ/daq-buildtools/dingpf/python-venv/scripts/pyvenv_requirements.txt | ||
diff_req=$(diff $WORK_DIR/.tmp_python_setup $WORK_DIR/pyvenv_requirements.txt) | ||
if [[ -n $diff_req ]]; then | ||
echo "INFO [`eval $timenow`]: Overwriting is turned on. The exisiting file will be moved to: $moved_req" | ||
moved_req=$WORK_DIR/pyvenv_requirements.txt.`date "+%y%m%d%H%M%S"` | ||
mv $WORK_DIR/pyvenv_requirements.txt $moved_req | ||
mv $WORK_DIR/.tmp_python_setup $WORK_DIR/pyvenv_requirements.txt | ||
else | ||
rm -f $WORK_DIR/.tmp_python_setup | ||
fi | ||
fi | ||
else | ||
curl -O https://raw.githubusercontent.com/DUNE-DAQ/daq-buildtools/dingpf/python-venv/scripts/pyvenv_requirements.txt | ||
fi | ||
echo "INFO [`eval $timenow`]: checking/installing required modules for virtual_env $VENV_NAME. " | ||
python -m pip install -r pyvenv_requirements.txt | ||
if [[ $? != "0" ]]; then | ||
echo "ERROR [`eval $timenow`]: Installing required modules failed." | ||
exit 12 | ||
fi | ||
|
||
### | ||
# special handling of the moo module since PyPI has a module with same name. | ||
### | ||
if python -c "import moo" &> /dev/null; then | ||
echo "INFO [`eval $timenow`]: moo is installed." | ||
pip list|grep moo | ||
else | ||
echo "INFO [`eval $timenow`]: moo is not installed. Install it now." | ||
pip install git+git://github.com/brettviren/moo.git | ||
if [[ $? != "0" ]]; then | ||
echo "ERROR [`eval $timenow`]: Installing moo failed." | ||
exit 13 | ||
fi | ||
fi | ||
|
||
|
||
echo "INFO [`eval $timenow`]: $VEVN_NAME has been activated, use \"deactivate\" to exit the venv." |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You might be able to replace these lines with one like:
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 suggestion. I tried it in this commit 4ec2be3.
But it looks like pip was still checking the moo in PyPI. I got the error messages as the following: