Skip to content

Commit

Permalink
pypi publish (#12)
Browse files Browse the repository at this point in the history
* Create python-publish.yml

* (1) rename contents to onpy

* (2) rename src/ folder
  • Loading branch information
kyle-tennison authored Apr 26, 2024
1 parent 4ea4c58 commit 7ed6a74
Show file tree
Hide file tree
Showing 29 changed files with 126 additions and 85 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Upload Python Package

on:
release:
types: [published]

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e '.[dev]'
python -m pip install build
- name: Build package
run: python -m build
- name: Publish package
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pyshape
# onpy

A comprehensive API for creating [OnShape](https://onshape.com) models entirely
through Python.

[![Integration Tests](https://github.com/kyle-tennison/pyshape/actions/workflows/validate.yml/badge.svg)](https://github.com/kyle-tennison/pyshape/actions/workflows/validate.yml)
[![Integration Tests](https://github.com/kyle-tennison/onpy/actions/workflows/validate.yml/badge.svg)](https://github.com/kyle-tennison/onpy/actions/workflows/validate.yml)
8 changes: 4 additions & 4 deletions examples/preliminary.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# A preliminary example of how this module should look

from pyshape import Client
from pyshape.features.sketch import Sketch
from pyshape.features.extrude import Extrude
from onpy import Client
from onpy.features.sketch import Sketch
from onpy.features.extrude import Extrude

# from pyshape.features.extrude import Extrude
# from onpy.features.extrude import Extrude

client = Client()

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "pyshape"
name = "onpy"
version = "0.0.1"
requires-python = ">=3.12"
authors = [
Expand Down
2 changes: 1 addition & 1 deletion src/pyshape/__init__.py → src/onpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
)


from pyshape.client import Client
from onpy.client import Client
8 changes: 4 additions & 4 deletions src/pyshape/api/endpoints.py → src/onpy/api/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Contains different endpoints exposed to the RestApi object"""

import pyshape.api.model as model
from pyshape.api.versioning import VersionTarget
import onpy.api.model as model
from onpy.api.versioning import VersionTarget

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pyshape.api.rest_api import RestApi
from onpy.api.rest_api import RestApi


class EndpointContainer:
Expand All @@ -24,7 +24,7 @@ def document_create(self, name: str, description: str | None) -> model.Document:
"""Creates a new document"""

if description is None:
description = "Created with pyshape"
description = "Created with onpy"

return self.api.post(
endpoint="/documents",
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/pyshape/api/rest_api.py → src/onpy/api/rest_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

import json
import sys
from pyshape.api.endpoints import EndpointContainer
from pyshape.api.model import ApiModel
from pyshape.util.model import HttpMethod
from pyshape.util.exceptions import PyshapeApiError, PyshapeInternalError
from onpy.api.endpoints import EndpointContainer
from onpy.api.model import ApiModel
from onpy.util.model import HttpMethod
from onpy.util.exceptions import PyshapeApiError, PyshapeInternalError

import requests
from requests.auth import HTTPBasicAuth
Expand All @@ -14,7 +14,7 @@
from typing import TYPE_CHECKING, Callable

if TYPE_CHECKING:
from pyshape.client import Client
from onpy.client import Client


class RestApi:
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/pyshape/client.py → src/onpy/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Entry point to this library"""

from pyshape.util.credentials import CredentialManager
from pyshape.api.rest_api import RestApi
from pyshape.document import Document
from pyshape.util.exceptions import PyshapeParameterError
from pyshape.util.misc import find_by_name_or_id, UnitSystem
from onpy.util.credentials import CredentialManager
from onpy.api.rest_api import RestApi
from onpy.document import Document
from onpy.util.exceptions import PyshapeParameterError
from onpy.util.misc import find_by_name_or_id, UnitSystem

from loguru import logger

Expand Down
14 changes: 7 additions & 7 deletions src/pyshape/document.py → src/onpy/document.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Interface to managing OnShape documents"""

import pyshape.api.model as model
from pyshape.elements.partstudio import PartStudio
from pyshape.elements.assembly import Assembly
from pyshape.util.misc import find_by_name_or_id
from pyshape.api.versioning import WorkspaceWVM
from pyshape.util.exceptions import PyshapeParameterError
import onpy.api.model as model
from onpy.elements.partstudio import PartStudio
from onpy.elements.assembly import Assembly
from onpy.util.misc import find_by_name_or_id
from onpy.api.versioning import WorkspaceWVM
from onpy.util.exceptions import PyshapeParameterError

from typing import TYPE_CHECKING, Any
from functools import cache

if TYPE_CHECKING:
from pyshape.client import Client
from onpy.client import Client


class Document(model.NameIdFetchable):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""Assembly element interface"""

from pyshape.elements.base import Element
import pyshape.api.model as model
from onpy.elements.base import Element
import onpy.api.model as model

from typing import TYPE_CHECKING, override

if TYPE_CHECKING:
from pyshape.client import Client
from pyshape.document import Document
from onpy.client import Client
from onpy.document import Document


class Assembly(Element):
Expand Down
8 changes: 4 additions & 4 deletions src/pyshape/elements/base.py → src/onpy/elements/base.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
"""Abstract base class for OnShape elements (i.e., PartStudios, Assemblies, etc.)"""

import pyshape.api.model as model
import onpy.api.model as model

from abc import abstractmethod, ABC
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from pyshape.client import Client
from pyshape.document import Document
from pyshape.api.rest_api import RestApi
from onpy.client import Client
from onpy.document import Document
from onpy.api.rest_api import RestApi


class Element(ABC, model.NameIdFetchable):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""PartStudio element interface"""

from loguru import logger
from pyshape.elements.base import Element
import pyshape.api.model as model
from pyshape.features.base import Feature, FeatureList
from pyshape.features.default_planes import DefaultPlane, DefaultPlaneOrientation
from pyshape.api.versioning import WorkspaceWVM
from pyshape.util.exceptions import PyshapeFeatureError
from onpy.elements.base import Element
import onpy.api.model as model
from onpy.features.base import Feature, FeatureList
from onpy.features.default_planes import DefaultPlane, DefaultPlaneOrientation
from onpy.api.versioning import WorkspaceWVM
from onpy.util.exceptions import PyshapeFeatureError

from typing import TYPE_CHECKING, override

if TYPE_CHECKING:
from pyshape.client import Client
from pyshape.document import Document
from onpy.client import Client
from onpy.document import Document


class PartStudio(Element):
Expand Down
2 changes: 2 additions & 0 deletions src/onpy/features/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from onpy.features.extrude import Extrude
from onpy.features.sketch import Sketch
12 changes: 6 additions & 6 deletions src/pyshape/features/base.py → src/onpy/features/base.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
"""Base class for sketches"""

import pyshape.api.model as model
from pyshape.util.exceptions import PyshapeParameterError
import onpy.api.model as model
from onpy.util.exceptions import PyshapeParameterError

from abc import ABC, abstractmethod
from typing import TYPE_CHECKING, Any, Iterator, Protocol

if TYPE_CHECKING:
from pyshape.client import Client
from pyshape.document import Document
from pyshape.elements.partstudio import PartStudio
from pyshape.features.plane import Plane
from onpy.client import Client
from onpy.document import Document
from onpy.elements.partstudio import PartStudio
from onpy.features.plane import Plane


class Feature(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from enum import Enum
from textwrap import dedent
from typing import TYPE_CHECKING, override
from pyshape.features.base import Feature
from pyshape.features.plane import Plane
from pyshape.api.versioning import WorkspaceWVM
import pyshape.api.model as model
from onpy.features.base import Feature
from onpy.features.plane import Plane
from onpy.api.versioning import WorkspaceWVM
import onpy.api.model as model

if TYPE_CHECKING:
from pyshape.document import Document
from pyshape.elements.partstudio import PartStudio
from onpy.document import Document
from onpy.elements.partstudio import PartStudio


class DefaultPlaneOrientation(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import ABC, abstractmethod
import uuid
import pyshape.api.model as model
import onpy.api.model as model


class Entity(ABC):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from enum import Enum
import math
from typing import override
from pyshape.features.entities.base import Entity
import pyshape.api.model as model
from pyshape.util.misc import UnitSystem, Point2D
from onpy.features.entities.base import Entity
import onpy.api.model as model
from onpy.util.misc import UnitSystem, Point2D


class SketchCircle(Entity):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""OnShape extrusion feature"""

from typing import TYPE_CHECKING, override
from pyshape.api.model import Feature, FeatureAddResponse
from pyshape.features.base import Feature, Extrudable
import pyshape.api.model as model
from onpy.api.model import Feature, FeatureAddResponse
from onpy.features.base import Feature, Extrudable
import onpy.api.model as model

if TYPE_CHECKING:
from pyshape.elements.partstudio import PartStudio
from onpy.elements.partstudio import PartStudio


class Extrude(Feature):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Abstract Class for Planes"""

from pyshape.features.base import Feature
from onpy.features.base import Feature


class Plane(Feature): ...
14 changes: 7 additions & 7 deletions src/pyshape/features/sketch.py → src/onpy/features/sketch.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
from typing import TYPE_CHECKING, override

from loguru import logger
from pyshape.features.base import Feature, Extrudable
from pyshape.features.entities.base import Entity
from pyshape.features.entities.sketch_entities import SketchCircle, SketchLine
import pyshape.api.model as model
from pyshape.util.misc import unwrap_type, unwrap, Point2D, UnitSystem
from onpy.features.base import Feature, Extrudable
from onpy.features.entities.base import Entity
from onpy.features.entities.sketch_entities import SketchCircle, SketchLine
import onpy.api.model as model
from onpy.util.misc import unwrap_type, unwrap, Point2D, UnitSystem

if TYPE_CHECKING:
from pyshape.elements.partstudio import PartStudio
from pyshape.features.plane import Plane
from onpy.elements.partstudio import PartStudio
from onpy.features.plane import Plane


class Sketch(Feature, Extrudable):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Manages OnShape credentials"""

from pyshape.util.exceptions import PyshapeAuthError
from onpy.util.exceptions import PyshapeAuthError

import re
import os
Expand All @@ -11,7 +11,7 @@
class CredentialManager:
"""Manages token retrieval and credential storing"""

credential_path = os.path.expanduser(f"~/.pyshape/config.json")
credential_path = os.path.expanduser(f"~/.onpy/config.json")

@staticmethod
def is_secret_key(token: str | None) -> bool:
Expand Down Expand Up @@ -76,7 +76,7 @@ def fetch_dev_tokens() -> tuple[str, str] | None:

@staticmethod
def configure_file(access_token: str, secret_token: str) -> None:
"""Creates a configuration file at ~/.pyshape/config.json
"""Creates a configuration file at ~/.onpy/config.json
Args:
access_token: The access token/key from OnShape dev portal
Expand Down Expand Up @@ -115,7 +115,7 @@ def fetch_or_prompt() -> tuple[str, str]:
return tokens

logger.error(
"pyshape needs your OnShape credentials. \n"
"onpy needs your OnShape credentials. \n"
"navagate to https://dev-portal.onshape.com/keys and generate a pair of "
"access & secret keys. Paste them here when prompted:"
)
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/pyshape/util/misc.py → src/onpy/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
from dataclasses import dataclass
from enum import Enum
from typing import Self
from pyshape.api.model import NameIdFetchable
from pyshape.util.exceptions import PyshapeParameterError
from onpy.api.model import NameIdFetchable
from onpy.util.exceptions import PyshapeParameterError


def find_by_name_or_id[
Expand Down
File renamed without changes.
Loading

0 comments on commit 7ed6a74

Please sign in to comment.