Skip to content

Commit

Permalink
Put the virtualenv into a .venv directory instead of the project root (
Browse files Browse the repository at this point in the history
…#151)

Signed-off-by: tdruez <[email protected]>
  • Loading branch information
tdruez authored Jul 17, 2024
1 parent 0eb3e6f commit 736b6c7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ jobs:
run: make docs

- name: Run tests
run: bin/python manage.py test --verbosity=2 --noinput --parallel
run: .venv/bin/python manage.py test --verbosity=2 --noinput --parallel
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ local
/dist/
/.cache/
/.python-version
/enterprise.egg-info/
/.venv/
/.*cache/
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ LABEL org.opencontainers.image.licenses="AGPL-3.0-only"
ENV APP_NAME dejacode
ENV APP_USER app
ENV APP_DIR /opt/$APP_NAME
ENV VIRTUAL_ENV /opt/$APP_NAME/venv
ENV VENV_LOCATION /opt/$APP_NAME/.venv

# Force Python unbuffered stdout and stderr (they are flushed to terminal immediately)
ENV PYTHONUNBUFFERED 1
Expand Down Expand Up @@ -51,9 +51,9 @@ USER $APP_USER
RUN mkdir -p /var/$APP_NAME/static/ /var/$APP_NAME/media/

# Create the virtualenv
RUN python -m venv $VIRTUAL_ENV
RUN python -m venv $VENV_LOCATION
# Enable the virtualenv, similar effect as "source activate"
ENV PATH $VIRTUAL_ENV/bin:$PATH
ENV PATH $VENV_LOCATION/bin:$PATH

# Install the dependencies before the codebase COPY for proper Docker layer caching
COPY --chown=$APP_USER:$APP_USER setup.cfg setup.py $APP_DIR/
Expand Down
12 changes: 5 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
#

PYTHON_EXE=python3.12
MANAGE=bin/python manage.py
ACTIVATE?=. bin/activate;
VENV_LOCATION=.venv
ACTIVATE?=. ${VENV_LOCATION}/bin/activate;
MANAGE=${VENV_LOCATION}/bin/python manage.py
PIP_ARGS=--find-links=./thirdparty/dist/ --no-index --no-cache-dir
GET_SECRET_KEY=`cat /dev/urandom | head -c 50 | base64`
# Customize with `$ make envfile ENV_FILE=/etc/dejacode/.env`
ENV_FILE=.env
FIXTURES_LOCATION=./dje/fixtures
DOCS_LOCATION=./docs
MODIFIED_PYTHON_FILES=`git ls-files -m "*.py"`
BLACK_ARGS=--exclude="migrations|data|lib/|lib64|bin|var|dist|.cache" -l 100
DOCKER_COMPOSE=docker compose -f docker-compose.yml
DOCKER_EXEC=${DOCKER_COMPOSE} exec
DB_NAME=dejacode_db
Expand All @@ -28,7 +26,7 @@ TIMESTAMP=$(shell date +"%Y-%m-%d_%H%M")

virtualenv:
@echo "-> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE}"
${PYTHON_EXE} -m venv .
${PYTHON_EXE} -m venv ${VENV_LOCATION}

conf: virtualenv
@echo "-> Install dependencies"
Expand Down Expand Up @@ -72,7 +70,7 @@ check-deploy:

clean:
@echo "-> Cleaning the Python env"
rm -rf bin/ lib/ lib64/ include/ build/ dist/ share/ pip-selfcheck.json pyvenv.cfg
rm -rf .venv/ .*_cache/ *.egg-info/ build/ dist/
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete

initdb:
Expand Down

0 comments on commit 736b6c7

Please sign in to comment.