Skip to content
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

Core Structure for supporting multiple XBlocks #2

Merged
merged 25 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@
# - `make dev.build`: Builds the Docker image for the XBlock SDK environment.
# - `make dev.run`: Cleans, builds, and runs the container, mapping the local project directory.

FROM openedx/xblock-sdk
RUN mkdir -p /usr/local/src/xblocks-contrib
FROM openedx/xblock-sdk:latest

WORKDIR /usr/local/src/xblocks-contrib
VOLUME ["/usr/local/src/xblocks-contrib"]
RUN apt-get update && apt-get install -y gettext
RUN echo "pip install -r /usr/local/src/xblocks-contrib/requirements/dev.txt" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh
RUN echo "pip install -e /usr/local/src/xblocks-contrib" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh
RUN echo "cd /usr/local/src/xblocks-contrib && make compile_translations && cd /usr/local/src/xblock-sdk" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh
RUN echo "exec python /usr/local/src/xblock-sdk/manage.py \"\$@\"" >> /usr/local/src/xblock-sdk/install_and_run_xblock.sh
RUN chmod +x /usr/local/src/xblock-sdk/install_and_run_xblock.sh
ENTRYPOINT ["/bin/bash", "/usr/local/src/xblock-sdk/install_and_run_xblock.sh"]
CMD ["runserver", "0.0.0.0:8000"]

RUN apt-get update && apt-get install -y \
gettext \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY . /usr/local/src/xblocks-contrib/

RUN pip install -r requirements/dev.txt && pip install -e .
RUN make compile_translations

ENTRYPOINT ["bash", "-c", "python /usr/local/src/xblock-sdk/manage.py migrate && exec python /usr/local/src/xblock-sdk/manage.py runserver 0.0.0.0:8000"]
EXPOSE 8000
4 changes: 2 additions & 2 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ appdirs==1.4.4
# via fs
asgiref==3.8.1
# via django
boto3==1.35.29
boto3==1.35.34
# via fs-s3fs
botocore==1.35.29
botocore==1.35.34
# via
# boto3
# s3transfer
Expand Down
14 changes: 7 additions & 7 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ asgiref==3.8.1
# -r requirements/quality.txt
# -r requirements/test.txt
# django
astroid==3.3.4
astroid==3.3.5
# via
# -r requirements/quality.txt
# pylint
Expand All @@ -29,18 +29,18 @@ binaryornot==0.4.4
# -r requirements/quality.txt
# -r requirements/test.txt
# cookiecutter
boto3==1.35.29
boto3==1.35.34
# via
# -r requirements/quality.txt
# -r requirements/test.txt
# fs-s3fs
botocore==1.35.29
botocore==1.35.34
# via
# -r requirements/quality.txt
# -r requirements/test.txt
# boto3
# s3transfer
build==1.2.2
build==1.2.2.post1
# via
# -r requirements/pip-tools.txt
# pip-tools
Expand Down Expand Up @@ -357,7 +357,7 @@ requests==2.32.3
# -r requirements/test.txt
# cookiecutter
# xblock-sdk
rich==13.8.1
rich==13.9.2
# via
# -r requirements/quality.txt
# -r requirements/test.txt
Expand Down Expand Up @@ -404,11 +404,11 @@ tomlkit==0.13.2
# via
# -r requirements/quality.txt
# pylint
tox==4.20.0
tox==4.21.2
# via
# -r requirements/quality.txt
# -r requirements/test.txt
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -r requirements/quality.txt
# -r requirements/test.txt
Expand Down
12 changes: 6 additions & 6 deletions requirements/doc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ binaryornot==0.4.4
# via
# -r requirements/test.txt
# cookiecutter
boto3==1.35.29
boto3==1.35.34
# via
# -r requirements/test.txt
# fs-s3fs
botocore==1.35.29
botocore==1.35.34
# via
# -r requirements/test.txt
# boto3
# s3transfer
build==1.2.2
build==1.2.2.post1
# via -r requirements/doc.in
cachetools==5.5.0
# via
Expand Down Expand Up @@ -292,7 +292,7 @@ restructuredtext-lint==1.4.0
# via doc8
rfc3986==2.0.0
# via twine
rich==13.8.1
rich==13.9.2
# via
# -r requirements/test.txt
# cookiecutter
Expand Down Expand Up @@ -348,11 +348,11 @@ text-unidecode==1.3
# via
# -r requirements/test.txt
# python-slugify
tox==4.20.0
tox==4.21.2
# via -r requirements/test.txt
twine==5.1.1
# via -r requirements/doc.in
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -r requirements/test.txt
# arrow
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip-tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# make upgrade
#
build==1.2.2
build==1.2.2.post1
# via pip-tools
click==8.1.7
# via pip-tools
Expand Down
12 changes: 6 additions & 6 deletions requirements/quality.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ asgiref==3.8.1
# via
# -r requirements/test.txt
# django
astroid==3.3.4
astroid==3.3.5
# via
# pylint
# pylint-celery
binaryornot==0.4.4
# via
# -r requirements/test.txt
# cookiecutter
boto3==1.35.29
boto3==1.35.34
# via
# -r requirements/test.txt
# fs-s3fs
botocore==1.35.29
botocore==1.35.34
# via
# -r requirements/test.txt
# boto3
Expand Down Expand Up @@ -266,7 +266,7 @@ requests==2.32.3
# -r requirements/test.txt
# cookiecutter
# xblock-sdk
rich==13.8.1
rich==13.9.2
# via
# -r requirements/test.txt
# cookiecutter
Expand Down Expand Up @@ -302,9 +302,9 @@ text-unidecode==1.3
# python-slugify
tomlkit==0.13.2
# via pylint
tox==4.20.0
tox==4.21.2
# via -r requirements/test.txt
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via
# -r requirements/test.txt
# arrow
Expand Down
10 changes: 5 additions & 5 deletions requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ asgiref==3.8.1
# django
binaryornot==0.4.4
# via cookiecutter
boto3==1.35.29
boto3==1.35.34
# via
# -r requirements/base.txt
# fs-s3fs
botocore==1.35.29
botocore==1.35.34
# via
# -r requirements/base.txt
# boto3
Expand Down Expand Up @@ -182,7 +182,7 @@ requests==2.32.3
# via
# cookiecutter
# xblock-sdk
rich==13.8.1
rich==13.9.2
# via cookiecutter
s3transfer==0.10.2
# via
Expand All @@ -207,9 +207,9 @@ stevedore==5.3.0
# via code-annotations
text-unidecode==1.3
# via python-slugify
tox==4.20.0
tox==4.21.2
# via -r requirements/test.in
types-python-dateutil==2.9.0.20240906
types-python-dateutil==2.9.0.20241003
# via arrow
urllib3==2.2.3
# via
Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,17 @@ def is_requirement(line):
)


def package_data(pkg, roots, sub_roots):
def package_data(pkg, sub_roots):
"""
Declare package_data based on `roots`.
Declare package_data based on all root directories inside `pkg`.

All of the files under each of the `roots` will be declared as package
data for package `pkg`.
All of the files under each of the sub_roots for every root directory
inside `pkg` will be declared as package data for package `pkg`.

"""
data = []
roots = [d for d in os.listdir(pkg) if os.path.isdir(os.path.join(pkg, d))]

for root in roots:
for sub_root in sub_roots:
for dirname, _, files in os.walk(os.path.join(pkg, root, sub_root)):
Expand Down Expand Up @@ -193,7 +195,6 @@ def package_data(pkg, roots, sub_roots):
],
entry_points={
"xblock.v1": [
# _extracted suffix is added for testing only.
"_annotatable_extracted = xblocks_contrib:AnnotatableBlock",
"_discussion_extracted = xblocks_contrib:DiscussionXBlock",
"_html_extracted = xblocks_contrib:HtmlBlock",
Expand All @@ -204,7 +205,5 @@ def package_data(pkg, roots, sub_roots):
"_word_cloud_extracted = xblocks_contrib:WordCloudBlock",
]
},
package_data=package_data(
"xblocks_contrib", ["annotatable", "poll"], ["static", "public", "templates"]
),
package_data=package_data("xblocks_contrib", ["static", "public", "templates"]),
)
Loading