-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing "externally-managed-environment" problem with pip (#9)
* Using a python venv by default for groundlight python SDK stuff. * Fixing cv2 issue, and readme install. * Fixup file location.
- Loading branch information
1 parent
92449ab
commit b384791
Showing
5 changed files
with
50 additions
and
16 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,11 +1,15 @@ | ||
# Absolute basics | ||
python3 python3-pip | ||
python3 python-is-python3 | ||
|
||
# Install python libraries | ||
# (We'd rather install this stuff with pip or poetry, but pip struggles inside chroot for anything | ||
# complicated. So for now this works.) | ||
python3-opencv python3-numpy | ||
python3-pydantic python3-pil python3-yaml | ||
# we don't install things like python3-pip or many libraries here, because pip and apt don't | ||
# get along, so we'll set up a venv later. | ||
|
||
# Nice-to-have utilities | ||
iotop nethogs net-tools telnet | ||
# We'll set up a venv to get around this. | ||
python3-venv | ||
|
||
# We do install OS's opencv to make sure all the .so files are available. | ||
python3-opencv | ||
|
||
# Some nice-to-have utilities | ||
iotop nethogs net-tools telnet | ||
git curl wget |
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,9 +1,14 @@ | ||
#!/bin/bash -e | ||
|
||
pipit() { | ||
/usr/bin/pip3 $@ --break-system-packages | ||
} | ||
# set up a groundlight virtual environment for python | ||
python3 -m venv /opt/groundlight/gl-py | ||
chmod a+rw -R /opt/groundlight/gl-py | ||
source /opt/groundlight/gl-py/bin/activate | ||
|
||
pipit install groundlight | ||
# Framegrab will try to re-install opencv, which won't go well. | ||
pipit install --no-deps framegrab | ||
# Now install the groundlight python libraries | ||
pip install groundlight | ||
# framegrab will install opencv-python, numpy, and pillow | ||
pip install framegrab | ||
|
||
# add a .bashrc entry to activate the groundlight virtual environment | ||
echo "source /opt/groundlight/gl-py/bin/activate" >> /home/${FIRST_USER_NAME}/.bashrc |
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,5 @@ | ||
#!/bin/bash -e | ||
|
||
GL_DIR="${ROOTFS_DIR}/opt/groundlight" | ||
|
||
install -v files/gl-py-README.md "${GL_DIR}/gl-py/README.md" |
21 changes: 21 additions & 0 deletions
21
stage-gl1/01-install-python-libraries/files/gl-py-README.md
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,21 @@ | ||
# Groundlight Python Libraries | ||
We have set up a python virtual environment (`venv`) for you to use. To activate it, run: | ||
|
||
``` | ||
source /opt/groundlight/gl-py/bin/activate | ||
``` | ||
|
||
(This line is already in your .bashrc file, so you probably don't need to run it yourself.) | ||
|
||
Some might think this is unnecessarily complicated, or not how they'd like to manage their | ||
python systems. We understand. We have chosen this approach because it is the most | ||
natural for many users, especially those who "just want to use pip thank you very much." | ||
This attitude is extremely understandable, however modern python (3.11) and debian/ubuntu | ||
systems have made this difficult with the "externally-managed-environment" feature | ||
which basically prevents you from using pip without a virtual environment. | ||
|
||
If you like `conda`, `mamba`, `poetry`, `pyenv`, or some other python environment manager, | ||
so do we! Please go ahead and use them. Hopefully this default has not gotten in your way. | ||
If it is, please [get in touch](https://github.com/groundlight/groundlight-pi-gen/issues). | ||
|
||
Happy visual understanding! |