Skip to content

gergo/uvSetup #374

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

Merged
merged 26 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b8f4150
chore: set up uv as a project and package manager
gjedlicska Jan 19, 2025
6680272
chore: run ruff format
gjedlicska Jan 19, 2025
c052dfa
chore: run ruff format
gjedlicska Jan 19, 2025
ace7c39
chore: run ruff format
gjedlicska Jan 19, 2025
d380e6e
chore: run ruff format
gjedlicska Jan 19, 2025
ffb8045
chore: fix all ruff issues
gjedlicska Jan 19, 2025
4c91032
chore: test fix WIP
gjedlicska Jan 19, 2025
d526c8c
feat: add github actions workflow
gjedlicska Jan 19, 2025
6daef04
feat: run pre-commit in CI
gjedlicska Jan 19, 2025
035cd08
fix: missing ruff dev dependency added to project
gjedlicska Jan 19, 2025
811c584
chore: fix ruff import formatting
gjedlicska Jan 19, 2025
6279dd3
chore: update pre-commit repo to new version
gjedlicska Jan 19, 2025
fe0a8eb
chore: do not run on pr-s just yet
gjedlicska Jan 19, 2025
ce104ad
feat: add publish workflow
gjedlicska Jan 19, 2025
6fb6418
fix: checkout, duh...
gjedlicska Jan 19, 2025
e0b48f6
feat: use dynamic version magic
gjedlicska Jan 19, 2025
ee97f3b
chore: cleanup
gjedlicska Jan 19, 2025
dfa8fc9
docs: change readme to reference uv
gjedlicska Jan 20, 2025
3859a88
chore: uv-lock use editable local package
gjedlicska Jan 20, 2025
37c8e6d
ci: run server in ci
gjedlicska Jan 20, 2025
513594c
feat: run tests
gjedlicska Jan 20, 2025
970cf62
feat: add codecov upload
gjedlicska Jan 20, 2025
eb13c9b
chore: remove stuff to please the ci gods
gjedlicska Jan 21, 2025
9afb2c5
chore: add back and empty circleci config
gjedlicska Jan 21, 2025
17cbcc3
chore: just an echo of circleci
gjedlicska Jan 21, 2025
b7ba219
update uv.lock
dogukankaratas Jan 21, 2025
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
107 changes: 7 additions & 100 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,108 +1,15 @@
version: 2.1

orbs:
codecov: codecov/codecov@3.3.0

# Define the jobs we want to run for this project
jobs:
pre-commit:
parameters:
config_file:
default: ./.pre-commit-config.yaml
description: Optional, path to pre-commit config file.
type: string
cache_prefix:
default: ''
description: |
Optional cache prefix to be used on CircleCI. Can be used for cache busting or to ensure multiple jobs use different caches.
type: string
docker:
- image: speckle/pre-commit-runner:latest
resource_class: medium
steps:
- checkout
- restore_cache:
keys:
- cache-pre-commit-<<parameters.cache_prefix>>-{{ checksum "<<parameters.config_file>>" }}
- run:
name: Install pre-commit hooks
command: pre-commit install-hooks --config <<parameters.config_file>>
- save_cache:
key: cache-pre-commit-<<parameters.cache_prefix>>-{{ checksum "<<parameters.config_file>>" }}
paths:
- ~/.cache/pre-commit
- run:
name: Run pre-commit
command: pre-commit run --all-files
- run:
command: git --no-pager diff
name: git diff
when: on_fail

test:
machine:
image: ubuntu-2204:2023.02.1
docker_layer_caching: false
resource_class: medium
parameters:
tag:
default: "3.11"
type: string
steps:
- checkout
- run:
name: Install python
command: |
pyenv install -s << parameters.tag >>
pyenv global << parameters.tag >>
- run:
name: Startup the Speckle Server
command: docker compose -f docker-compose.yml up -d
- run:
name: Install Poetry
command: |
pip install poetry
- run:
name: Install packages
command: poetry install
- run:
name: Run tests
command: poetry run pytest --cov --cov-report xml:reports/coverage.xml --junitxml=reports/test-results.xml
- store_test_results:
path: reports
- store_artifacts:
path: reports
- codecov/upload

deploy:
build:
docker:
- image: "cimg/python:3.8"
- image: cimg/base:2023.03
steps:
- checkout
- run: python patch_version.py $CIRCLE_TAG
- run: poetry build
- run: poetry publish -u __token__ -p $PYPI_TOKEN
- run: echo "so long and thanks for all the fish"

# Orchestrate our job run sequence
workflows:
main:
build_and_test:
jobs:
- pre-commit:
filters:
tags:
only: /.*/
- test:
matrix:
parameters:
tag: ["3.11"]
filters:
tags:
only: /.*/
- deploy:
context: pypi
requires:
- pre-commit
- test
filters:
tags:
only: /[0-9]+(\.[0-9]+)*/
branches:
ignore: /.*/ # For testing only! /ci\/.*/
- build
56 changes: 56 additions & 0 deletions .github/workflows/github-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Specklepy test and build"
on:
# pull_request:
# branches:
# - 'v3-dev'
push:
branches:
- "gergo/uvSetup"
jobs:
ci:
name: continuous-integration
runs-on: ubuntu-latest
strategy:
matrix:
python-version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"

steps:
- uses: actions/checkout@v4

- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
enable-cache: true
cache-dependency-glob: "uv.lock"

- name: Install the project
run: uv sync --all-extras --dev

- uses: actions/cache@v3
with:
path: ~/.cache/pre-commit/
key: ${{ hashFiles('.pre-commit-config.yaml') }}

- name: Run pre-commit
run: uv run pre-commit run --all-files

# - name: Run Speckle Server
# run: docker compose up -d

# - name: Run tests
# run: uv run pytest --cov --cov-report xml:reports/coverage.xml --junitxml=reports/test-results.xml

# - uses: codecov/codecov-action@v5
# if: matrix.python-version == 3.13
# with:
# fail_ci_if_error: true # optional (default = false)
# files: ./reports/test-results.xml # optional
# token: ${{ secrets.CODECOV_TOKEN }}

- name: Minimize uv cache
run: uv cache prune --ci
36 changes: 36 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Publish a release to PyPI.
# name: 'Publish to PyPI'

# on:
# push:
# branches:
# - 'gergo/uvSetup'

# jobs:
# pypi-publish:
# name: Upload to PyPI
# runs-on: ubuntu-latest
# environment:
# name: release
# permissions:
# # For PyPI's trusted publishing.
# id-token: write
# steps:
# - name: 'Install uv'
# uses: astral-sh/setup-uv@v5
# - uses: actions/checkout@v4
# with:
# # This is necessary so that we have the tags.
# fetch-depth: 0
# - uses: mtkennerly/dunamai-action@v1
# with:
# env-var: MY_VERSION
# args: --style semver
# - run: echo $MY_VERSION
# - name: 'Build artifacts'
# run: uv build
# - name: Publish to PyPi
# run: uv publish --publish-url https://test.pypi.org/simple/

# - name: Test package install
# run: uv run --with specklepy --no-project -- python -c "import specklepy"
32 changes: 15 additions & 17 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
repos:
- repo: https://github.com/charliermarsh/ruff-pre-commit
- repo: local
hooks:
# Run the linter.
- id: ruff
rev: v0.8.2
name: ruff lint
entry: uv run ruff check --force-exclude
language: system
types_or: [python, pyi]
# Run the formatter.
- id: ruff-format
name: ruff format
entry: uv run ruff format --force-exclude
language: system
types_or: [python, pyi]


- repo: https://github.com/commitizen-tools/commitizen
hooks:
- id: commitizen
- id: commitizen-branch
stages:
- push
- pre-push
rev: v3.13.0

- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
# It is recommended to specify the latest version of Python
# supported by your project here, or alternatively use
# pre-commit's default_language_version, see
# https://pre-commit.com/#top_level-default_language_version
# language_version: python3.11
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
rev: v5.0.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,25 @@ Head to the [**📚 specklepy docs**](https://speckle.guide/dev/python.html) for

### Installation

This project uses python-poetry for dependency management, make sure you follow the official [docs](https://python-poetry.org/docs/#installation) to get poetry.
This project uses uv for dependency management, make sure you follow the official [docs](https://docs.astral.sh/uv/) to get it.

To bootstrap the project environment run `$ poetry install`. This will create a new virtual-env for the project and install both the package and dev dependencies.
To create a new virtual environment with uv run `$ uv venv` and follow the instructions on the screen to activate the virtual environment.
To bootstrap the project environment run `$ uv sync`. This will install both the package and dev dependencies.

If this is your first time using poetry and you're used to creating your venvs within the project directory, run `poetry config virtualenvs.in-project true` to configure poetry to do the same.
To execute any python script run `$ uv run python my_script.py`

To execute any python script run `$ poetry run python my_script.py`

> Alternatively you may roll your own virtual-env with either venv, virtualenv, pyenv-virtualenv etc. Poetry will play along an recognize if it is invoked from inside a virtual environment.
> Alternatively you may roll your own virtual-env with either venv, virtualenv, pyenv-virtualenv etc. Uv will play along an recognize if it is invoked from inside a virtual environment.

### Style guide

All our repo wide styling linting and other rules are checked and enforced by `pre-commit`, which is included in the dev dependencies.
All our repo wide styling linting and other rules are checked and enforced by `pre-commit`, which is included in the dev dependencies.
It is recommended to set up `pre-commit` after installing the dependencies by running `$ pre-commit install`.
Commiting code that doesn't adhere to the given rules, will fail the checks in our CI system.

### Local Data Paths

It may be helpful to know where the local accounts and object cache dbs are stored. Depending on on your OS, you can find the dbs at:

- Windows: `APPDATA` or `<USER>\AppData\Roaming\Speckle`
- Linux: `$XDG_DATA_HOME` or by default `~/.local/share/Speckle`
- Mac: `~/.config/Speckle`
Expand Down
8 changes: 1 addition & 7 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ services:
# Speckle Server dependencies
#######
postgres:
image: "postgres:14.5-alpine"
image: "postgres:16-alpine"
restart: always
environment:
POSTGRES_DB: speckle
Expand Down Expand Up @@ -53,12 +53,6 @@ services:
# Speckle Server
#######

speckle-frontend:
image: speckle/speckle-frontend-2:latest
restart: always
ports:
- "0.0.0.0:8080:8080"

speckle-server:
image: speckle/speckle-server:latest
restart: always
Expand Down
4 changes: 2 additions & 2 deletions example/units_none.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from devtools import debug

from specklepy.api import operations
from specklepy.objects.geometry import Base
from specklepy.objects.units import Units
from specklepy.objects_v2.geometry import Base
from specklepy.objects_v2.units import Units

dct = {
"id": "1234abcd",
Expand Down
31 changes: 0 additions & 31 deletions patch_version.py

This file was deleted.

Loading
Loading