Skip to content

Commit

Permalink
switch to uv
Browse files Browse the repository at this point in the history
  • Loading branch information
Graeme22 committed Sep 24, 2024
1 parent af622f2 commit 2a0a6d1
Show file tree
Hide file tree
Showing 9 changed files with 1,781 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ Since Tastytrade certification sessions are severely limited in capabilities, th
1. Fork the repository to your personal Github account and make your proposed changes.
2. Export your username, password, and account number to the following environment variables: `TT_USERNAME`, `TT_PASSWORD`, and `TT_ACCOUNT`.
3. Make sure you have at least one share of long $F in your account, which will be used to place the OCO complex order (nothing will fill).
4. Run `make venv` to create the virtual environment, then `make test` to run the tests locally.
4. Run `make install` to create the virtual environment, then `make lint` and `make test` to run the tests locally.
30 changes: 16 additions & 14 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,29 @@ on:

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
uses: actions/setup-python@v2
- name: Set up Python 3.12
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install dependencies
python-version: '3.12'
- uses: yezz123/setup-uv@v4
- name: Setup uv venv
run: |
uv sync
uv pip install -e .
- name: Lint with ruff
run: |
python -m pip install --upgrade pip
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Linting...
uv run ruff check tastytrade/
uv run ruff check tests/
- name: Type check with mypy
run: |
isort --check --diff tastytrade/ tests/
flake8 --count --show-source --statistics tastytrade/ tests/
mypy -p tastytrade
- name: Testing...
uv run mypy -p tastytrade
uv run mypy -p tests
- name: Test with pytest
run: |
python -m pytest --cov=tastytrade --cov-report=term-missing tests/ --cov-fail-under=95
uv run pytest --cov=tastytrade --cov-report=term-missing tests/ --cov-fail-under=95
env:
TT_USERNAME: ${{ secrets.TT_USERNAME }}
TT_PASSWORD: ${{ secrets.TT_PASSWORD }}
128 changes: 109 additions & 19 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,117 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
name: Publish Python 🐍 distribution 📦 to PyPI and TestPyPI

name: Upload Python Package

on:
release:
types: [created]
on: push

jobs:
deploy:
build:
name: Build distribution 📦
runs-on: ubuntu-latest
permissions:
id-token: write

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install pypa/build
run: >-
python3 -m
pip install
build
--user
- name: Build a binary wheel and a source tarball
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/

publish-to-pypi:
name: >-
Publish Python 🐍 distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
needs:
- build
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/tastytrade
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1

github-release:
name: >-
Sign the Python 🐍 distribution 📦 with Sigstore
and upload them to GitHub Release
needs:
- publish-to-pypi
runs-on: ubuntu-latest

permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Sign the dists with Sigstore
uses: sigstore/[email protected]
with:
inputs: >-
./dist/*.tar.gz
./dist/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--notes ""
- name: Upload artifact signatures to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
# Upload to GitHub Release using the `gh` CLI.
# `dist/` contains the built packages, and the
# sigstore-produced signatures and certificates.
run: >-
gh release upload
'${{ github.ref_name }}' dist/**
--repo '${{ github.repository }}'
publish-to-testpypi:
name: Publish Python 🐍 distribution 📦 to TestPyPI
needs:
- build
runs-on: ubuntu-latest

environment:
name: testpypi
url: https://test.pypi.org/p/tastytrade

permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing

steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
python-version: '3.x'
- name: Install dependencies and build
run: |
python -m pip install --upgrade pip
pip install setuptools wheel
python setup.py sdist bdist_wheel
- name: Publish to PyPI
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to TestPyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/
20 changes: 9 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
.PHONY: venv lint test docs
.PHONY: install lint test docs

venv:
python -m venv .venv
.venv/bin/pip install -r requirements.txt
.venv/bin/pip install -e .
.venv/bin/pip install -r docs/requirements.txt
install:
uv sync
uv pip install -e .

lint:
.venv/bin/isort --check --diff tastytrade/ tests/
.venv/bin/flake8 --count --show-source --statistics tastytrade/ tests/
.venv/bin/mypy -p tastytrade
.venv/bin/mypy -p tests
uv run ruff check tastytrade/
uv run ruff check tests/
uv run mypy -p tastytrade
uv run mypy -p tests

test:
.venv/bin/pytest --cov=tastytrade --cov-report=term-missing tests/ --cov-fail-under=95
uv run pytest --cov=tastytrade --cov-report=term-missing tests/ --cov-fail-under=95

docs:
cd docs; make html
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
project = 'tastytrade'
copyright = '2024, Graeme Holliday'
author = 'Graeme Holliday'
release = '8.3'
release = '8.4'

# -- General configuration ---------------------------------------------------
# https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration
Expand Down
44 changes: 44 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[project]
name = "tastytrade"
version = "8.4"
description = "An unofficial SDK for Tastytrade!"
readme = "README.md"
requires-python = ">=3.8"
license = {file = "LICENSE"}
authors = [
{name = "Graeme Holliday", email = "[email protected]"},
]

dependencies = [
"fake-useragent>=1.5.1",
"pandas-market-calendars>=4.4.1",
"pydantic>=2.9.2",
"requests>=2.32.3",
"websockets>=13.1",
]

[project.urls]
Homepage = "https://github.com/tastyware/tastytrade"
Documentation = "https://tastyworks-api.readthedocs.io/en/latest"

[tool.uv]
dev-dependencies = [
"mypy>=1.11.2",
"pytest>=8.3.3",
"pytest-asyncio>=0.24.0",
"pytest-cov>=5.0.0",
"ruff>=0.6.7",
"types-pytz>=2024.2.0.20240913",
"types-requests>=2.32.0.20240914",
"sphinx<7",
"sphinx-rtd-theme==1.2.2",
"sphinx-toolbox==3.4.0",
"enum-tools>=0.12.0",
"autodoc-pydantic>=2.2.0",
]

[tool.setuptools.package-data]
"tastytrade" = ["py.typed"]

[tool.setuptools.packages.find]
where = ["tastytrade"]
14 changes: 0 additions & 14 deletions requirements.txt

This file was deleted.

28 changes: 0 additions & 28 deletions setup.py

This file was deleted.

Loading

0 comments on commit 2a0a6d1

Please sign in to comment.