Skip to content

Commit

Permalink
support m1 MacBooks in bot (#824)
Browse files Browse the repository at this point in the history
This change allows Kodiak to run on M1 macs.

I originally tried upgrading to Python 3.10, but asyncio_redis has a bunch of issues and it will take a lot of care.

TODO in future PR:
- update web_api
  • Loading branch information
chdsbd authored Jul 3, 2022
1 parent eb64ac3 commit bbf3339
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 106 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
# Use our new PATH so we can call poetry from bash
echo 'export PATH="$PATH":"$HOME"/.local/bin' >> $BASH_ENV
source $BASH_ENV
command -v poetry || python -m pip install --user poetry==1.1.9
command -v poetry || python -m pip install --user poetry==1.1.13
poetry config virtualenvs.in-project true
poetry install
- save_cache:
Expand Down Expand Up @@ -68,7 +68,7 @@ jobs:
# Use our new PATH so we can call poetry from bash
echo 'export PATH="$PATH":"$HOME"/.local/bin' >> $BASH_ENV
source $BASH_ENV
command -v poetry || python -m pip install --user poetry==1.1.9
command -v poetry || python -m pip install --user poetry==1.1.13
poetry config virtualenvs.in-project true
poetry install
- save_cache:
Expand Down
1 change: 1 addition & 0 deletions bot/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7.13
2 changes: 1 addition & 1 deletion bot/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ RUN apt-get update && apt-get install -y supervisor

RUN mkdir -p /var/log/supervisor

RUN python3 -m pip install poetry===1.1.8
RUN python3 -m pip install poetry===1.1.13

RUN poetry config virtualenvs.in-project true

Expand Down
4 changes: 2 additions & 2 deletions bot/kodiak/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import annotations

from enum import Enum
from typing import Any, Dict, List, Optional, Union, cast
from typing import List, Optional, Union

import toml
from pydantic import BaseModel, ValidationError, validator
Expand Down Expand Up @@ -172,6 +172,6 @@ def parse_toml(
cls, content: str
) -> Union[V1, toml.TomlDecodeError, ValidationError]:
try:
return cls.parse_obj(cast(Dict[str, Any], toml.loads(content)))
return cls.parse_obj(toml.loads(content))
except (toml.TomlDecodeError, ValidationError) as e:
return e
255 changes: 157 additions & 98 deletions bot/poetry.lock

Large diffs are not rendered by default.

11 changes: 8 additions & 3 deletions bot/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,32 @@ python = "^3.7"
uvicorn = "^0.15.0"
toml = "^0.10.0"
PyJWT = "^1.7"
cryptography = "2.8"
cryptography = "^3.4.6"
structlog = "^19.1"
colorama = "^0.4.1"
databases = "0.3.2"
# bzpopmin and bzpopmax support. connection pool is built concurrently. TLS support.
asyncio_redis = {git = "https://github.com/chdsbd/asyncio-redis.git", branch="master"}
inflection = "0.5.1"
markdown-html-finder = "^0.2.3"
markupsafe = "^1.1"
fastapi = "^0.47.0"
sentry-sdk = "^1.5.12"
requests = "^2.22"
rure = "^0.2.2"
# same as `rure` on pypi, but with arm64 builds for macos.
kodiak_rure = "^0.2.2"
zstandard = "^0.13.0"
httpx = "^0.18.1"
httpcore = "0.13.2"
pydantic = "^1.9.1"

[tool.poetry.scripts]
kodiak = 'kodiak.cli:cli'

[tool.poetry.dev-dependencies]
pytest = "6.0.1"
black = "^21.9b0"
mypy = "^0.812"
mypy = "^0.960"
ipdb = "^0.13.9"
pytest-asyncio = "^0.10.0"
pytest-mock = "3.3.1"
Expand All @@ -42,6 +45,8 @@ flake8-pie = "0.7.1"
isort = "^4.3"
pytest-cov = "^2.10"
flake8-pyi = "^20.10"
types-requests = "^2.28.0"
types-toml = "^0.10.7"

[tool.poetry.plugins."pytest11"]
"pytest_plugin" = "pytest_plugin.plugin"
Expand Down
5 changes: 5 additions & 0 deletions bot/typings/jwt.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from typing_extensions import Literal

def encode(
*, payload: dict[str, object], key: str, algorithm: Literal["RS256"]
) -> bytes: ...
1 change: 1 addition & 0 deletions bot/typings/markdown_html_finder.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def find_html_positions(x: str) -> list[tuple[int, int]]: ...
1 change: 1 addition & 0 deletions bot/typings/markupsafe.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
def escape(__: str) -> str: ...

0 comments on commit bbf3339

Please sign in to comment.