Skip to content

Commit

Permalink
Merge pull request #82 from freezingsaddles/obscurerichard/use-pyproj…
Browse files Browse the repository at this point in the history
…ect-toml

Make this project use pyproject.toml and Setuptools to handle dependencies instead of setup.py
  • Loading branch information
obscurerichard authored Jan 5, 2025
2 parents 79021a5 + 6323208 commit a0382e7
Show file tree
Hide file tree
Showing 15 changed files with 152 additions and 111 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ eggs/
*.egg-info/
*.egg
*.cfg

7 changes: 0 additions & 7 deletions .flake8

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Build and Deploy Latest

on:
on: # yamllint disable-line
push:
branches:
- 'main'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build-tag.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: Build Tag

on:
on: # yamllint disable-line
push:
tags:
- '*'
- '*'

jobs:
build:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: Build

on: pull_request
on: pull_request # yamllint disable-line

jobs:
build:
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
name: Lint

on: pull_request
on: pull_request # yamllint disable-line

jobs:

# Thanks https://black.readthedocs.io/en/stable/integrations/github_actions.html
lint:
runs-on: ubuntu-latest
Expand All @@ -20,8 +20,10 @@ 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
# There are too many errors to start with to fail on this
continue-on-error: true
with:
plugins: "flake8-pyproject"
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
- repo: https://github.com/jackdewinter/pymarkdown
rev: v0.9.26
hooks:
- id: pymarkdown
- repo: https://github.com/djlint/djLint
rev: v1.36.4
hooks:
- id: djlint-reformat
- id: djlint
9 changes: 5 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@ RUN apt-get update \

RUN mkdir -p /build/wheels
RUN pip3 install --upgrade pip setuptools wheel
ADD requirements.txt /tmp/requirements.txt
RUN pip3 wheel -r /tmp/requirements.txt --wheel-dir=/build/wheels
ADD pyproject.toml /tmp/pyproject.toml
RUN cd /tmp && pip3 wheel --wheel-dir=/build/wheels .

# Now build the wheel for this project too.
ADD . /app
WORKDIR /app

RUN python3 setup.py bdist_wheel -d /build/wheels
RUN pip3 install build
RUN python3 -m build --wheel --outdir /build/wheels

# DEPLOY
# =====

FROM ubuntu:22.04 as deploystep
FROM ubuntu:22.04 AS deploystep
LABEL maintainer="Richard Bullington-McGuire <[email protected]>"

RUN apt-get update \
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include freezing/sync *
41 changes: 32 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
# Freezing Saddles Sync

This component is part of the [Freezing Saddles](http://freezingsaddles.com) project. Its purpose is to
1. receive workflow messages published from [freezing-nq](https://github.com/freezingsaddles/freezing-nq) and perform Strava API calls to retrieve activities/streams/etc.
This component is part of the [Freezing Saddles](http://freezingsaddles.com) project. Its purpose is to:

1. Receive workflow messages published from [freezing-nq](https://github.com/freezingsaddles/freezing-nq) and perform Strava API calls to retrieve activities/streams/etc.
2. Perform periodic (cron-like) double checks to make sure that we haven't missed any activity updates/deletes.
3. Perform periodic updates for non-Strava data (e.g. weather data).

## Deploying With Docker
## Development Setup

This project supports local development both with Docker and by running directly on the host.

To get started, you should clone the project and install the dependencies:

```bash
shell$ git clone https://github.com/freezingsaddles/freezing-sync
shell$ cd freezing-web
shell$ python3 -m venv env
shell$ source env/bin/activate
(env) shell$ pip install -e '.[dev]'
``````

### Deploying With Docker

See [freezing-compose](https://github.com/freezingsaddles/freezing-compose) for guide to deploying this in production along
with the related containers.

This component is designed to run as a container and should be configured with environment variables for:

- `BEANSTALKD_HOST`: The hostname (probably a container link) to a beanstalkd server.
- `BEANSTALKD_PORT`: The port for beanstalkd server (default 11300)
- `SQLALCHEMY_URL`: The URL to the database.
Expand All @@ -25,14 +41,16 @@ This component is designed to run as a container and should be configured with e
- `UPLOAD_GRACE_PERIOD`: How long (days) can people upload rides after competition>
- `EXCLUDE_KEYWORDS`: Any keywords to match on to exclude rides (default: "#NoBAFS"). Note: these are not case-sensitive.
## Running Locally
### Running Locally
If you are running this component locally for development/debugging, you may set these values in a configuration file, and specify the path to this file with the `APP_SETTINGS` environment variable. For example:
```bash
APP_SETTINGS=local.cfg freezing-sync
```
You can run individual sync commands too:
```bash
APP_SETTINGS=local.cfg python -m freezing.sync.cli.sync_weather --debug --limit 1
```
Expand All @@ -41,11 +59,16 @@ There are a few additional settings you may need (i.e. not to be default) when n
- `STRAVA_ACTIVITY_CACHE_DIR`: Where to put cached activities (absolute path is a good idea).
- `VISUAL_CROSSING_CACHE_DIR`: Similarly, where should weather files be stored?
# Legal
### Coding standards
This software is a an [Apache 2.0 Licensed](LICENSE), community-driven effort, and as such the contributions are owned by the individual contributors:
The `freezing-sync` code is intended to be [PEP-8](https://www.python.org/dev/peps/pep-0008/) compliant. Code formatting is done with [black](https://black.readthedocs.io/en/stable/), [isort](https://pycqa.github.io/isort/) and [djlint](https://www.djlint.com/) and can be linted with [flake8](http://flake8.pycqa.org/en/latest/). See the [pyproject.toml](pyproject.toml) file and install the dev dependencies to get these tools.
Copyright 2018 Hans Lillelid <br>
Copyright 2020 Richard Bullington-McGuire <br>
Copyright 2020 Merlin Hughes <br>
This project also has _optional_ support for [pre-commit](https://pre-commit.org) to run these checks automatically before you commit. To install pre-commit, install the `dev` dependencies and then run `pre-commit install` in the root of the repository.
## Legal
This software is a an [Apache 2.0 Licensed](LICENSE), community-driven effort, and as such the contributions are owned by the individual contributors:
- Copyright 2018 Hans Lillelid
- Copyright 2020 Richard Bullington-McGuire
- Copyright 2020 Merlin Hughes
2 changes: 1 addition & 1 deletion example.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ STRAVA_ACTIVITY_CACHE_DIR=data/cache/activities
STRAVA_CLIENT_ID=STRAVA_CLIENT_ID
STRAVA_CLIENT_SECRET=STRAVA_CLIENT_SECRET

# Python Time zone for competition days.
# Python Time zone for competition days.
# See https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
TIMEZONE=TIMEZONE:-America/New_York

Expand Down
83 changes: 83 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,85 @@
[project]
name = "freezing-sync"
version = "1.6.0"
description = "Freezing Saddles activity and metadata sync."
authors = [
{name = "Hans Lellelid", email = "[email protected]"},
{name = "Merlin Hughes"},
{name = "Richard Bullington-McGuire", email = "[email protected]"},
]
maintainers = [
{name = "Richard Bullington-McGuire", email = "[email protected]"},
]
license = {text = "Apache License (2.0)"}
dependencies = [
"APScheduler==3.11.0",
"GeoAlchemy2==0.16.0",
"PyMySQL==1.1.1",
"SQLAlchemy==1.4.54",
"colorlog==6.9.0",
"datadog==0.50.2",
"envparse==0.2.0",
"freezing-model @ https://github.com/freezingsaddles/freezing-model/archive/0.11.2.tar.gz",
"greenstalk==2.0.2",
"polyline==1.4.0",
"pytz==2024.2",
"requests==2.32.3",
"stravalib==1.2.0",
]
classifiers = [
"Development Status :: 5 - Production/Stable",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.10",
"Topic :: Games",
]

[project.optional-dependencies]
dev = [
"black",
"flake8-pyproject",
"flake8",
"isort",
"pre-commit",
"uppd",
]

[project.entry-points.console_scripts]
freezing-sync = "freezing.sync.run:main"
freezing-sync-activities = "freezing.sync.cli.sync_activities:main"
freezing-sync-athletes = "freezing.sync.cli.sync_athletes:main"
freezing-sync-detail = "freezing.sync.cli.sync_details:main"
freezing-sync-photos = "freezing.sync.cli.sync_photos:main"
freezing-sync-streams = "freezing.sync.cli.sync_streams:main"
freezing-sync-weather = "freezing.sync.cli.sync_weather:main"

[tool.isort]
profile = "black"

[tool.flake8]
# Thanks https://www.reddit.com/r/learnpython/comments/rr6y69/comment/hqeqt68/?utm_source=share&utm_medium=web2x&context=3
ignore = [
"E203",
"E501",
"W503",
]
max-line-length = 88
max-complexity = 39
extend-ignore = "E203"
inline-quotes = "double"

[tool.setuptools]
# Thanks https://stackoverflow.com/a/72547402/424301
py-modules = ["freezing"]


[tool.djlint]
line_break_after_multiline_tag=true
max_line_length=88

[tool.pymarkdown]
plugins.md013.enabled = false
extensions.front-matter.enabled = true
4 changes: 0 additions & 4 deletions requirements-test.txt

This file was deleted.

11 changes: 0 additions & 11 deletions requirements.txt

This file was deleted.

67 changes: 0 additions & 67 deletions setup.py

This file was deleted.

0 comments on commit a0382e7

Please sign in to comment.