Skip to content
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

Improve VS Code implementation #401

Merged
merged 3 commits into from
Dec 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .devcontainer/Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
ARG VARIANT=3.10-bullseye
FROM mcr.microsoft.com/vscode/devcontainers/python:0-${VARIANT}

ENV VIRTUAL_ENV=/opt/.venv
ENV FILE_LOCATION "/usr/src/app"
ENV PATH="$VIRTUAL_ENV/bin:$PATH"
ENV LOCAL_USER="vscode"

USER $LOCAL_USER

COPY . $FILE_LOCATION

WORKDIR $FILE_LOCATION

RUN sudo python3 -m venv $VIRTUAL_ENV && \
sudo chown -R $LOCAL_USER:$LOCAL_USER ${VIRTUAL_ENV} && \
. $VIRTUAL_ENV/bin/activate && \
python3 -m pip install --upgrade setuptools wheel Cython && \
python3 -m pip install -r $FILE_LOCATION/requirements.txt && \
python3 -m pip install -r $FILE_LOCATION/requirements_test.txt && \
sudo $FILE_LOCATION//script/install-coap-client.sh
36 changes: 33 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,39 @@
{
"name": "Pytradfri dev",
"context": "..",
"dockerFile": "../Dockerfile",
"settings": {},
"dockerFile": "Dockerfile.dev",
"postCreateCommand": "script/setup",
"postStartCommand": "script/bootstrap",
"containerEnv": {
"DEVCONTAINER": "1"
},
"settings": {
"python.pythonPath": "/opt/.venv/bin/python",
"python.defaultInterpreterPath": "/opt/.venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.formatting.provider": "black",
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.formatting.blackArgs": [
"-S",
"--line-length",
"88"
],
"python.linting.enabled": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"python.languageServer": "Pylance",
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
},
"extensions": [
"ms-python.vscode-pylance"
"ms-python.vscode-pylance",
"visualstudioexptteam.vscodeintellicode",
"esbenp.prettier-vscode"
],
}
24 changes: 24 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"python.pythonPath": "/opt/.venv/bin/python",
"python.defaultInterpreterPath": "/opt/.venv/bin/python",
"python.terminal.activateEnvInCurrentTerminal": true,
"python.formatting.provider": "black",
"[python]": {
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.formatting.blackArgs": [
"-S",
"--line-length",
"88"
],
"python.linting.enabled": true,
"editor.formatOnPaste": false,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"files.trimTrailingWhitespace": true,
"python.languageServer": "Pylance",
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
}
11 changes: 11 additions & 0 deletions script/bootstrap
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/sh
# Resolve all dependencies that the application requires to run.

# Stop on errors
set -e

cd "$(dirname "$0")/.."

echo "Installing development dependencies..."

. $VIRTUAL_ENV/bin/activate && python3 -m pip install -e .
8 changes: 8 additions & 0 deletions script/setup
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# Stop on errors
set -e

cd "$(dirname "$0")/../"

pre-commit install