Commit 96450b65 authored by Philippe Pepiot's avatar Philippe Pepiot
Browse files

Fix detecting cube name

Cube name might not be equal to the package name stripped by 'cubicweb-'.
For instance cubicweb-saem-ref cube name is "saem_ref", not saem-ref.

Use a python script to detect the cube name using pkg_resources.
parent df4f9252ca14
...@@ -3,4 +3,4 @@ ...@@ -3,4 +3,4 @@
!pyramid.ini.j2 !pyramid.ini.j2
!entrypoint.sh !entrypoint.sh
!check-docker-updates.sh !check-docker-updates.sh
!get-cube.sh !get-cube
...@@ -21,8 +21,8 @@ RUN apt-get update && apt-get -y --no-install-recommends install \ ...@@ -21,8 +21,8 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
RUN test $PYTHON = "python" && export py=python2 pip=pip2 || export py=python3 pip=pip3; \ RUN test $PYTHON = "python" && export py=python2 pip=pip2 || export py=python3 pip=pip3; \
update-alternatives --install /usr/bin/python python /usr/bin/$py 50 && \ update-alternatives --install /usr/bin/python python /usr/bin/$py 50 && \
update-alternatives --install /usr/bin/pip pip /usr/bin/$pip 50 update-alternatives --install /usr/bin/pip pip /usr/bin/$pip 50
COPY check-docker-updates.sh get-cube.sh /usr/local/bin/ COPY check-docker-updates.sh get-cube /usr/local/bin/
RUN chmod +x /usr/local/bin/check-docker-updates.sh /usr/local/bin/get-cube.sh RUN chmod +x /usr/local/bin/check-docker-updates.sh /usr/local/bin/get-cube
ENV PIP_NO_CACHE_DIR off ENV PIP_NO_CACHE_DIR off
ENV PIP_DISABLE_PIP_VERSION_CHECK on ENV PIP_DISABLE_PIP_VERSION_CHECK on
# Markdown require setuptools>=36 # Markdown require setuptools>=36
......
...@@ -6,4 +6,4 @@ ONBUILD USER root ...@@ -6,4 +6,4 @@ ONBUILD USER root
ONBUILD COPY . /src/ ONBUILD COPY . /src/
ONBUILD RUN pip install -e /src ONBUILD RUN pip install -e /src
ONBUILD USER cubicweb ONBUILD USER cubicweb
ONBUILD RUN cubicweb-ctl create $(get-cube.sh) $CW_INSTANCE --automatic --no-db-create ONBUILD RUN cubicweb-ctl create $(get-cube) $CW_INSTANCE --automatic --no-db-create
#!/bin/sh #!/bin/sh
set -e set -e
export CUBE=$(get-cube.sh) export CUBE=$(get-cube)
test -z "$CUBE" && exit 1 test -z "$CUBE" && exit 1
if test -z "$CW_DB_NAME"; then if test -z "$CW_DB_NAME"; then
export CW_DB_NAME=$CUBE export CW_DB_NAME=$CUBE
......
#!/usr/bin/env python
from __future__ import print_function
import os
import pkg_resources
import subprocess
def getcube():
if os.environ.get('CUBE'):
return os.environ['CUBE']
name = subprocess.check_output(
['python', 'setup.py', '--name'], cwd='/src').decode().strip()
cubename = list(pkg_resources.get_distribution(
name).get_entry_map('cubicweb.cubes').keys())
assert len(cubename) == 1, (
"You should have exactly one entrypoint for 'cubicweb.cubes' "
"entrypoint in setup.py: got {0}".format(repr(cubename)))
return cubename[0]
if __name__ == '__main__':
print(getcube())
#!/bin/sh
set -e
if test -n "$CUBE"; then
echo "$CUBE"
elif test -f /src/setup.py; then
python /src/setup.py --name | sed 's@cubicweb-@@g'
else
>&2 echo "unable to deternine the cube name. You have to set it by the CUBE environment variable"
exit 1
fi
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment