-
Notifications
You must be signed in to change notification settings - Fork 0
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
サポートするPythonバージョンを「3.8以上」から「3.9以上」に変更しました。 #137
Changes from 15 commits
9861b6a
b980e68
525143c
3230b19
f452d12
13c3dd8
5dd9db5
8191aad
c84f979
f070f58
f2c9db0
c0f304e
6f7f868
b507412
9da98d2
fb05b87
09ea1af
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,132 +1,77 @@ | ||
FROM ubuntu:18.04 as devcontainer | ||
|
||
RUN set -x \ | ||
&& sed -i.bak -r 's!(deb|deb-src) \S+!\1 mirror://mirrors.ubuntu.com/mirrors.txt!' /etc/apt/sources.list | ||
|
||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
ca-certificates \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* | ||
FROM ubuntu:22.04 | ||
|
||
# Install prerequisites | ||
RUN set -x \ | ||
&& export DEBIAN_FRONTEND=noninteractive \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
gnupg2 \ | ||
software-properties-common \ | ||
language-pack-ja \ | ||
tzdata \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* \ | ||
curl \ | ||
lsb-release \ | ||
&& apt-get -y clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Set locale & timezone | ||
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 | ||
&& echo "Asia/Tokyo" > /etc/timezone | ||
|
||
# create vscode user | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
sudo \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* \ | ||
&& echo "vscode ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers.d/ALL \ | ||
&& groupadd \ | ||
--gid 5000 \ | ||
vscode \ | ||
&& useradd \ | ||
--uid 5000 \ | ||
--gid 5000 \ | ||
--home-dir /home/vscode \ | ||
--create-home \ | ||
--shell /bin/bash \ | ||
vscode | ||
ENV LANG=ja_JP.UTF-8 | ||
ENV LC_ALL=ja_JP.UTF-8 | ||
ENV LC_CTYPE=ja_JP.UTF-8 | ||
|
||
# vscode extensions cache | ||
# https://code.visualstudio.com/docs/remote/containers-advanced#_avoiding-extension-reinstalls-on-container-rebuild | ||
RUN set -x \ | ||
&& mkdir -p /home/vscode/.vscode-server/extensions /home/vscode/.vscode-server-insiders \ | ||
&& chown -R vscode:vscode /home/vscode/.vscode-server /home/vscode/.vscode-server-insiders \ | ||
&& ln -s /home/vscode/.vscode-server/extensions /home/vscode/.vscode-server-insiders/extensions | ||
&& sed -i.bak -r 's!(deb|deb-src) \S+!\1 http://jp.archive.ubuntu.com/ubuntu/!' /etc/apt/sources.list | ||
|
||
# common tools | ||
# Install Ubuntu packages | ||
RUN set -x \ | ||
# Python3.12をインストールするために、deadsnakes PPAを追加 | ||
&& add-apt-repository ppa:deadsnakes/ppa \ | ||
# Install packages | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
# python | ||
python3.12-dev \ | ||
# common tools | ||
bash-completion \ | ||
curl \ | ||
build-essential \ | ||
git \ | ||
gnupg2 \ | ||
iputils-ping \ | ||
jq \ | ||
less \ | ||
make \ | ||
net-tools \ | ||
openssh-client \ | ||
sudo \ | ||
tar \ | ||
time \ | ||
unzip \ | ||
vim \ | ||
wget \ | ||
xz-utils \ | ||
zip \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* | ||
&& apt-get -y clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# docker | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gnupg-agent \ | ||
software-properties-common \ | ||
&& 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" \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
docker-ce-cli \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* \ | ||
&& groupadd --gid 999 docker \ | ||
&& usermod -aG docker vscode | ||
|
||
# docker compose | ||
ARG COMPOSE_VERSION=1.27.4 | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
curl \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* \ | ||
&& curl -fsSL "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \ | ||
&& chmod +x /usr/local/bin/docker-compose \ | ||
&& curl -fsSL -o /etc/bash_completion.d/docker-compose "https://raw.githubusercontent.com/docker/compose/${COMPOSE_VERSION}/contrib/completion/bash/docker-compose" | ||
|
||
# docker / docker-compose in devcontainer | ||
RUN set -x \ | ||
&& mkdir -p /usr/local/devcontainer-tool/bin \ | ||
&& curl -fsSL -o /usr/local/devcontainer-tool/bin/docker https://github.com/thamaji/devcontainer-docker/releases/download/v1.0.2/docker \ | ||
&& chmod +x /usr/local/devcontainer-tool/bin/docker \ | ||
&& curl -fsSL -o /usr/local/devcontainer-tool/bin/docker-compose https://github.com/thamaji/devcontainer-compose/releases/download/v1.0.3/docker-compose \ | ||
&& chmod +x /usr/local/devcontainer-tool/bin/docker-compose | ||
ENV PATH=/usr/local/devcontainer-tool/bin:${PATH} | ||
|
||
# python3.8 | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
python3.8 \ | ||
python3.8-dev \ | ||
python3-pip \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* \ | ||
&& ln -s $(which python3.8) /usr/local/bin/python | ||
ENV PIP_DEFAULT_TIMEOUT=100 | ||
# Python / pip | ||
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 | ||
RUN set -x \ | ||
&& python -m pip install -U pip setuptools \ | ||
&& pip install poetry \ | ||
&& sudo -u vscode -i poetry config virtualenvs.in-project true | ||
&& python -m pip install "poetry<1.9" | ||
|
||
# fix poetry issue (see: https://github.com/python-poetry/poetry/issues/221) | ||
RUN set -x \ | ||
&& apt-get update \ | ||
&& apt-get install -y --no-install-recommends \ | ||
language-pack-en \ | ||
&& apt-get clean && rm -rf /var/cache/apt/archives/* /var/lib/apt/lists/* | ||
ENV LC_ALL=C.UTF-8 | ||
# Add user / Grant sudo privileges | ||
RUN useradd -m -s /bin/bash -u 5000 -U vscode \ | ||
&& echo "vscode ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/ALL | ||
|
||
USER vscode | ||
|
||
ADD entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT [ "bash", "-eux", "/entrypoint.sh" ] | ||
RUN poetry config virtualenvs.in-project true |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,42 @@ | ||
// 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": "KCI Python", | ||
"name": "${localWorkspaceFolderBasename}", | ||
"build": { | ||
"dockerfile": "Dockerfile", | ||
"context": ".", | ||
"args": { | ||
"COMPOSE_VERSION": "1.27.4", | ||
}, | ||
"target": "devcontainer" | ||
"args": {} | ||
}, | ||
"containerUser": "vscode", | ||
"remoteUser": "vscode", | ||
"updateRemoteUserUID": true, | ||
"overrideCommand": false, | ||
// マウント対象のディレクトリを事前に作成する | ||
"initializeCommand": "mkdir -p ${localWorkspaceFolder}/.devcontainer/venv", | ||
"mounts": [ | ||
"source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind", | ||
"source=${localWorkspaceFolder}/.devcontainer/.extensions,target=/home/vscode/.vscode-server/extensions,type=bind", | ||
// ホスト側のvenvとコンテナ側のvenvを分離して、ホスト側でpoetryコマンドを利用できるようにする | ||
// ホスト側のvenvとコンテン側のvenvを分類して、ホスト側でpoetryコマンドを利用できるようにする | ||
"source=${localWorkspaceFolder}/.devcontainer/venv,target=${containerWorkspaceFolder}/.venv,type=bind" | ||
], | ||
"forwardPorts": [], | ||
"runArgs": [ | ||
"--init", | ||
"--net=host", | ||
"--env=ANNOFAB_USER_ID", | ||
"--env=ANNOFAB_PASSWORD" | ||
], | ||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces,type=bind,consistency=cached", | ||
"workspaceFolder": "/workspaces", | ||
"postStartCommand": "poetry install", | ||
"extensions": [ | ||
"bungcip.better-toml", | ||
"jgclark.vscode-todo-highlight", | ||
"lextudio.restructuredtext", | ||
"mosapride.zenkaku", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"njpwerner.autodocstring", | ||
"streetsidesoftware.code-spell-checker" | ||
] | ||
"customizations": { | ||
"vscode": { | ||
"extensions": [ | ||
"mosapride.zenkaku", | ||
"ms-python.python", | ||
"ms-python.vscode-pylance", | ||
"charliermarsh.ruff", | ||
"streetsidesoftware.code-spell-checker", | ||
"bungcip.better-toml", | ||
"njpwerner.autodocstring", | ||
"mechatroner.rainbow-csv", | ||
"lextudio.restructuredtext" | ||
] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ version: 2 | |
build: | ||
os: ubuntu-22.04 | ||
tools: | ||
python: "3.8" | ||
python: "3.12" | ||
|
||
python: | ||
install: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,48 +11,21 @@ | |
}, | ||
"files.autoSave": "afterDelay", | ||
"files.autoSaveDelay": 1000, | ||
"python.pythonPath": ".venv/bin/python", | ||
"python.languageServer": "Pylance", | ||
"python.autoComplete.addBrackets": true, | ||
"python.autoComplete.extraPaths": [ | ||
".venv/lib/python3.8/site-packages/" | ||
".venv/lib/python3.12/site-packages/" | ||
], | ||
// "poetry run"コマンドで実行することを想定しているので、venv環境を自動的にactivateしないようにする | ||
"python.terminal.activateEnvironment":false, | ||
|
||
"python.formatting.blackPath": ".venv/bin/black", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VSCode 1.91.1で警告が出るので削除しました。 |
||
"python.formatting.provider": "black", | ||
"python.linting.enabled": true, | ||
"python.linting.lintOnSave": true, | ||
"python.linting.pylintEnabled": true, | ||
"python.linting.pylintPath": ".venv/bin/pylint", | ||
"python.linting.pylintArgs": [ | ||
"--rcfile setup.cfg", | ||
], | ||
"python.linting.flake8Enabled": true, | ||
"python.linting.flake8Path": ".venv/bin/flake8", | ||
"python.linting.flake8Args": [], | ||
"python.linting.mypyEnabled": true, | ||
"python.linting.mypyPath": ".venv/bin/mypy", | ||
"python.linting.mypyArgs": [], | ||
"python.linting.banditEnabled": false, | ||
"python.linting.pylamaEnabled": false, | ||
"python.linting.prospectorEnabled": false, | ||
"python.linting.pydocstyleEnabled": false, | ||
"python.linting.pycodestyleEnabled": false, | ||
"python.linting.ignorePatterns": [ | ||
".vscode/*.py", | ||
"**/site-packages/**/*.py", | ||
"docs/**/*.py" | ||
], | ||
"python.analysis.extraPaths": [ | ||
".venv/lib/python3.8/site-packages/" | ||
".venv/lib/python3.12/site-packages/" | ||
], | ||
"python.analysis.completeFunctionParens": true, | ||
"[python]": { | ||
"editor.formatOnSave": true, | ||
"editor.codeActionsOnSave": { | ||
"source.organizeImports": true | ||
"source.organizeImports": "explicit" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. VSCode 1.91.1の警告に従い修正しました。 |
||
}, | ||
}, | ||
"python.testing.autoTestDiscoverOnSaveEnabled": false, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,7 +20,7 @@ def open_resource(self) -> Generator[Resource, None, None]: | |
endpoint = ( | ||
self._annofab_endpoint if self._annofab_endpoint is not None else annofabapi.resource.DEFAULT_ENDPOINT_URL | ||
) | ||
resource = annofabapi.build(self._annofab_id, self._annofab_pass, endpoint) | ||
resource = annofabapi.build(self._annofab_id, self._annofab_pass, endpoint_url=endpoint) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 最新の annofabapi 0.74.0でエラーが出ないように修正しました。 |
||
try: | ||
yield resource | ||
finally: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Poetryはsetupptolsは必須としていないので、削除しました。
https://python-poetry.org/docs/configuration#virtualenvsoptionsno-setuptools