Skip to content

Commit

Permalink
Switch to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
nrontsis committed Oct 22, 2024
1 parent f60cf87 commit 0377aa5
Show file tree
Hide file tree
Showing 15 changed files with 363 additions and 55 deletions.
23 changes: 19 additions & 4 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
FROM mcr.microsoft.com/vscode/devcontainers/typescript-node
RUN apt-get update && apt-get install -y python3 python3-pip python3.11-venv
RUN ln -s /usr/bin/python3 /usr/bin/python
RUN npm install -g @vscode/vsce
FROM ghcr.io/astral-sh/uv:debian
RUN apt-get -q update && \
apt-get install -y --no-install-recommends \
sudo \
vim \
npm && \
apt-get clean && rm -rf /var/lib/apt/lists/*
RUN npm install -g @vscode/vsce

# Setup non-root user
ARG USERNAME=user
ARG USER_UID=1000
ARG USER_GID=$USER_UID
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME
1 change: 1 addition & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
"mounts": [
"source=devcontainer-persistence,target=/devcontainer-persistence,type=volume"
],
"remoteUser": "user",
}
7 changes: 4 additions & 3 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ if [ ! -e ~/.bash_history ]; then
ln -s /devcontainer-persistence/.bash_history ~/.bash_history
fi

python3 -m venv .venv
for file in ~/.bashrc ~/.bash_profile; do
[ ! -f "$file" ] && touch "$file"
grep -q "export PYTHONPATH=$(pwd)" "$file" || echo "export PYTHONPATH=$(pwd)${PYTHONPATH:+:${PYTHONPATH}}" >> "$file"
done
grep -q "source $(pwd)/.venv/bin/activate" ~/.bashrc || echo "source $(pwd)/.venv/bin/activate" >> ~/.bashrc
.venv/bin/pip install -r requirements.txt -r requirements-dev.txt
.venv/bin/pre-commit install

uv lock
uv sync --locked
uv run pre-commit install
npm --prefix client install
14 changes: 4 additions & 10 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,10 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v4

- name: setup node
uses: actions/setup-node@v4

- name: clean install dependencies
run: cd client && npm ci

- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: astral-sh/setup-uv@v3
- run: cd client && npm ci
- name: compile and create vsix
run: |
cd client
Expand All @@ -27,7 +22,6 @@ jobs:
npm run compile
npm run webpack
npm run vscepack
- name: upload vsix as artifact
uses: actions/upload-artifact@v4
with:
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@ jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Set up Python virtual environment
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: Run pre-commit
run: |
source .venv/bin/activate
pre-commit run --all-files
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- run: uv python install
- run: uv sync --all-extras --locked --dev
- run: uv run pre-commit run --all-files
19 changes: 6 additions & 13 deletions .github/workflows/python-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,11 @@ name: Python Tests
on: [push, pull_request]

jobs:
pre-commit:
python-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
- name: Set up Python virtual environment
run: |
python -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt -r requirements-dev.txt
- name: Run tests
run: |
source .venv/bin/activate
pytest tests
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v3
- run: uv python install
- run: uv sync --all-extras --locked --dev
- run: uv run pytest tests
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,5 @@ code --force --install-extension PATH_TO_PACKAGES_EXTENSION.vsix
```
Make sure to reload the VSCode window after installation.


### Copyright Note
The `client` folder is essentially a modified copy of the `client` folder from https://github.com/QualiTorque/torque-vs-code-extensions

The initial folder structure vscode setup and CI were also heavily influenced from the same repo.
The typescript code is a modified copy of the `client` folder from https://github.com/QualiTorque/torque-vs-code-extensions which was licensed under Apache 2.0 License at the time the code was copied. Also, the initial folder structure, vscode setup, and CI were also heavily influenced from the same repo.
1 change: 0 additions & 1 deletion client/COPYRIGHT.md

This file was deleted.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
]
},
"scripts": {
"vscode:prepublish": "npm run compile && echo copying server && cp -Rf ../server/. out/server && cp ../*.md ./ && cp ../LICENSE ./LICENSE",
"vscode:prepublish": "./prepublish.sh",
"compile": "tsc -b",
"watch": "tsc -b -w",
"webpack": "webpack --mode development",
Expand Down
7 changes: 7 additions & 0 deletions client/prepublish.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
set -eu
cp -Rf ../server/. ./out/server
cp ../*.md ./
cp ../LICENSE ./LICENSE
uv export --no-emit-project --no-dev --format requirements-txt --frozen > ./out/server/requirements.txt
npm run compile
18 changes: 18 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
[project]
version = "0.0.0"
name = "venv"
readme = "README.md"
requires-python = ">=3.11"
dependencies = [
"pygls",
"pyyaml"
]

[tool.uv]
dev-dependencies = [
"pre-commit",
"ruff",
"pyright",
"pytest"
]

[tool.pyright]
include = ["server"]
useLibraryCodeForTypes = true
Expand Down
4 changes: 0 additions & 4 deletions requirements-dev.txt

This file was deleted.

1 change: 0 additions & 1 deletion requirements.txt

This file was deleted.

2 changes: 0 additions & 2 deletions server/requirements.txt

This file was deleted.

Loading

0 comments on commit 0377aa5

Please sign in to comment.