Skip to content

Commit

Permalink
Merge pull request #374 from specklesystems/gergo/uvSetup
Browse files Browse the repository at this point in the history
gergo/uvSetup
  • Loading branch information
dogukankaratas authored Jan 22, 2025
2 parents e1e5d9d + b7ba219 commit b4e2f37
Show file tree
Hide file tree
Showing 63 changed files with 1,885 additions and 2,470 deletions.
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

0 comments on commit b4e2f37

Please sign in to comment.