Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace requirements.txt with poetry #195

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
logo.png
Examples
Scripts
examples
venv
.venv
.github
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto

*.sh text eol=lf
22 changes: 8 additions & 14 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ on:
workflow_dispatch:

concurrency:
group: ${{ github.head_ref || github.ref_name }}
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
Expand All @@ -30,26 +30,20 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pylint pylint-exit pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Install poetry
uses: abatilo/actions-poetry@v2
- name: Setup flake8 annotations
uses: rbialon/flake8-annotations@v1
- name: Add pylint annotator
uses: pr-annotators/[email protected]
- name: Lint with flake8 and pylint
run: |
flake8 .
pylint PlexAniSync.py TautulliSyncHelper.py ./plexanisync || pylint-exit --error-fail --warn-fail $?
- run: pytest

- run: make lint
- run: make test

build-docker-plexanisync:
needs: lint-and-test
uses: ./.github/workflows/build-docker-image.yml
with:
dockerfile: ./Docker/PlexAniSync/Dockerfile
dockerfile: ./docker/PlexAniSync/Dockerfile
imagename: ${{ github.repository_owner }}/plexanisync
eventname: ${{ github.event_name }}
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
Expand All @@ -59,7 +53,7 @@ jobs:
needs: build-docker-plexanisync
uses: ./.github/workflows/build-docker-image.yml
with:
dockerfile: ./Docker/Tautulli/Dockerfile
dockerfile: ./docker/Tautulli/Dockerfile
imagename: ${{ github.repository_owner }}/tautulli-plexanisync
eventname: ${{ github.event_name }}
platforms: linux/amd64,linux/arm/v6,linux/arm/v7,linux/arm64
Expand Down
17 changes: 7 additions & 10 deletions .github/workflows/build-docker-image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,19 @@ jobs:
permissions:
contents: read
packages: write

env:
DOCKER_IO: ${{ startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/master' }}
steps:
# Set IMAGE_NAMES to ghcr.io, also set to docker.io if building a tag or master
- name: Set variables
run: |
- name: Set image names
run: |
EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64)
echo "IMAGE_NAMES<<$EOF" >> $GITHUB_ENV
if [[ ${{ github.ref }} == *"refs/tags/"* ]] || [[ ${{ github.ref }} == "refs/heads/master" ]]; then
DOCKER_IO=true
echo "ghcr.io/${{ inputs.imagename }}" >> $GITHUB_ENV
if [[ ${{ env.DOCKER_IO }} == true ]]; then
echo "${{ inputs.imagename }}" >> $GITHUB_ENV
fi
echo "ghcr.io/${{ inputs.imagename }}" >> $GITHUB_ENV
echo "$EOF" >> $GITHUB_ENV
if [[ -n "$DOCKER_IO" ]]; then
echo "DOCKER_IO=true" >> $GITHUB_ENV
fi
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up QEMU
Expand All @@ -56,7 +53,7 @@ jobs:
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Log into docker.com registry
if: ${{ env.DOCKER_IO }}
if: env.DOCKER_IO == 'true'
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/update-requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: update-requirements

on:
push:
paths:
- 'pyproject.toml'
- 'poetry.lock'
pull_request:
paths:
- 'pyproject.toml'
- 'poetry.lock'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
update-requirements:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.7
uses: actions/setup-python@v4
with:
python-version: 3.7
- name: Install poetry
uses: abatilo/actions-poetry@v2
- run: make update-requirements
- name: Commit requirements.txt changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update requirements.txt
35 changes: 0 additions & 35 deletions Docker/PlexAniSync/Dockerfile

This file was deleted.

23 changes: 0 additions & 23 deletions Docker/PlexAniSync/run/settingsupdater.py

This file was deleted.

38 changes: 0 additions & 38 deletions Docker/Tautulli/Dockerfile

This file was deleted.

27 changes: 27 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
SHELL := bash
ifeq ($(OS),Windows_NT)
EXITCODE = %ERRORLEVEL%
else
EXITCODE = $$?
endif

.PHONY: install
install:
poetry install --no-interaction --only main

.PHONY: install-dev-tools
install-dev-tools:
poetry install --no-interaction

.PHONY: lint
lint: install-dev-tools
poetry run flake8 .
poetry run pylint ./scripts/*.py ./plexanisync || poetry run pylint-exit --error-fail --warn-fail $(EXITCODE)

.PHONY: test
test: install-dev-tools
poetry run pytest -v

.PHONY: update-requirements
update-requirements:
poetry export --without-hashes --format=requirements.txt -o requirements.txt
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ https://github.com/RickDB/PlexAniSync/archive/master.zip

### Step 3 - Configuration

From the project directory rename `settings.ini.example` to `settings.ini`, open `settings.ini` with your favorite text editor and edit where needed.
In the `data` directory copy `settings.ini.example` to `settings.ini`, open `settings.ini` with your favorite text editor and edit where needed.


#### Plex
Expand Down Expand Up @@ -141,7 +141,7 @@ Install the addtional requirements using the Python package installer (pip) from

Now that configuration is finished and requirements have been installed we can finally start the sync script:

`python PlexAniSync.py`
`python scripts/PlexAniSync.py`

Depending on library size and server can take a few minutes to finish, for scheduled syncing you can create a cronjob, systemd timer or windows task which runs it every 30 minutes for instance.

Expand All @@ -153,7 +153,7 @@ See [Systemd service](https://github.com/RickDB/PlexAniSync/wiki/Systemd-service

You can manually link a Plex title and season to an AniList ID, to do so:

- From the project folder copy `custom_mappings.yaml.example` to `custom_mappings.yaml`
- In the `data` directory, copy `custom_mappings.yaml.example` to `custom_mappings.yaml`
- Add new entries there in the following format:

```yaml
Expand Down Expand Up @@ -199,11 +199,11 @@ The feature of synonyms was introduced for the community mappings where you can

If you want to load a different settings.in file you can do so by supplying it in the first argument like so:

`python PlexAniSync.py settings_alternate.ini`
`python scripts/PlexAniSync.py data/settings_alternate.ini`

In case of the Tautulli sync helper script you can do as well, first argument will then be settings filename and second will be the series name like so:

`python TautulliSyncHelper.py settings_alternate.ini <plex show name>`
`python scripts/TautulliSyncHelper.py data/settings_alternate.ini <plex show name>`

### Make Plex watched episode count take priority

Expand Down Expand Up @@ -247,7 +247,7 @@ In the project folder you will find `TautulliSyncHelper.py` which you can use to

Usage is as follows:

`python TautulliSyncHelper.py <plex show name>`
`python scripts/TautulliSyncHelper.py <plex show name>`

Depending on your OS make sure to place the show name between single or double quotes, for more information see the wiki page:

Expand All @@ -258,11 +258,11 @@ https://github.com/RickDB/PlexAniSync/wiki/Tautulli-sync-script
PlexAniSync is available as Docker image.

[PlexAniSync](https://github.com/RickDB/PlexAniSync/pkgs/container/plexanisync)<br/>
[Documentation](Docker/PlexAniSync/README.md)
[Documentation](docker/PlexAniSync/README.md)

Another docker container for Tautulli with built-in PlexAniSync can be found here:<br/>
[Tautulli-PlexAniSync](https://github.com/RickDB/PlexAniSync/pkgs/container/tautulli-plexanisync)<br/>
[Documentation](Docker/Tautulli/README.md)
[Documentation](docker/Tautulli/README.md)

## Requirements

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
35 changes: 35 additions & 0 deletions docker/PlexAniSync/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
FROM python:3.11 AS builder

RUN apt-get update && \
apt-get install -y build-essential

COPY requirements.txt .

# install dependencies to /venv
ENV PATH=/venv/bin:$PATH
RUN python -m venv /venv
RUN pip install -r requirements.txt

FROM python:3.11-slim

WORKDIR /plexanisync

# copy venv from builder
COPY --from=builder /venv /venv
ENV PATH=/venv/bin:$PATH

ENV PLEX_SECTION=Anime \
PLEX_URL=http://127.0.0.1:32400 \
PLEX_TOKEN='' \
ANI_USERNAME='' \
ANI_TOKEN='' \
INTERVAL=3600

COPY requirements.txt docker/PlexAniSync/run/. /plexanisync/
COPY data /plexanisync/data
COPY scripts /plexanisync/scripts
COPY plexanisync /plexanisync/plexanisync

LABEL org.opencontainers.image.documentation=https://github.com/RickDB/PlexAniSync/blob/master/docker/PlexAniSync/README.md

CMD ["/plexanisync/runsync.sh"]
4 changes: 2 additions & 2 deletions Docker/PlexAniSync/README.md → docker/PlexAniSync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ docker run -d \
-e ANI_TOKEN=SomeToken \
-e INTERVAL=3600 \
-v /etc/localtime:/etc/localtime:ro \
-v /path/to/your/custom_mappings.yaml:/plexanisync/custom_mappings.yaml \
-v /path/to/your/custom_mappings.yaml:/plexanisync/data/custom_mappings.yaml \
ghcr.io/rickdb/plexanisync:latest
```

Expand All @@ -37,7 +37,7 @@ services:
- INTERVAL=3600
volumes:
- '/etc/localtime:/etc/localtime:ro'
- '/path/to/your/custom_mappings.yaml:/plexanisync/custom_mappings.yaml'
- '/path/to/your/custom_mappings.yaml:/plexanisync/data/custom_mappings.yaml'
```

### Environment Variables
Expand Down
Loading