Skip to content

Commit 6b91509

Browse files
authored
Put the virtualenv into a .venv directory instead of the project root (#1334)
Signed-off-by: tdruez <tdruez@nexb.com>
1 parent 769e76f commit 6b91509

File tree

10 files changed

+21
-26
lines changed

10 files changed

+21
-26
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: make docs
6161

6262
- name: Run tests
63-
run: bin/python manage.py test --verbosity=2 --noinput
63+
run: .venv/bin/python manage.py test --verbosity=2 --noinput
6464
env:
6565
SCANCODEIO_DB_NAME: ${{ env.POSTGRES_DB }}
6666
SCANCODEIO_DB_USER: ${{ env.POSTGRES_USER }}

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ share
4343
selenium
4444
local
4545
/dist/
46-
/.cache/
46+
/.*cache/
47+
/.venv/
4748
/.python-version
4849
/.pytest_cache/
4950
/scancodeio.egg-info/

Dockerfile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ LABEL org.opencontainers.image.licenses="Apache-2.0"
2929
ENV APP_NAME scancodeio
3030
ENV APP_USER app
3131
ENV APP_DIR /opt/$APP_NAME
32-
ENV VIRTUAL_ENV /opt/$APP_NAME/venv
32+
ENV VENV_LOCATION /opt/$APP_NAME/.venv
3333

3434
# Force Python unbuffered stdout and stderr (they are flushed to terminal immediately)
3535
ENV PYTHONUNBUFFERED 1
@@ -78,9 +78,9 @@ WORKDIR $APP_DIR
7878
USER $APP_USER
7979

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

8585
# Create static/ and workspace/ directories
8686
RUN mkdir -p /var/$APP_NAME/static/ \

Makefile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@
2222

2323
# Python version can be specified with `$ PYTHON_EXE=python3.x make conf`
2424
PYTHON_EXE?=python3
25-
MANAGE=bin/python manage.py
26-
ACTIVATE?=. bin/activate;
25+
VENV_LOCATION=.venv
26+
ACTIVATE?=. ${VENV_LOCATION}/bin/activate;
27+
MANAGE=${VENV_LOCATION}/bin/python manage.py
2728
VIRTUALENV_PYZ=etc/thirdparty/virtualenv.pyz
2829
# Do not depend on Python to generate the SECRET_KEY
2930
GET_SECRET_KEY=`head -c50 /dev/urandom | base64 | head -c50`
@@ -46,7 +47,7 @@ endif
4647

4748
virtualenv:
4849
@echo "-> Bootstrap the virtualenv with PYTHON_EXE=${PYTHON_EXE}"
49-
@${PYTHON_EXE} ${VIRTUALENV_PYZ} --never-download --no-periodic-update .
50+
@${PYTHON_EXE} ${VIRTUALENV_PYZ} --never-download --no-periodic-update ${VENV_LOCATION}
5051

5152
conf: virtualenv
5253
@echo "-> Install dependencies"
@@ -85,8 +86,8 @@ check-deploy:
8586

8687
clean:
8788
@echo "-> Clean the Python env"
88-
rm -rf bin/ lib/ lib64/ include/ build/ dist/ docs/_build/ .cache/ pip-selfcheck.json pyvenv.cfg
89-
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete -type d -name '*.egg-info' -delete
89+
rm -rf .venv/ .*_cache/ *.egg-info/ build/ dist/
90+
find . -type f -name '*.py[co]' -delete -o -type d -name __pycache__ -delete
9091

9192
migrate:
9293
@echo "-> Apply database migrations"

pyproject.toml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
[tool.ruff]
22
line-length = 88
3-
exclude = [
4-
"migrations",
5-
"bin",
6-
"Script",
7-
"Lib",
8-
"lib",
9-
"lib64",
10-
"local",
11-
"var",
12-
]
3+
extend-exclude = ["migrations", "var"]
4+
target-version = "py310"
135

146
[tool.ruff.lint]
157
# Rules: https://docs.astral.sh/ruff/rules/
@@ -41,5 +33,6 @@ section-order = [
4133
max-complexity = 10
4234

4335
[tool.ruff.lint.per-file-ignores]
44-
# All usage of assert on the SPDX test file.
36+
# Allow the usage of assert in the test_spdx file.
4537
"**/test_spdx.py*" = ["S101"]
38+
"scanpipe/pipes/spdx.py" = ["UP006", "UP035"]

scanpipe/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, *args, **kwargs):
4747

4848
def clean(self, data, initial=None):
4949
single_file_clean = super().clean
50-
if isinstance(data, (list, tuple)):
50+
if isinstance(data, list | tuple):
5151
result = [single_file_clean(entry, initial) for entry in data]
5252
else:
5353
result = single_file_clean(data, initial)

scanpipe/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ def inputs(self, pattern="**/*", extensions=None):
930930
if not extensions:
931931
return self.input_path.glob(pattern)
932932

933-
if not isinstance(extensions, (list, tuple)):
933+
if not isinstance(extensions, list | tuple):
934934
raise TypeError("extensions should be a list or tuple")
935935

936936
return (

scanpipe/pipes/output.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ def _adapt_value_for_xlsx(fieldname, value, maximum_length=32767, _adapt=True):
413413
value = [mapping[mapping_key] for mapping in value]
414414

415415
# convert these to text lines, remove duplicates
416-
if isinstance(value, (list, tuple)):
416+
if isinstance(value, list | tuple):
417417
value = ordered_unique(str(v) for v in value if v)
418418
value = "\n".join(value)
419419

scanpipe/tests/test_pipelines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ def _normalize_package_uids(self, data):
594594
is_local_files = True
595595
normalized_data = {}
596596
for key, value in data.items():
597-
if isinstance(value, (list, dict)):
597+
if isinstance(value, list | dict):
598598
value = self._normalize_package_uids(value)
599599
if key in fields_with_package_uids and value:
600600
value = purl_with_fake_uuid(value)

scanpipe/views.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def get_field_value(self, field_name, render_func=None):
327327
if isinstance(field_value, Manager):
328328
return list(field_value.all())
329329

330-
if isinstance(field_value, (list, dict)):
330+
if isinstance(field_value, list | dict):
331331
with suppress(Exception):
332332
field_value = render_as_yaml(field_value)
333333

0 commit comments

Comments
 (0)