From e21f77989670c61854156a157d30702ef23c1a51 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 31 Dec 2024 19:33:02 -0500 Subject: [PATCH 1/4] Switch to pyproject.toml for dependencies --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/freezingsaddles/freezing-web?shareId=XXXX-XXXX-XXXX-XXXX). --- .github/workflows/lint.yml | 2 +- Dockerfile | 3 +- MANIFEST.in | 5 --- pyproject.toml | 50 +++++++++++++++++++++++++++ requirements-test.txt | 7 ---- requirements.txt | 19 ----------- setup.py | 69 -------------------------------------- 7 files changed, 52 insertions(+), 103 deletions(-) delete mode 100644 MANIFEST.in delete mode 100644 requirements-test.txt delete mode 100644 requirements.txt delete mode 100644 setup.py diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 56d2f615..b5045073 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -21,7 +21,7 @@ jobs: - name: isort Lint uses: isort/isort-action@v1 with: - requirements-files: "requirements.txt requirements-test.txt" + requirements-files: "pyproject.toml" - name: flake8 Lint uses: py-actions/flake8@v2 diff --git a/Dockerfile b/Dockerfile index aeb19e9a..ca5dbd0a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,11 @@ RUN apk update RUN apk add py3-mysqlclient RUN addgroup -S freezing && adduser -S -G freezing freezing RUN pip3 install --upgrade pip -ADD requirements.txt /tmp/requirements.txt -RUN pip3 install -r /tmp/requirements.txt ADD . /app RUN mkdir -p /data COPY leaderboards /data/leaderboards COPY alembic.ini /app +COPY pyproject.toml /app/ WORKDIR /app RUN pip3 install . ENV LEADERBOARDS_DIR=/data/leaderboards diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 013bde5d..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,5 +0,0 @@ -recursive-include freezing/web/templates * -recursive-include freezing/web/static * -include requirements.txt -include requirements-test.txt -include setup.py diff --git a/pyproject.toml b/pyproject.toml index 0734e5b0..f2b38058 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,53 @@ +[build-system] +requires = ["setuptools", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "freezing-web" +version = "1.5.6" +description = "Freezing Saddles website component." +authors = [ + {name = "Hans Lellelid", email = "hans@xmpl.org"}, + {name = "Ian Will"}, + {name = "Jon Renaut"}, + {name = "Merlin Hughes"}, + {name = "Richard Bullington-McGuire", email = "richard.bullington.mcguire@gmail.com"}, + {name = "Adrian Porter"}, + {name = "Joe Tatsuko"} +] +license = {name = "Apache-2.0"} +dependencies = [ + "Flask", + "GeoAlchemy2", + "PyMySQL", + "PyYAML", + "alembic", + "arrow", + "beautifulsoup4", + "colorlog", + "envparse", + "freezing-model", + "geojson", + "gunicorn", + "marshmallow", + "marshmallow-enum", + "polyline", + "python-instagram", + "pytz", + "stravalib" +] + +[project.optional-dependencies] +test = [ + "bandit", + "black", + "djlint", + "flake8", + "isort", + "pur", + "pymarkdownlnt" +] + [tool.isort] profile = "black" diff --git a/requirements-test.txt b/requirements-test.txt deleted file mode 100644 index 5c0b0b3a..00000000 --- a/requirements-test.txt +++ /dev/null @@ -1,7 +0,0 @@ -bandit==1.8.0 -black==24.10.0 -djlint==1.36.4 -flake8==7.1.1 -isort==5.13.2 -pur==7.3.2 -pymarkdownlnt==0.9.26 diff --git a/requirements.txt b/requirements.txt deleted file mode 100644 index 088cc725..00000000 --- a/requirements.txt +++ /dev/null @@ -1,19 +0,0 @@ -Flask==3.1.0 -GeoAlchemy2==0.16.0 -PyMySQL[rsa]==1.1.1 -PyYAML==6.0.2 -SQLAlchemy==1.4.54 -# Thanks https://stackoverflow.com/a/77214086/424301 - Flask did not pin Werkzeug dep -Werkzeug==3.1.3 -arrow==0.15.5 -autoflake==2.3.1 -beautifulsoup4==4.12.3 -colorlog==4.1.0 -envparse==0.2.0 -freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.10.4.tar.gz -gunicorn==23.0.0 -marshmallow==3.23.2 -marshmallow-enum @ https://github.com/lyft/marshmallow_enum/archive/support-for-marshamallow-3.tar.gz -python-instagram==1.3.2 -pytz==2024.2 -stravalib==1.2.0 diff --git a/setup.py b/setup.py deleted file mode 100644 index 2b3c25c5..00000000 --- a/setup.py +++ /dev/null @@ -1,69 +0,0 @@ -from setuptools import setup - -__authors__ = [ - '"Hans Lellelid" ', - "Ian Will", - "Jon Renaut", - "Merlin Hughes", - "Richard Bullington-McGuire ", - "Adrian Porter", - "Joe Tatsuko", -] - -__copyright__ = "Copyright 2015 Hans Lellelid" - -version = "1.5.6" - -long_description = """ -The freezing saddles cycling competition website/scoreboard. -""" - -install_req = [ - "Flask", - "GeoAlchemy2", - "PyMySQL", - "PyYAML", - "alembic", - "arrow", - "beautifulsoup4", - "colorlog", - "envparse", - "freezing-model", - "geojson", - "gunicorn", - "marshmallow", - "marshmallow-enum", - "polyline", - "python-instagram", - "pytz", - "stravalib", -] - -setup( - name="freezing-web", - version=version, - description="Freezing Saddles website component.", - long_description=long_description, - author="Hans Lellelid", - author_email="hans@xmpl.org", - # This is a workaround for https://github.com/pypa/setuptools/issues/97 - packages=["freezing.web", "freezing.web.views", "freezing.web.utils"], - # packages=find_packages(include=['freezing.web.*']) - include_package_data=True, - package_data={"freezing.web": ["static/*", "templates/*"]}, - license="Apache", - url="http://github.com/freezingsaddles/freezing-web", - install_requires=install_req, - classifiers=[ - "Development Status :: 3 - Alpha", - "Intended Audience :: Developers", - "License :: OSI Approved :: Apache Software License", - "Operating System :: OS Independent", - "Programming Language :: Python :: 3.6", - ], - # zip_safe=False, - entry_points=""" - [console_scripts] - freezing-server = freezing.web.runserver:main - """, -) From 8902ff6133c075e59e3a88425d47a6b09e4fc711 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 31 Dec 2024 19:47:59 -0500 Subject: [PATCH 2/4] Nip and tuck after GitHub Copilot pass --- MANIFEST.in | 2 ++ pyproject.toml | 56 +++++++++++++++++++++++++++++++------------------- 2 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 MANIFEST.in diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 00000000..958c63b6 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +recursive-include freezing/web/templates * +recursive-include freezing/web/static * diff --git a/pyproject.toml b/pyproject.toml index f2b38058..6f2889fe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" [project] name = "freezing-web" -version = "1.5.6" +version = "1.6.0" description = "Freezing Saddles website component." authors = [ {name = "Hans Lellelid", email = "hans@xmpl.org"}, @@ -15,26 +15,37 @@ authors = [ {name = "Adrian Porter"}, {name = "Joe Tatsuko"} ] -license = {name = "Apache-2.0"} +license = {text = "Apache License (2.0)"} dependencies = [ - "Flask", - "GeoAlchemy2", - "PyMySQL", - "PyYAML", - "alembic", - "arrow", - "beautifulsoup4", - "colorlog", - "envparse", - "freezing-model", - "geojson", - "gunicorn", - "marshmallow", - "marshmallow-enum", - "polyline", - "python-instagram", - "pytz", - "stravalib" + "Flask==3.1.0", + "GeoAlchemy2==0.16.0", + "PyMySQL[rsa]==1.1.1", + "PyYAML==6.0.2", + "SQLAlchemy==1.4.54", + # Thanks https://stackoverflow.com/a/77214086/424301 - Flask did not pin Werkzeug dep + "Werkzeug==3.1.3", + "arrow==0.15.5", + "autoflake==2.3.1", + "beautifulsoup4==4.12.3", + "colorlog==4.1.0", + "envparse==0.2.0", + "freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.10.4.tar.gz", + "gunicorn==23.0.0", + "marshmallow==3.23.2", + "marshmallow-enum @ https://github.com/lyft/marshmallow_enum/archive/support-for-marshamallow-3.tar.gz", + "python-instagram==1.3.2", + "pytz==2024.2", + "stravalib==1.2.0", +] +classifiers = [ + "Development Status :: 4 - Beta", + "License :: OSI Approved :: Apache Software License", + "Topic :: Games", + "Operating System :: OS Independent", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.10", + "Natural Language :: English", ] [project.optional-dependencies] @@ -44,7 +55,6 @@ test = [ "djlint", "flake8", "isort", - "pur", "pymarkdownlnt" ] @@ -58,3 +68,7 @@ max_line_length=88 [tool.pymarkdown] plugins.md013.enabled = false extensions.front-matter.enabled = true + +[tool.setuptools] +# Thanks https://stackoverflow.com/a/72547402/424301 +py-modules = ["freezing"] From 705af7e658c08071e8521a063031fca2a7a67448 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 31 Dec 2024 20:07:32 -0500 Subject: [PATCH 3/4] Clean test and running freezing-server --- freezing/web/templates/user/rides.html | 4 ++-- pyproject.toml | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/freezing/web/templates/user/rides.html b/freezing/web/templates/user/rides.html index a5b62bbc..a7ace0d4 100644 --- a/freezing/web/templates/user/rides.html +++ b/freezing/web/templates/user/rides.html @@ -156,7 +156,7 @@

} function rideFormatter(value, row) { - return "" + value + ""; + return `${value}`; } function photosFormatter(value, row) { @@ -197,7 +197,7 @@

function refetchFormatter(value, row) { if (row.photos_fetched) { - return "refetch"; + return `refetch`; } } diff --git a/pyproject.toml b/pyproject.toml index 6f2889fe..da28c27c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -72,3 +72,6 @@ extensions.front-matter.enabled = true [tool.setuptools] # Thanks https://stackoverflow.com/a/72547402/424301 py-modules = ["freezing"] + +[project.scripts] +freezing-server = "freezing.web.runserver:main" From 27afc57310de0aca22e01e4e34e51b84a75063e9 Mon Sep 17 00:00:00 2001 From: Richard Bullington-McGuire Date: Tue, 31 Dec 2024 20:14:18 -0500 Subject: [PATCH 4/4] Fix up actions package directives --- .github/workflows/lint.yml | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index b5045073..b7bb33d5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -38,7 +38,7 @@ jobs: - name: Install dependencies run: | python -m pip install --upgrade pip - pip install -r requirements.txt -r requirements-test.txt + pip install '.[dev]' - name: djlint Lint run: | djlint --check freezing/web/templates diff --git a/pyproject.toml b/pyproject.toml index da28c27c..bb4f2880 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,7 @@ classifiers = [ ] [project.optional-dependencies] -test = [ +dev = [ "bandit", "black", "djlint",