Skip to content

Commit

Permalink
Refactor: move dependencies and metadata to pyproject.toml (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Apr 13, 2023
2 parents dd3d8a0 + 5b5b02f commit e2af9c7
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 42 deletions.
7 changes: 2 additions & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
FROM benefits_client:latest

# install devcontainer requirements
COPY .devcontainer/requirements.txt .devcontainer/requirements.txt
RUN pip install -r .devcontainer/requirements.txt
RUN pip install -e .[dev,test]

# docs requirements are in a separate file for the GitHub Action
COPY docs/requirements.txt docs/requirements.txt
RUN pip install -r docs/requirements.txt

COPY tests/pytest/requirements.txt tests/pytest/requirements.txt
RUN pip install -r tests/pytest/requirements.txt

# install pre-commit environments in throwaway Git repository
# https://stackoverflow.com/a/68758943
COPY .pre-commit-config.yaml .
Expand Down
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"bungcip.better-toml",
"batisteo.vscode-django",
"bpruitt-goddard.mermaid-markdown-syntax-highlighting",
"eamodio.gitlens",
Expand Down
4 changes: 0 additions & 4 deletions .devcontainer/requirements.txt

This file was deleted.

1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
.flake8
.*ignore
*.db
*.egg-info
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
version: 2
updates:
- package-ecosystem: "pip"
directory: "/appcontainer" # main requirements.txt
directory: "/" # pyproject.toml
schedule:
interval: "daily"
commit-message:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/labeler-deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ on:
branches: [dev]
types: [opened]
paths:
- '.github/workflows/deploy-*.yml'
- 'benefits/**'
- 'bin/**'
- ".github/workflows/deploy-*.yml"
- "benefits/**"
- "bin/**"
- Dockerfile
- requirements.txt
- pyproject.toml

jobs:
label-deployment-dev:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/tests-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
with:
python-version-file: .github/workflows/.python-version
cache: pip
cache-dependency-path: "**/requirements.txt"
cache-dependency-path: "**/pyproject.toml"

- name: Install Python dependencies
run: pip install -r appcontainer/requirements.txt -r tests/pytest/requirements.txt
run: pip install -e .[test]

- name: Run setup
run: ./bin/init.sh
Expand Down
14 changes: 7 additions & 7 deletions appcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
FROM ghcr.io/cal-itp/docker-python-web:main

# install python dependencies
COPY appcontainer/requirements.txt requirements.txt
RUN pip install -r requirements.txt
# upgrade pip
RUN python -m pip install --upgrade pip

# copy Django utility script
# copy source files
COPY manage.py manage.py
COPY bin bin
COPY benefits benefits
COPY pyproject.toml pyproject.toml

# copy source files
COPY bin/ bin/
COPY benefits/ benefits/
RUN pip install -e .

# ensure $USER can compile messages in the locale directories
USER root
Expand Down
7 changes: 0 additions & 7 deletions appcontainer/requirements.txt

This file was deleted.

52 changes: 45 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,17 +1,53 @@
# NOTE: you have to use single-quoted strings in TOML for regular expressions.
# It's the equivalent of r-strings in Python. Multiline strings are treated as
# verbose regular expressions by Black. Use [ ] to denote a significant space
# character.
[build-system]
requires = ["setuptools>=64", "wheel"]
build-backend = "setuptools.build_meta"

# Configuration for black
[project]
classifiers = ["Programming Language :: Python :: 3 :: Only"]
description = "Cal-ITP Benefits is an application that enables automated eligibility verification and enrollment for transit benefits onto customers’ existing contactless bank (credit/debit) cards."
dependencies = [
"Authlib==1.2.0",
"Django==4.2",
"django-csp==3.7",
"eligibility-api==2023.01.1",
"requests==2.28.2",
"sentry-sdk==1.19.1",
"six==1.16.0",
]
dynamic = ["version"]
keywords = ["django"]
license = { file = "LICENSE" }
name = "benefits"
readme = "README.md"
requires-python = ">=3.9"

[project.optional-dependencies]
dev = [
"black",
"djlint",
"flake8",
"pre-commit",
]
test = [
"pytest",
"pytest-cov",
"pytest-django",
"pytest-mock",
"pytest-socket",
]

[project.urls]
Code = "https://github.com/cal-itp/benefits"
Documentation = "https://docs.calitp.org/benefits"
Issues = "https://github.com/cal-itp/benefits/issues"

# Configuration for black
[tool.black]
line-length = 127
target-version = ['py310']
include = '\.pyi?$'

# Configuration for djlint

[tool.djlint]
ignore = "H017,H031"
indent = 2
Expand All @@ -22,7 +58,6 @@ preserve_blank_lines = true
use_gitignore = true

# Configuration for pytest

[tool.coverage.run]
omit = [
"benefits/core/migrations/*"
Expand All @@ -33,3 +68,6 @@ DJANGO_SETTINGS_MODULE = "benefits.settings"
markers = [
"request_path: use with session_request to initialize with the given path",
]

[tool.setuptools]
packages = ["benefits"]
5 changes: 0 additions & 5 deletions tests/pytest/requirements.txt

This file was deleted.

0 comments on commit e2af9c7

Please sign in to comment.