Skip to content

Commit

Permalink
update poetry -> uv
Browse files Browse the repository at this point in the history
  • Loading branch information
iamtatsuki05 committed Oct 13, 2024
1 parent c5deb11 commit 233496e
Show file tree
Hide file tree
Showing 9 changed files with 2,788 additions and 4,394 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
docker compose build --progress=plain
docker compose up -d
- name: Test
run: docker compose exec python-cpu poetry run tox
run: docker compose exec python-cpu uv run tox
8 changes: 4 additions & 4 deletions .github/workflows/test_poetry.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ jobs:
sudo apt-get update
sudo apt-get install -y mecab libmecab-dev mecab-ipadic-utf8
- name: Install Poetry
- name: Install uv
run: |
curl -sSL https://install.python-poetry.org | python3 -
curl -LsSf https://astral.sh/uv/install.sh | sh
echo "PATH=$HOME/.local/bin:$PATH" >> $GITHUB_ENV
- name: Install dependencies
run: |
poetry install
uv sync
- name: Run tests
run: |
poetry run tox
uv run tox
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ services:
ports:
- "8888:8888"
command:
poetry run jupyter lab
uv run jupyter lab
--ip=0.0.0.0
--allow-root
--NotebookApp.token=''
Expand Down
13 changes: 5 additions & 8 deletions docker/cpu/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,19 @@ RUN curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py \
&& pip3 --no-cache-dir install --upgrade pip

## install Poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
ENV PATH $PATH:/root/.local/bin
RUN poetry config virtualenvs.create true \
&& poetry config virtualenvs.in-project false
COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv

WORKDIR ${WORKDIR}

# install python packages
COPY poetry.lock pyproject.toml ./
COPY uv.lock pyproject.toml ./
COPY src ./src
RUN poetry install --no-dev
RUN uv sync --frozen --no-cache

FROM base AS dev
WORKDIR ${WORKDIR}

# install python packages
COPY poetry.lock pyproject.toml ./
COPY uv.lock pyproject.toml ./
COPY src ./src
RUN poetry install
RUN uv sync --frozen --no-cache
4,310 changes: 0 additions & 4,310 deletions poetry.lock

This file was deleted.

128 changes: 66 additions & 62 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,69 +1,75 @@
[tool.poetry]
[project]
name = "project"
version = "0.1.0"
description = ""
authors = ["iamtatsuki05 <[email protected]>"]
packages = [
{ include = "project", from = "src/" },
description = "Add your description here"
requires-python = ">=3.10"
dependencies = [
"python-dotenv==1.0.0",
"setuptools==69.0.3",
"fire==0.5.0",
"pydantic==2.5.3",
"beautifulsoup4==4.12.2",
"selenium==4.16.0",
"fastapi==0.108.0",
"uvicorn==0.25.0",
"matplotlib==3.5.1",
"pandas==1.4.2",
"seaborn==0.11.2",
"japanize-matplotlib==1.1.3",
"numpy==1.22.3",
"jupyterlab==3.3.4",
"tqdm==4.64.0",
"scikit-learn==1.1.1",
"openpyxl==3.1.2",
"polars==0.20.31",
"aiohttp==3.9.5",
"tenacity==8.4.1",
"playwright==1.44.0",
]

[tool.poetry.dependencies]
python = "^3.10"
python-dotenv = "^1.0.0"
setuptools = "^69.0.3"
fire = "^0.5.0"
pydantic = "^2.5.3"
beautifulsoup4 = "^4.12.2"
selenium = "^4.16.0"
fastapi = "^0.108.0"
uvicorn = "^0.25.0"
matplotlib = "^3.5.1"
pandas = "^1.4.2"
seaborn = "^0.11.2"
japanize-matplotlib = "^1.1.3"
numpy = "^1.22.3"
jupyterlab = "^3.3.4"
tqdm = "^4.64.0"
scikit-learn = "^1.1.1"
openpyxl = "^3.1.2"
polars = "^0.20.31"
aiohttp = "^3.9.5"
tenacity = "^8.4.1"
playwright = "^1.44.0"
[tool.hatch.build.targets.wheel]
packages = ["src/project", "src"]

[tool.poetry.group.dev.dependencies]
pytest = "^7.0.0"
ipykernel = ">=6.13.0"
autopep8 = ">=1.6.0"
autoflake = ">=1.4"
flake8 = ">=4.0.1"
flake8-isort = ">=4.1.1"
flake8-quotes = ">=3.3.1"
flake8-print = ">=4.0.0"
isort = ">=5.10.1"
black = {extras = ["jupyter"], version = "^22.6.0"}
mypy = ">=0.971"
tox = ">=3.25.1"
pre-commit = ">=3.3.3"
nbstripout = "0.6.1"
[tool.uv]
dev-dependencies = [
"jupyterlab>=3.3.4",
"mypy>=1.11.2",
"nbstripout>=0.7.1",
"pre-commit>=4.0.1",
"pytest>=8.3.3",
"ruff>=0.6.9",
"tox>=4.21.2",
]

[tool.isort]
profile = "black"
line_length = 88
multi_line_output = 3
include_trailing_comma = true
skip = [".venv", ".tox"]
[tool.ruff]
line-length = 119
target-version = "py310"
exclude = [".git", ".venv", "__pycache__", "data", "dist", "misc", "notebooks", "prof", "tmp", "workspacea", ".tox"]

[tool.black]
skip-string-normalization = true
include = '\.py$'
[tool.ruff.format]
quote-style = "single"
indent-style = "space"
skip-magic-trailing-comma = false
line-ending = "auto"

[tool.pytest.ini_options]
testpaths = "tests/"
[tool.ruff.lint]
extend-select = [
"I", # isort
]
# ignores
ignore = ["E501"]

[tool.ruff.lint.isort]
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
split-on-trailing-comma = true

[tool.ruff.lint.pyupgrade]
# Python3.8互換のための設定
keep-runtime-typing = true

[tool.mypy]
python_version=3.10
files = "src/project"
python_version="3.10"
files = "src"
ignore_missing_imports = true
disallow_untyped_defs = true
no_implicit_optional = true
Expand All @@ -72,11 +78,9 @@ show_error_codes = true
pretty = true
allow_untyped_globals = true

[tool.flake8]
max-line-length = 119
ignore = "D, E203, W391, W503"
exclude = " .git, .venv, __pycache__, data, dist, misc, notebooks, prof, tmp, workspacea, .tox"
[tool.pytest.ini_options]
filterwarnings = ["ignore::DeprecationWarning",]

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
requires = ["hatchling"]
build-backend = "hatchling.build"
6 changes: 5 additions & 1 deletion src/project/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
def main():
from project.env import PACKAGE_DIR


def main() -> None:
print('Hello, World!')
print(f'PACKAGE_DIR: {PACKAGE_DIR}')


if __name__ == '__main__':
Expand Down
11 changes: 4 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ commands =

[testenv:lint]
allowlist_externals =
pflake8
ruff
mypy
black
isort
skip_install = true
commands =
# pflake8 --show-source --statistics src/ tests {posargs}
# mypy . {posargs}
black --check . {posargs}
isort --check-only . {posargs}
ruff check --output-format=full src/ tests {posargs}
mypy src/ {posargs}
ruff format --check ./
Loading

0 comments on commit 233496e

Please sign in to comment.