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

Put the virtualenv into a .venv directory instead of the project root #151

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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