Skip to content

Commit

Permalink
開発環境をPython3.11から3.12に変更しました (#668)
Browse files Browse the repository at this point in the history
* update Python3.12

* update poetry

* ruff v0.5による修正

* ruffの設定を変更

* update devcontaienr.json

* いったん削除

* update tarvis.yaml
  • Loading branch information
yuji38kwmt authored Aug 13, 2024
1 parent 177baf7 commit c0372cc
Show file tree
Hide file tree
Showing 10 changed files with 355 additions and 330 deletions.
23 changes: 9 additions & 14 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ RUN update-locale LANG=ja_JP.UTF-8 LANGUAGE=ja_JP:ja \
&& ln -sf /usr/share/zoneinfo/Asia/Tokyo /etc/localtime \
&& echo "Asia/Tokyo" > /etc/timezone

ENV LANG ja_JP.UTF-8
ENV LC_ALL ja_JP.UTF-8
ENV LC_CTYPE ja_JP.UTF-8
ENV LANG=ja_JP.UTF-8
ENV LC_ALL=ja_JP.UTF-8
ENV LC_CTYPE=ja_JP.UTF-8

RUN set -x \
&& sed -i.bak -r 's!(deb|deb-src) \S+!\1 http://jp.archive.ubuntu.com/ubuntu/!' /etc/apt/sources.list
Expand All @@ -31,15 +31,14 @@ RUN set -x \
# for docker
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
&& add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
# Python3.11をインストールするために、deadsnakes PPAを追加
# Python3.12をインストールするために、deadsnakes PPAを追加
&& add-apt-repository ppa:deadsnakes/ppa \
# Install packages
&& apt-get update \
&& apt-get install -y --no-install-recommends \
docker-ce-cli \
# python
python3.11-dev \
python3-pip \
python3.12-dev \
# common tools
bash-completion \
build-essential \
Expand Down Expand Up @@ -70,20 +69,16 @@ ENV PATH=/usr/local/devcontainer-tool/bin:${PATH}


# Python / pip
RUN ln -s $(which python3.11) /usr/bin/python
RUN ln -s $(which python3.12) /usr/bin/python
RUN curl -sSL https://bootstrap.pypa.io/get-pip.py | python -
ENV PYTHONDONTWRITEBYTECODE=1 \
PIP_DEFAULT_TIMEOUT=100 \
PIP_NO_CACHE_DIR=on \
PIP_DISABLE_PIP_VERSION_CHECK=on

# poetry
# # poetry
RUN set -x \
&& python -m pip install -U \
pip \
setuptools \
requests \
&& python -m pip install \
"poetry<1.8"
&& python -m pip install "poetry<1.9"

# Add user / Grant sudo privileges
RUN useradd -m -s /bin/bash -u 5000 -U vscode \
Expand Down
10 changes: 2 additions & 8 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
// https://github.com/microsoft/vscode-dev-containers/tree/v0.154.0/containers/docker-existing-dockerfile
{
"name": "Existing Dockerfile",
"name": "${localWorkspaceFolderBasename}",
"build": {
"dockerfile": "Dockerfile",
"context": ".",
"args": {},
"args": {}
},
"containerUser": "vscode",
"remoteUser": "vscode",
"updateRemoteUserUID": true,
// マウント対象のディレクトリを事前に作成する
"initializeCommand": "mkdir -p ${localWorkspaceFolder}/.devcontainer/venv",
"mounts": [
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind",
// ホスト側のvenvとコンテナ側のvenvを分類して、ホスト側でpoetryコマンドを利用できるようにする
"source=${localWorkspaceFolder}/.devcontainer/venv,target=${containerWorkspaceFolder}/.venv,type=bind"
],
"forwardPorts": [],
"runArgs": [
"--init",
"--net=host",
"--env=ANNOFAB_USER_ID",
"--env=ANNOFAB_PASSWORD"
],
"containerEnv": {
"CONTAINER_WORKSPACE": "${containerWorkspaceFolder}",
"LOCAL_WORKSPACE": "${localWorkspaceFolder}"
},
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind,consistency=cached",
"workspaceFolder": "/workspaces",
"postStartCommand": "poetry install --all-extras",
Expand Down
2 changes: 1 addition & 1 deletion .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ version: 2
build:
os: ubuntu-22.04
tools:
python: "3.11"
python: "3.12"

sphinx:
configuration: docs/conf.py
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ jobs:
- python: 3.9
- python: 3.10
- python: 3.11
- python: 3.12
script:
# 開発環境と同じPythonバージョンのみlintを実行する
- make lint
- python: 3.12


branches:
Expand Down
2 changes: 1 addition & 1 deletion annofabapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def _should_retry_with_status(status_code: int) -> bool:
# 注意:429(Too many requests)の場合は、backoffモジュール外でリトライするため、このメソッドでは判定しない
if status_code == requests.codes.not_implemented:
return False
if 500 <= status_code < 600:
if 500 <= status_code < 600: # noqa: SIM103
return True
return False

Expand Down
4 changes: 2 additions & 2 deletions annofabapi/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def _match_task_id_and_contain_input_data_json(zip_info: zipfile.ZipInfo) -> boo
return False
if paths[0] != task_id:
return False
if not paths[1].endswith(".json"):
if not paths[1].endswith(".json"): # noqa: SIM103
return False
return True

Expand Down Expand Up @@ -516,7 +516,7 @@ def is_input_data_json(zip_info: zipfile.ZipInfo) -> bool:
paths = [p for p in zip_info.filename.split("/") if len(p) != 0]
if len(paths) != 2:
return False
if not paths[1].endswith(".json"):
if not paths[1].endswith(".json"): # noqa: SIM103
return False
return True

Expand Down
Loading

0 comments on commit c0372cc

Please sign in to comment.