Skip to content

Commit

Permalink
add pyproject.toml and pinned dependencies (#107)
Browse files Browse the repository at this point in the history
* switch makefile helpers to use pip-tools

* add .in files for requirements and use .txt for locked deps

* remove warning

* phony

* switch to pyproject.toml

* add ruff

* damn

* separate lint and format

* replace pip-tools with uv

* fix pip sync

* no enforce format check

* phony targets

* fix comment

* more cleanup
  • Loading branch information
facundoolano authored Jul 18, 2024
1 parent 1556ffb commit 4a38de5
Show file tree
Hide file tree
Showing 4 changed files with 373 additions and 29 deletions.
20 changes: 15 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: all deps dev-deps run docker shell dbreset dbshell feed-* prod-* user-* db-*
.PHONY: all deps deps-dev deps-lock run docker docker-flask shell test lint format feed-* prod-* user-* db-*

venv=. venv/bin/activate &&
flask=$(venv) flask --app feedi/app.py
Expand All @@ -9,12 +9,17 @@ all: deps node_modules

venv:
python -m venv venv
$(venv) pip install uv

deps: venv
$(venv) pip install -r requirements.txt
$(venv) uv pip sync requirements.txt

deps-dev: deps
$(venv) pip install -r requirements-dev.txt
$(venv) uv pip sync requirements.txt requirements-dev.txt

deps-lock: venv
$(venv) uv pip compile -o requirements.txt pyproject.toml
$(venv) uv pip compile --extra dev -o requirements-dev.txt pyproject.toml

node_modules:
npm install || true
Expand All @@ -24,9 +29,14 @@ node_modules:
test:
$(venv) FLASK_ENV=testing pytest --disable-warnings -v $(if $(TEST),-k $(TEST))

format:
$(venv) ruff format

lint:
$(venv) flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude venv,migrations
$(venv) flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude venv,migrations
$(venv) ruff check
# FIXME uncomment in another PR, and apply formatting
# $(venv) ruff format --check
# $(venv) flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --exclude venv,migrations

# Serve the app in development mode
run:
Expand Down
49 changes: 49 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[project]
name = "feedi"
description = "A personal news aggregator and Mastodon client"
version = "0.1.0"
requires-python = ">= 3.9"
authors = [
{ name = "Facundo Olano", email = "[email protected]" }
]
dependencies = [
"flask",
"feedparser",
"favicon",
"requests",
"sqlalchemy",
"flask-sqlalchemy",
"beautifulsoup4",
"lxml",
"Mastodon-py",
"gevent",
"huey",
"alembic",
"gunicorn",
"pyopml",
"flask-login",
"Werkzeug",
"dateparser",
"Pillow"
]

[project.optional-dependencies]
dev = [
"ipython",
"ipdb",
"flask-shell-ipython",
"pytest",
"httpretty",
"feedgen",
"ruff"
]

[tool.ruff]
exclude = [
"venv",
"migrations"
]

line-length = 120
target-version = "py39"

196 changes: 189 additions & 7 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,190 @@
-r requirements.txt
ipython
ipdb
flask-shell-ipython
pytest==7.4.3
httpretty==1.1.4
# This file was autogenerated by uv via the following command:
# uv pip compile --extra dev -o requirements-dev.txt pyproject.toml
alembic==1.13.2
# via feedi (pyproject.toml)
asttokens==2.4.1
# via stack-data
beautifulsoup4==4.12.3
# via
# feedi (pyproject.toml)
# favicon
blinker==1.8.2
# via flask
blurhash==1.1.4
# via mastodon-py
certifi==2024.7.4
# via requests
charset-normalizer==3.3.2
# via requests
click==8.1.7
# via
# flask
# flask-shell-ipython
dateparser==1.2.0
# via feedi (pyproject.toml)
decorator==5.1.1
# via
# ipdb
# ipython
# mastodon-py
exceptiongroup==1.2.2
# via
# ipython
# pytest
executing==2.0.1
# via stack-data
favicon==0.7.0
# via feedi (pyproject.toml)
feedgen==1.0.0
flake8
# via feedi (pyproject.toml)
feedparser==6.0.11
# via feedi (pyproject.toml)
flask==3.0.3
# via
# feedi (pyproject.toml)
# flask-login
# flask-shell-ipython
# flask-sqlalchemy
flask-login==0.6.3
# via feedi (pyproject.toml)
flask-shell-ipython==0.5.1
# via feedi (pyproject.toml)
flask-sqlalchemy==3.1.1
# via feedi (pyproject.toml)
gevent==24.2.1
# via feedi (pyproject.toml)
greenlet==3.0.3
# via gevent
gunicorn==22.0.0
# via feedi (pyproject.toml)
httpretty==1.1.4
# via feedi (pyproject.toml)
huey==2.5.1
# via feedi (pyproject.toml)
idna==3.7
# via requests
importlib-metadata==8.0.0
# via flask
iniconfig==2.0.0
# via pytest
ipdb==0.13.13
# via feedi (pyproject.toml)
ipython==8.18.1
# via
# feedi (pyproject.toml)
# flask-shell-ipython
# ipdb
itsdangerous==2.2.0
# via flask
jedi==0.19.1
# via ipython
jinja2==3.1.4
# via flask
lxml==5.2.2
# via
# feedi (pyproject.toml)
# feedgen
# pyopml
mako==1.3.5
# via alembic
markupsafe==2.1.5
# via
# jinja2
# mako
# werkzeug
mastodon-py==1.8.1
# via feedi (pyproject.toml)
matplotlib-inline==0.1.7
# via ipython
packaging==24.1
# via
# gunicorn
# pytest
parso==0.8.4
# via jedi
pexpect==4.9.0
# via ipython
pillow==10.4.0
# via feedi (pyproject.toml)
pluggy==1.5.0
# via pytest
prompt-toolkit==3.0.47
# via ipython
ptyprocess==0.7.0
# via pexpect
pure-eval==0.2.2
# via stack-data
pygments==2.18.0
# via ipython
pyopml==1.0.0
# via feedi (pyproject.toml)
pytest==8.2.2
# via feedi (pyproject.toml)
python-dateutil==2.9.0.post0
# via
# dateparser
# feedgen
# mastodon-py
python-magic==0.4.27
# via mastodon-py
pytz==2024.1
# via dateparser
regex==2024.5.15
# via dateparser
requests==2.32.3
# via
# feedi (pyproject.toml)
# favicon
# mastodon-py
ruff==0.5.2
# via feedi (pyproject.toml)
setuptools==71.0.0
# via
# zope-event
# zope-interface
sgmllib3k==1.0.0
# via feedparser
six==1.16.0
# via
# asttokens
# mastodon-py
# python-dateutil
soupsieve==2.5
# via beautifulsoup4
sqlalchemy==2.0.31
# via
# feedi (pyproject.toml)
# alembic
# flask-sqlalchemy
stack-data==0.6.3
# via ipython
tomli==2.0.1
# via
# ipdb
# pytest
traitlets==5.14.3
# via
# ipython
# matplotlib-inline
typing-extensions==4.12.2
# via
# alembic
# ipython
# sqlalchemy
tzlocal==5.2
# via dateparser
urllib3==2.2.2
# via requests
wcwidth==0.2.13
# via prompt-toolkit
werkzeug==3.0.3
# via
# feedi (pyproject.toml)
# flask
# flask-login
zipp==3.19.2
# via importlib-metadata
zope-event==5.0
# via gevent
zope-interface==6.4.post2
# via gevent
Loading

0 comments on commit 4a38de5

Please sign in to comment.