Skip to content

Commit

Permalink
build: install poetry and remove extraneous config files
Browse files Browse the repository at this point in the history
  • Loading branch information
engineervix committed Jun 6, 2023
1 parent 31280f7 commit b4ab738
Show file tree
Hide file tree
Showing 13 changed files with 2,874 additions and 652 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
COMPOSE_DOCKER_CLI_BUILD=1
DOCKER_BUILDKIT=1
COMPOSE_PROJECT_NAME=zednews
DEVELOPMENT=1

# OpenAI
OPENAI_API_KEY=CHANGE_ME!!!
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip" # caching pip dependencies
cache-dependency-path: "requirements*.txt"
cache: "poetry"
cache-dependency-path: "poetry.lock"

- name: Install Dependencies
shell: bash
Expand All @@ -166,10 +166,11 @@ jobs:
export LANG=en_US.UTF-8
export LANGUAGE=en_US:en
export LC_ALL=en_US.UTF-8
python -m venv ~/venv
source ~/venv/bin/activate
python -m pip install --upgrade pip
python -m pip install -r requirements.txt -r requirements-dev.txt
export POETRY_HOME=/opt/poetry
python3 -m venv $POETRY_HOME
$POETRY_HOME/bin/pip install poetry==1.4.1
source $POETRY_HOME/bin/activate
poetry install
- name: Test with unittest
shell: bash
Expand Down Expand Up @@ -199,8 +200,8 @@ jobs:
uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: "pip" # caching pip dependencies
cache-dependency-path: "requirements*.txt"
cache: "poetry"
cache-dependency-path: "poetry.lock"

- name: "Download coverage data"
uses: actions/download-artifact@v3
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,21 @@ ENV LC_ALL en_US.UTF-8
USER zednews

# set up virtual environment & install python dependencies
ARG POETRY_VERSION=1.4.1
ARG DEVELOPMENT
ENV VIRTUAL_ENV=/home/zednews/venv \
DEVELOPMENT=${DEVELOPMENT}
RUN python3 -m venv $VIRTUAL_ENV
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
RUN pip install --upgrade pip
RUN pip install pip-tools
COPY --chown=zednews ./requirements.txt .
COPY --chown=zednews ./requirements-dev.txt .
RUN python3 -m pip install -r requirements.txt ${DEVELOPMENT:+-r requirements-dev.txt}
RUN python -m pip install poetry==$POETRY_VERSION
COPY --chown=zednews ./pyproject.toml .
COPY --chown=zednews ./poetry.lock .
RUN poetry install ${DEVELOPMENT:+--with dev} --no-root

# Copy the source code of the project into the container
COPY --chown=zednews:zednews . .
RUN poetry install --only-root

# Runtime command that executes when "docker run" is called
# basically, do nothing ... we'll run commands ourselves
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ It consists primarily of two parts / components:
On your machine:

- you need to have [poetry](https://python-poetry.org/) installed
- create a python [virtual environment](https://realpython.com/python-virtual-environments-a-primer/)
- upgrade pip to latest version

Expand All @@ -77,7 +78,7 @@ On your machine:
- install dependencies

```bash
pip install -r requirements.txt -r requirements-dev.txt
poetry install
```

- update environment variables.
Expand Down Expand Up @@ -194,7 +195,7 @@ See `pre-commit-config.yaml` for more details. In addition, please note the foll

### Dev

- [ ] Switch to [Poetry](https://python-poetry.org/)
- [x] Switch to [Poetry](https://python-poetry.org/)
- [x] Replace [flake8](https://pypi.org/project/flake8/), [pycodestyle](https://pypi.org/project/pydocstyle/) and [isort](https://pypi.org/project/isort/) with [ruff](https://github.com/charliermarsh/ruff)
- [ ] Test all the things

Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
build:
context: .
args:
DEVELOPMENT: 1
DEVELOPMENT: ${DEVELOPMENT:-0}
command: tail -f /dev/null
volumes:
- ./:/home/zednews/app/
Expand Down
12 changes: 0 additions & 12 deletions jsconfig.json

This file was deleted.

2,811 changes: 2,811 additions & 0 deletions poetry.lock

Large diffs are not rendered by default.

87 changes: 42 additions & 45 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,53 +1,50 @@
[project]
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"

[tool.poetry]
name = "zed-news"
version = "0.2.0"
description = "news podcast on auto-pilot"
authors = ["Victor Miti <victormiti@gmail.com>"]
readme = "README.md"
requires-python = "~=3.10"
authors = [
{name = "Victor Miti", email = "victormiti@gmail.com"}
]
dependencies = [
"aerich",
"apprise",
"asyncpg",
"Babel",
"beautifulsoup4",
"boto3",
"bpython",
"cohere",
"colorama",
"eyed3",
"fake-useragent",
"feedparser",
"invoke",
"jinja2",
"langchain",
"num2words",
"openai",
"tortoise-orm[psycopg]",
"psycopg2-binary",
"python-dateutil",
"python-dotenv",
"pytz",
"requests",
"tiktoken",
"tomli",
]
packages = [{include = "app"}]

[project.optional-dependencies]
dev = [
"black",
"commitizen",
"coverage[toml]",
"DSLR",
"pip-tools",
"pre-commit",
"ruff",
]
[tool.poetry.dependencies]
python = "~=3.10"
aerich = "^0.7.1"
apprise = "^1.4.0"
asyncpg = "^0.27.0"
babel = "^2.12.1"
beautifulsoup4 = "^4.12.2"
boto3 = "^1.26.147"
bpython = "^0.24"
cohere = "^4.8.0"
colorama = "^0.4.6"
eyed3 = "^0.9.7"
fake-useragent = "^1.1.3"
feedparser = "^6.0.10"
invoke = "^2.1.2"
jinja2 = "^3.1.2"
langchain = "^0.0.191"
num2words = "^0.5.12"
openai = "^0.27.7"
tortoise-orm = {extras = ["psycopg"], version = "^0.19.3"}
psycopg2-binary = "^2.9.6"
python-dateutil = "^2.8.2"
python-dotenv = "^1.0.0"
pytz = "^2023.3"
requests = "^2.31.0"
tiktoken = "^0.4.0"
tomli = "^2.0.1"

[tool.setuptools]
py-modules = []
[tool.poetry.group.dev.dependencies]
black = "^23.3.0"
commitizen = "^3.2.2"
coverage = {version = "<6", extras = ["toml"]}
dslr = "^0.4.0"
pre-commit = "^3.3.2"
ruff = "^0.0.270"

[tool.black]
line-length = 120
Expand Down Expand Up @@ -104,7 +101,7 @@ skip_covered = true
show_missing = true

[tool.commitizen]
version_provider = "pep621"
version_provider = "poetry"
version_files = [
"app/__init__.py",
"cron.sh",
Expand Down
Loading

0 comments on commit b4ab738

Please sign in to comment.