Skip to content
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
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
root = true

[*]
# end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 4
charset = utf-8

[*.{bat,cmd,ps1}]
end_of_line = crlf

[*.sh]
end_of_line = lf

[LICENSE]
insert_final_newline = false
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh text eol=lf
22 changes: 9 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,15 @@ on:
- main

jobs:
check:
name: Black and pytest
ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
- run: uv python install 3.14
- run: uv run pytest --cov --cov-branch --cov-report=xml
- uses: codecov/codecov-action@fb8b3582c8e4def4969c97caa2f19720cb33a72f # v7.0.0
with:
python-version: "3.14"
enable-cache: true
- name: Sync
run: uv sync --locked --group dev
- name: Black
run: uv run black --check .
- name: Tests
run: uv run pytest
token: ${{ secrets.CODECOV_TOKEN }}
- run: uv run ruff format --check
- run: uv build
26 changes: 16 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Publish CwMath Package
name: Publish cwapi3d Package

on:
push:
tags:
- "v*"
branches:
- "main"

jobs:
build-and-publish:
name: Build and Publish
runs-on: ubuntu-latest
environment:
name: pypi
Expand All @@ -16,12 +15,19 @@ jobs:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Install uv
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: dorny/paths-filter@vceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
id: changes
with:
filters: |
src:
- 'src/**'
- 'pyproject.toml'
- if: steps.changes.outputs.src == 'true'
uses: astral-sh/setup-uv@11f9893b081a58869d3b5fccaea48c9e9e46f990 # v8.3.2
- name: Install Python
- if: steps.changes.outputs.src == 'true'
run: uv python install 3.14
- name: Build
- if: steps.changes.outputs.src == 'true'
run: uv build
- name: Publish
run: uv publish
- if: steps.changes.outputs.src == 'true'
uses: pypa/gh-action-pypi-publish@dc37677b2e1c63e2034f94d8a5b11f265b73ba33 # v1.14.2
4 changes: 0 additions & 4 deletions .pip-tools.toml

This file was deleted.

12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-illegal-windows-names
- id: end-of-file-fixer
- id: fix-byte-order-marker
- id: forbid-submodules
- id: no-commit-to-branch
- id: trailing-whitespace
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.14
13 changes: 5 additions & 8 deletions GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
* use meaningful and appropriate naming


Please follow the style guide below when adding functionalities.
Please follow the style guide below when adding functionalities.

```python

# imports
import math
import sys
from myclass import MyClass


# example function
def add_one(number:int) -> int:
def add_one(number: int) -> int:
"""Increase number by one.
Author: John Doe

Expand All @@ -32,15 +32,12 @@ def add_one(number:int) -> int:


# Aligned with opening delimiter.
foo = long_function_name(var_one, var_two,
var_three, var_four)
foo = long_function_name(var_one, var_two, var_three, var_four)

if foo == 'blah':
do_blah_thing()

do_one()
do_two()
do_three()

```

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2024 Cadwork
Copyright (c) 2026 Cadwork

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
13 changes: 5 additions & 8 deletions docs/style_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
* use meaningful and appropriate naming


Please follow the style guide below when adding functionalities.
Please follow the style guide below when adding functionalities.

```python

# imports
import math
import sys
from myclass import MyClass


# example function
def add_one(number:int) -> int:
def add_one(number: int) -> int:
"""Increase number by one.
Author: John Doe

Expand All @@ -32,15 +32,12 @@ def add_one(number:int) -> int:


# Aligned with opening delimiter.
foo = long_function_name(var_one, var_two,
var_three, var_four)
foo = long_function_name(var_one, var_two, var_three, var_four)

if foo == 'blah':
do_blah_thing()

do_one()
do_two()
do_three()

```

5 changes: 3 additions & 2 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ site_name: Cadwork Math Utilities
repo_name: cwapi3d/cwmath
repo_url: https://github.com/cwapi3d/cwmath

copyright: Copyright 2024 Cadwork
copyright: Copyright 2026 Cadwork

site_url: https://python.cadwork.dev/

theme:
name: material
logo: cw_logo.svg
favicon: cw_logo.svg
version: V30
version: V2026
palette:
- scheme: default
toggle:
Expand Down Expand Up @@ -75,6 +75,7 @@ extra_css:

plugins:
- search
- autorefs
- mkdocstrings:
handlers:
python:
Expand Down
40 changes: 21 additions & 19 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,43 +1,45 @@
[project]
name = "cwmath"
version = "1.0.0"
version = "1.0.1"

authors = [{ name = "Cadwork", email = "it@cadwork.ca" }]
requires-python = ">=3.14"
description = "Cadwork Math Utilities"
readme = "README.md"
license = { file = "LICENSE" }
keywords = ["cadwork"]
license-files = [ "LICENSE" ]
keywords = [ "cadwork" ]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Environment :: Plugins",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.14",
"Topic :: Software Development :: Libraries",
]
dependencies = []

[project.urls]
Homepage = "https://github.com/cwapi3d/cwmath"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[dependency-groups]
dev = [
"black",
"mkdocs",
"mkdocs-material",
"mkdocstrings[python]",
"pytest",
"black>=26.5.1",
"mkdocs>=1.6.1",
"mkdocs-autorefs>=1.4.4",
"mkdocs-material>=9.7.7",
"mkdocstrings[python]>=1.0.6",
"pre-commit>=4.6.2",
"pytest>=9.1.1",
"pytest-cov>=7.1.0",
"ruff>=0.16.3",
]

[tool.black]
line-length = 88
target-version = ["py314"]
[tool.ruff]
line-length = 120

[tool.pytest.ini_options]
testpaths = ["tests"]
[tool.ruff.format]
quote-style = "single"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
26 changes: 13 additions & 13 deletions src/cwmath/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
from cwmath.vec3 import Vec3

__all__ = [
"ABS_TOL",
"REL_TOL",
"Frame3",
"Line3",
"Plane3",
"Point2",
"Point3",
"Vec2",
"Vec3",
"is_close",
"project_point_on_line",
"project_point_on_plane",
"to_point_3d",
'ABS_TOL',
'REL_TOL',
'Frame3',
'Line3',
'Plane3',
'Point2',
'Point3',
'Vec2',
'Vec3',
'is_close',
'project_point_on_line',
'project_point_on_plane',
'to_point_3d',
]
5 changes: 2 additions & 3 deletions src/cwmath/cadwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@ def to_point_3d(
is imported only at this call site.
"""
if not isinstance(value, (Point3, Vec3)):
raise TypeError("to_point_3d expects a Point3 or Vec3")
raise TypeError('to_point_3d expects a Point3 or Vec3')
if factory is None:
try:
import cadwork as host
except ImportError as exc:
raise CadworkNotAvailableError(
"cadwork is not available; pass factory= to construct "
"a point_3d outside the cadwork host"
'cadwork is not available; pass factory= to construct a point_3d outside the cadwork host'
) from exc
factory = host
return factory.point_3d(value.x, value.y, value.z)
Loading