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

switch to uv #813

Merged
merged 1 commit into from
Nov 16, 2024
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
25 changes: 12 additions & 13 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ jobs:
name: docstubs
path: docstubs

- run: ./pw pdm use ${{ env.PYTHON_VERSION }} --first

- run: ./pw pdm install
- run: ./pw uv sync

# using relative path for npm scripts because it needs to work in the package directories too
- name: add pyprojectx and npm scripts to PATH
Expand All @@ -101,17 +99,18 @@ jobs:
# ideally this should be run with the rest of the pytest tests in the validation workflow,
# but they depend on the docstubs generated in the previous job
- name: validate docstubs
run: pdm run test_python -- -m needs_all_docstubs
run: uv run npm run test-python -- -m needs_all_docstubs

- id: current-version
# https://github.com/astral-sh/uv/issues/6298
run: |
echo ::set-output name=CURRENT_VERSION::$(pdm show --version)
echo ::set-output name=CURRENT_UPSTREAM_VERSION::$(pdm run node -p "require(\"./package.json\").version")
echo ::set-output name=CURRENT_VERSION::$(./pw uv run python -c "from based_build.get_version import get_version;print(get_version())")
echo ::set-output name=CURRENT_UPSTREAM_VERSION::$(uv run node -p "require(\"./package.json\").version")
working-directory: ${{ env.NPM_PACKAGE_DIR }}

- name: get currently published npm package version
if: github.ref == 'refs/heads/main'
run: echo ::set-output name=VERSION_INFO::$(pdm run npm view $(node -p "require(\"./package.json\").name")@=${{ steps.current-version.outputs.CURRENT_VERSION }})
run: echo ::set-output name=VERSION_INFO::$(uv run npm view $(node -p "require(\"./package.json\").name")@=${{ steps.current-version.outputs.CURRENT_VERSION }})
id: version-was-changed
working-directory: ${{ env.NPM_PACKAGE_DIR }}

Expand All @@ -122,7 +121,7 @@ jobs:
- name: Build VSIX
working-directory: ${{ env.VSIX_DIR }}
run: |
pdm run npm run package
uv run npm run package
mv basedpyright-*.vsix ${{ env.VSIX_NAME }}
- uses: actions/upload-artifact@v4
Expand All @@ -133,7 +132,7 @@ jobs:
# publish npm canary version on every push to every branch except main
- name: set version for npm canary
if: github.ref != 'refs/heads/main'
run: pdm run npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --workspace ${{ env.NPM_PACKAGE_DIR }} --no-git-tag-version
run: uv run npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --workspace ${{ env.NPM_PACKAGE_DIR }} --no-git-tag-version
- name: publish package - npm canary
if: github.ref != 'refs/heads/main'
uses: JS-DevTools/npm-publish@v1
Expand All @@ -144,7 +143,7 @@ jobs:
package: ${{ env.NPM_PACKAGE_DIR }}/package.json
- name: set version for npm canary (browser)
if: github.ref != 'refs/heads/main'
run: pdm run npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --workspace ${{ env.BROWSER_NPM_PACKAGE_DIR }} --no-git-tag-version
run: uv run npm version ${{ steps.current-version.outputs.CURRENT_VERSION }}-$GITHUB_SHA --workspace ${{ env.BROWSER_NPM_PACKAGE_DIR }} --no-git-tag-version
- name: publish package - npm canary (browser)
if: github.ref != 'refs/heads/main'
uses: JS-DevTools/npm-publish@v1
Expand All @@ -171,22 +170,22 @@ jobs:
access: public
package: ${{ env.BROWSER_NPM_PACKAGE_DIR }}/package.json

# this isn't ideal, but it's required becayse pdm publish re-builds the npm packages even tho they were already built earlier.
# this isn't ideal, but it's required becayse uv publish re-builds the npm packages even tho they were already built earlier.
# i think to fix that i need to rewrite pdm_build.py to use the build hooks so we can control it more easily, but i can't get that to work soooo
- name: set npm package versions back to upstream so pypi package can use it in --version output
if: github.ref == 'refs/heads/main'
run: npm version ${{ steps.current-version.outputs.CURRENT_UPSTREAM_VERSION }} --workspaces --no-git-tag-version

- name: build package - pypi
run: pdm build
run: uv build
- uses: actions/upload-artifact@v4
with:
name: dist
path: dist

- name: publish package - pypi
if: github.ref == 'refs/heads/main' && steps.version-was-changed.outputs.VERSION_INFO == ''
run: pdm publish
run: uv publish

# https://code.visualstudio.com/api/working-with-extensions/publishing-extension#get-a-personal-access-token
- name: publish VSIX - visual studio marketplace
Expand Down
31 changes: 0 additions & 31 deletions .github/workflows/deps.yaml

This file was deleted.

10 changes: 5 additions & 5 deletions .github/workflows/docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ jobs:
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: install dependencies
run: ./pw pdm install
run: ./pw uv sync
- name: validate docs
run: ./pw pdm run mkdocs build --strict
run: ./pw uv run mkdocs build --strict
- name: deploy dev docs
if: github.ref == 'refs/heads/main'
run: ./pw pdm run mike deploy --push --update-aliases dev
run: ./pw uv run mike deploy --push --update-aliases dev
- name: deploy release docs
if: github.ref_type == 'tag'
run: |
./pw pdm run mike deploy --push --update-aliases ${{ github.ref_name }} latest
./pw pdm run mike set-default --push latest
./pw uv run mike deploy --push --update-aliases ${{ github.ref_name }} latest
./pw uv run mike set-default --push latest
22 changes: 10 additions & 12 deletions .github/workflows/validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,30 @@ jobs:
steps:
- uses: actions/checkout@v4

- run: ./pw pdm use ${{ env.PYTHON_VERSION }} --first
- run: ./pw uv venv --python ${{ env.PYTHON_VERSION }}

# need to use pw script at least once even when activating the context so that the wrapper installs pyprojectx
- run: ./pw pdm lock --check
- run: ./pw uv sync --locked

- name: activate pyprojectx context
run: realpath ./.pyprojectx/main >> $GITHUB_PATH

- run: pdm install

- name: typescript typecheck
run: pdm run npm run typecheck
run: uv run npm run typecheck

- run: pdm run npm run check
- run: uv run npm run check

- name: python typecheck
run: pdm run typecheck
run: uv run npm run typecheck-python

- name: ruff check
run: pdm run ruff check --output-format github
run: uv run ruff check --output-format github

- name: ruff format
run: pdm run ruff format --check --diff
run: uv run ruff format --check --diff

- name: pylint
run: pdm run pylint
run: uv run npm run pylint

tests:
strategy:
Expand All @@ -57,7 +55,7 @@ jobs:
with:
python-version: ${{env.PYTHON_VERSION}}

- run: ./pw pdm install
- run: ./pw uv sync

# using relative path for npm scripts because it needs to work in the package directories too
- name: add pyprojectx and npm scripts to PATH (linux)
Expand All @@ -73,7 +71,7 @@ jobs:
echo "./node_modules/.bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: python tests
run: pdm run test_python -- -m "not needs_all_docstubs"
run: uv run npm run test-python -- -m "not needs_all_docstubs"

- name: npm test (pyright-internal)
run: npm test
Expand Down
1 change: 0 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"tamasfe.even-better-toml",
"redhat.vscode-yaml",
"github.vscode-github-actions",
"gabdug.pdm",
"Orta.vscode-jest"
]
}
4 changes: 2 additions & 2 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"focus": false,
"panel": "shared"
},
// tasks should be defined as either pdm or npm scripts where possible
// tasks should be defined npm scripts where possible
"tasks": [
{
"label": "Watch extension",
Expand Down Expand Up @@ -80,7 +80,7 @@
"label": "install dependencies",
"type": "shell",
"command": "./pw",
"args": ["pdm", "sync", "--clean", "-G", "dev", "-G", "docstubs", "-G", "lochelper"],
"args": ["uv", "sync"],
"presentation": {
"clear": true
},
Expand Down
13 changes: 4 additions & 9 deletions based_build/generateAllDocstubs.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
for pythonVersion in 3.13 3.12 3.11 3.10 3.9; do
./pw pdm use $pythonVersion --first
./pw pdm install --group=docstubs --no-self --no-default
./pw pdm run generate_docstubs
done
for pythonVersion in 3.8; do
./pw pdm use $pythonVersion --first
./pw pdm install --group=docstubs-old --no-self --no-default --lockfile pdm.docstubs-old.lock
./pw pdm run generate_docstubs
for pythonVersion in 3.13 3.12 3.11 3.10 3.9 3.8; do
./pw uv venv --python $pythonVersion
./pw uv sync --only-group=docstubs --no-install-project
./pw uv run npm run generate-docstubs
done
2 changes: 1 addition & 1 deletion docs/development/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ we recommend using vscode, as there are project configuration files in the repo

1. hit `F1` > `Tasks: Run task` > `install dependencies`, or run the following command:
```
./pw pdm install
./pw uv sync
```
this will install all dependencies required for the project (pyprojectx, pdm, node, typescript, etc.). all dependencies are installed locally to `./.venv` and `./node_modules`
2. press "Yes" when prompted by vscode to use the newly created virtualenv
Expand Down
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,16 @@
"typecheck": "npm exec --workspaces -- tsc --noEmit",
"run:cli:windows": "npm run build:cli:dev && node packages/pyright/index.js --pythonpath .venv/Scripts/python.exe",
"run:cli:unix": "npm run build:cli:dev && node packages/pyright/index.js --pythonpath .venv/bin/python",
"jest": "cd packages/pyright-internal && jest"
"jest": "cd packages/pyright-internal && jest",
"update-python-deps": "uv sync --upgrade",
"typecheck-python": "uv run --no-sync basedpyright",
"ruff-check": "uv run --no-sync ruff check && pw uv run --no-sync ruff format --check --diff",
"ruff-fix": "uv run --no-sync ruff check --fix && pw uv run --no-sync ruff format --fix",
"pylint": "uv run --no-sync pylint basedpyright based_build pdm_build.py",
"test-python": "uv run --no-sync pytest tests",
"generate-docstubs": "uv run --no-sync based_build/generate_docstubs.py",
"localization-helper": "uv run --no-sync based_build/localization_helper.py",
"docs": "uv run mkdocs serve"
},
"devDependencies": {
"@detachhead/ts-helpers": "^16.2.0",
Expand Down
Loading
Loading