Skip to content

Commit

Permalink
feat: dev pkg improvements (WIP)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdmccormick committed Feb 7, 2023
1 parent bbab35e commit 683f43c
Show file tree
Hide file tree
Showing 5 changed files with 76 additions and 9 deletions.
10 changes: 7 additions & 3 deletions tutor/templates/build/openedx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ RUN pip install uwsgi==2.0.21

# Install private requirements: this is useful for installing custom xblocks.
COPY ./requirements/ /openedx/requirements
RUN cd /openedx/requirements/ \
&& touch ./private.txt \
&& pip install -r ./private.txt
COPY ./bin/pip-install-all /openedx/bin/pip-install-all
RUN chmod a+x /openedx/bin/pip-install-all
RUN /openedx/bin/pip-install-all /openedx/requirements

{% for extra_requirements in OPENEDX_EXTRA_PIP_REQUIREMENTS %}RUN pip install '{{ extra_requirements }}'
{% endfor %}
Expand Down Expand Up @@ -224,6 +224,10 @@ RUN pip install -r requirements/edx/development.txt
# https://pypi.org/project/ipython
RUN pip install ipdb==0.13.9 ipython==8.7.0

# Install private development-only requirements
COPY ./requirements-dev /openedx/requirements-dev
RUN /openedx/bin/pip-install-all /openedx/requirements-dev

# Add ipdb as default PYTHONBREAKPOINT
ENV PYTHONBREAKPOINT=ipdb.set_trace

Expand Down
36 changes: 36 additions & 0 deletions tutor/templates/build/openedx/bin/pip-install-all
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh
# TODO: Document this

set -eu

script="$(basename "$0")"

if [ $# != 1 ] ; then
echo "$script: error: expected exactly one argument: a directory."
exit 1
fi

dir="$1"

if [ ! -d "$dir" ] ; then
echo "$script: error: not a directory: $dir"
exit 1
fi

if [ -z "$(ls -A "$dir")" ] ; then
echo "$script: $dir is empty; nothing to do"
exit 0
fi

for dir_item in "$dir"/* ; do
if [ ! -d "$dir_item" ] ; then
# skip regular files
continue
fi
# TODO: Is it right to always do editable (-e) install?
# Should we make it configurable?
set -x
pip install -e "$dir_item"
set +x
done

17 changes: 17 additions & 0 deletions tutor/templates/build/openedx/requirements-dev/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
requirements-dev
################

If you want to install a local Python package into the openedx-dev image, then:

1. Move it into this directory.
2. Reboot your development platform (``tutor dev reboot``). This will trigger the openedx-dev image to be rebuilt and containers to be recreated.

Going forward, changes to the local package's code should be automatically manifested.

To remove the local package, simply:

1. Move it out of this directory.
2. Reboot your development platform (``tutor dev reboot``).

Please note: This strategy will only affect the image for the Open edX development (``tutor dev``) environment. To install a package into all environments (``tutor dev``, ``tutor local``, ``tutor k8s``), use the `../requirements`_ directory instead.

16 changes: 16 additions & 0 deletions tutor/templates/build/openedx/requirements/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
requirements
############

If you want to install a local Python package into the openedx image, then:

1. Move it into this directory.
2. Reboot your platform (``tutor local/k8s/dev reboot``). This will trigger the openedx image to be rebuilt and containers to be recreated.

Going forward, changes to the local package's code should be automatically manifested.

To remove the local package, simply:

1. Move it out of this directory.
2. Reboot your platform (``tutor local/k8s/dev reboot``).

Tip: If you are only testing out a local package with your development environment (``tutor dev``), then you can save image build time by using `../requirements-dev`_ instead.
6 changes: 0 additions & 6 deletions tutor/templates/build/openedx/requirements/private-sample.txt

This file was deleted.

0 comments on commit 683f43c

Please sign in to comment.