Skip to content

Commit 253ab1c

Browse files
committed
switch to uv from pip and setuptools, switch to new Docker image, update docs, and update models with new Yahoo Fantasy Sports API fields
1 parent 095cc5e commit 253ab1c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+8474
-3232
lines changed

.github/workflows/python-package.yml

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,27 @@ jobs:
1818
strategy:
1919
fail-fast: false
2020
matrix:
21-
python-version: ["3.10", "3.11", "3.12"]
21+
python-version: ["3.10", "3.11", "3.12", "3.13"]
2222

2323
steps:
2424
- uses: actions/checkout@v4
25-
- name: Set up Python ${{ matrix.python-version }}
26-
uses: actions/setup-python@v5
25+
26+
- name: Install uv and set the python version to ${{ matrix.python-version }}
27+
uses: astral-sh/setup-uv@v6
2728
with:
29+
version: "0.8.17"
30+
enable-cache: true
2831
python-version: ${{ matrix.python-version }}
32+
2933
- name: Install dependencies
3034
run: |
31-
python -m pip install --upgrade pip
32-
python -m pip install flake8 bandit pytest
33-
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
34-
- name: Lint with flake8
35-
run: |
36-
# stop the build if there are Python syntax errors
37-
flake8 . --count --show-source --statistics
38-
# exit-zero treats all errors as warnings
39-
flake8 . --count --exit-zero --statistics
40-
- name: Security lint with bandit
41-
run: |
42-
# stop the build if there are security warnings
43-
bandit -r yfpy/
44-
# - name: Test with pytest
45-
# run: |
46-
# pytest
35+
uv sync --locked --all-extras --dev
36+
37+
- name: Lint with ruff
38+
run: make lint
39+
40+
- name: Security check with bandit
41+
run: make secure
42+
43+
# - name: Run tests with pytest
44+
# run: make test_code

.gitignore

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,15 @@ dist/
1717

1818
# Testing
1919
.pytest_cache/
20-
test_output/
20+
output/
2121

2222
# Environment
2323
*.env*
2424
!.env.template
25-
*.venv
25+
.venv
26+
.venv*/
2627
.python-version
28+
.python-venv
2729

2830
# Credentials
2931
*private*.json

DEPLOYMENT.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,33 @@
33
1. *(Optional)* Clear virtual machine of old requirements:
44

55
```shell
6-
pip uninstall -y -r <(pip freeze)
6+
uv pip uninstall -y -r <(uv pip freeze)
77
```
88

9-
2. *(Optional)* Check `requirements.txt` and `requirement-dev.txt` for latest dependency versions.
9+
2. *(Optional)* Check the `dependencies` and `dev-dependencies` sections of `pyproject.toml` for latest dependency versions.
1010

1111
3. *(Optional)* Update virtual machine with the latest dependencies:
1212

1313
```shell
14-
pip install -r requirements.txt -r requirements-dev.txt
14+
make update
1515
```
1616

17-
4. Lint code with `flake8`:
17+
4. Lint code with `ruff`:
1818

1919
```shell
20-
flake8 . --count --show-source --statistics
20+
make lint
2121
```
2222

2323
5. Check code security with `bandit`:
2424

2525
```shell
26-
bandit -r yfpy/
26+
make secure
2727
```
2828

2929
6. Run *all* `pytest` tests (see following commands for running subsets of tests):
3030

3131
```shell
32-
python -m pytest
32+
make test_code
3333
```
3434

3535
7. Run *all* `pytest` tests *verbosely*:
@@ -47,19 +47,19 @@
4747
9. *(Optional)* Run all tests from `pytest` file:
4848

4949
```shell
50-
python -m pytest -v -s -m integration test/integration/test_api_game_data.py
50+
python -m pytest -v -s -m integration tests/integration/test_api_game_data.py
5151
```
5252

5353
10. *(Optional)* Run *specific* test from `pytest` file:
5454

5555
```shell
56-
python -m pytest -v -s -m integration test/integration/test_api_game_data.py -k test_get_game_key_by_season
56+
python -m pytest -v -s -m integration tests/integration/test_api_game_data.py -k test_get_game_key_by_season
5757
```
5858

5959
11. *(Optional)* Test Python support using [act](https://github.com/nektos/act) for GitHub Actions:
6060

6161
```shell
62-
act_amd -j build
62+
make test_actions
6363
```
6464

6565
***Note***: If `act` is unable to locate Docker, make sure that the required `/var/run/docker.sock` symlink exists. If it does not, you can fix it by running:
@@ -92,7 +92,7 @@
9292
make docs
9393
```
9494

95-
***Note***: Running `make test_docs` from the previous step recreates the documentation without building the PyPI package with `setup.py`.
95+
***Note***: Running `make test_docs` from the previous step recreates the documentation without building the PyPI package with `uv`.
9696

9797
16. Create a git commit:
9898

@@ -113,7 +113,7 @@
113113
18. Install `twine` (if not already installed):
114114

115115
```shell
116-
pip install twine
116+
uv add twine
117117
```
118118

119119
19. *(Optional)* Test deployment by building the PyPI packages, recreating the documentation, and deploying to Test PyPI:

MANIFEST.in

Lines changed: 0 additions & 29 deletions
This file was deleted.

Makefile

Lines changed: 44 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,58 @@ THIS_FILE := $(lastword $(MAKEFILE_LIST))
99
help:
1010
@$(DOCS_BUILD) -h $(DOCS_OPTS) $(O)
1111

12-
.PHONY: build verify_build test_docs docs pages test_deploy deploy help Makefile
12+
.PHONY: update lint secure test_code test_actions test_actions_amd build verify_build get_version pre_build test_docs docs test_deploy uv_test_deploy deploy uv_deploy git_post_deploy git_update_docs help Makefile
1313

14-
build: ## Build PyPI packages for distribution.
15-
cd ${HOME}/Projects/personal/yfpy; python setup.py sdist bdist_wheel
14+
update: ## Update all package dependencies.
15+
uv sync --all-extras --dev
16+
17+
lint: ## Lint the package code with ruff.
18+
ruff check .
19+
20+
secure: ## Check package code security with bandit.
21+
bandit -c pyproject.toml -r .
22+
23+
test_code: ## Run code tests with Pytest.
24+
pytest tests
25+
26+
test_actions: ## Test package GitHub Actions using act.
27+
act -j build
28+
29+
test_actions_amd: ## Test package GitHub Actions on ARM architecture using act.
30+
act --container-architecture linux/amd64 -j build
31+
32+
build: update lint secure test_code ## Build PyPI packages for distribution.
33+
rm -rf dist/ && uv build
1634

1735
verify_build: ## Check PyPI packages for issues.
1836
twine check dist/*
1937

20-
test_docs: ## Extract YFPY project version from VERSION.py and serve MkDocs documentation locally for testing.
21-
export YFPY_VERSION=$$(python -c "from VERSION import __version__; print(__version__)") && mkdocs serve
38+
get_version: ## Extract Python package version from VERSION.py
39+
echo $$(python -c "from VERSION import __version__; print(f'v{__version__}')")
2240

23-
docs: build ## Extract YFPY project version from VERSION.py and build MkDocs documentation for distribution.
24-
export YFPY_VERSION=$$(python -c "from VERSION import __version__; print(__version__)") && mkdocs build
41+
pre_build: ## Set Python package version in VERSION.py using latest git tag, update docs with package version, update Docker Compose files with package and Python versions, and prepare documentation in /docs directory for GitHub Pages.
42+
python scripts/pre_build.py
2543

26-
pages: docs ## Prepare documentation in /docs directory for GitHub Pages.
27-
python docs-mkdocs/scripts/update_docs_for_github_pages.py
44+
test_docs: ## Extract Python package version and serve MkDocs documentation locally for testing.
45+
export PYTHON_PACKAGE_VERSION=$$(python -c "from VERSION import __version__; print(f'v{__version__}')") && mkdocs serve
2846

29-
test_deploy: pages ## Deploy PyPI packages to Test PyPI.
47+
docs: pre_build build ## Extract Python package version and build MkDocs documentation for distribution.
48+
export PYTHON_PACKAGE_VERSION=$$(python -c "from VERSION import __version__; print(f'v{__version__}')") && mkdocs build
49+
50+
test_deploy: docs verify_build ## Deploy PyPI package to Test PyPI with Twine.
3051
twine upload -r testpypi dist/*
3152

32-
deploy: pages ## Deploy PyPI packages to PyPI.
53+
uv_test_deploy: docs verify_build ## Deploy PyPI package to Test PyPI with uv.
54+
export UV_PUBLISH_URL=https://test.pypi.org/legacy/ && export UV_PUBLISH_TOKEN=$$(python -c "import os; from dotenv import load_dotenv; load_dotenv(); print(os.environ.get('TEST_UV_PUBLISH_TOKEN'))") && uv publish
55+
56+
deploy: docs verify_build ## Deploy PyPI package to PyPI with Twine.
3357
twine upload dist/*
58+
59+
uv_deploy: docs verify_build ## Deploy PyPI package to PyPI with uv.
60+
export UV_PUBLISH_URL=https://upload.pypi.org/legacy/ && export UV_PUBLISH_TOKEN=$$(python -c "import os; from dotenv import load_dotenv; load_dotenv(); print(os.environ.get('UV_PUBLISH_TOKEN'))") && uv publish
61+
62+
git_post_deploy: ## Update git by adding changed files, committing with a message about updating documentation and version number, and pushing
63+
git add . && git commit -m 'updated version number and documentation' && git push
64+
65+
git_update_docs: ## Update git by adding changed documentation files, committing with a message about updating documentation, and pushing
66+
git add . && git commit -m 'updated documentation' && git push

README.md

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[<img src="https://raw.githubusercontent.com/uberfastman/yfpy/refs/heads/main/docs/yfpy-logo.svg" width="400"/>](https://github.com/uberfastman/yfpy)
22

33
## YFPY - Yahoo Fantasy Sports API Wrapper
4+
45
Python API wrapper for the Yahoo Fantasy Sports public API
56

67
*Author: Wren J. R. (uberfastman)*
@@ -34,9 +35,11 @@ Python API wrapper for the Yahoo Fantasy Sports public API
3435
<sup>Detailed documentation on YFPY can be found at [https://yfpy.uberfastman.com](https://yfpy.uberfastman.com).</sup>
3536

3637
### Table of Contents
38+
3739
* [About](#about)
3840
* [Installation](#installation)
3941
* [Pip](#pip)
42+
* [uv](#uv)
4043
* [Manual](#manual)
4144
* [Setup](#setup)
4245
* [Yahoo Developer Network App](#yahoo-developer-network-app)
@@ -60,6 +63,7 @@ Python API wrapper for the Yahoo Fantasy Sports public API
6063
* [Development](#development)
6164
* [Troubleshooting](#troubleshooting)
6265
* [Yahoo Fantasy Sports API](#yahoo-fantasy-sports-api)
66+
* [JetBrains and PyCharm](#jetbrains-and-pycharm)
6367

6468
---
6569

@@ -76,13 +80,23 @@ YFPY is a comprehensive wrapper around the Yahoo Fantasy Sports API. It allows f
7680
<a name="pip"></a>
7781
#### Pip
7882

79-
* If you wish to use YFPY within another project, from within your project directory, run
83+
* If you wish to use YFPY within another project, from within your project directory, run:
8084
```shell
8185
pip install yfpy
8286
```
8387

8488
or add `yfpy` to your project `requirements.txt`.
8589

90+
<a name="uv"></a>
91+
#### uv
92+
93+
* If you wish to use YFPY within another project, from within your project directory, run:
94+
```shell
95+
uv add yfpy
96+
```
97+
98+
or add `yfpy` to the project `dependencies` section in your `pyproject.toml`.
99+
86100
<a name="manual"></a>
87101
#### Manual
88102

@@ -229,7 +243,7 @@ query.save_access_token_data_to_env_file(
229243
#### Querying the Yahoo Fantasy Sports API
230244
231245
* See the documentation on the [`yfpy.query.YahooFantasySportsQuery`](https://yfpy.uberfastman.com/_autosummary/yfpy.query.YahooFantasySportsQuery.html#yfpy.query.YahooFantasySportsQuery) class for example usage of all available queries.
232-
* See [`quickstart/quickstart.py`](https://github.com/uberfastman/yfpy/blob/main/quickstart/quickstart.py) for example usage output.
246+
* See [`scripts/quickstart.py`](https://github.com/uberfastman/yfpy/blob/main/scripts/quickstart.py) for example usage output.
233247
* Uncomment/comment out whichever configuration values in their respective functions with which you wish to experiment.
234248
* Uncomment/comment out whichever query lines in the `RUN QUERIES` section you wish to run.
235249
* Uncomment/comment out whichever query lines in the `CHECK FOR MISSING DATA FIELDS` section you wish to check for any new/missing data fields returned by the Yahoo Sports Fantasy Football API.
@@ -250,11 +264,11 @@ YFPY can be used within Docker for a more seamless, platform-agnostic experience
250264
```
251265
Then:
252266
```shell
253-
python quickstart/quickstart.py
267+
python scripts/quickstart.py
254268
```
255269
* Send commands to the running container from your host machine:
256270
```shell
257-
docker exec -i yfpy-package-1 bash -c "python quickstart/quickstart.py"
271+
docker exec -i yfpy-package-1 bash -c "python scripts/quickstart.py"
258272
```
259273
260274
<a name="docker-development"></a>
@@ -289,7 +303,7 @@ YFPY has a collection of fully functional code snippets that can be run using [p
289303
* Before running any integration tests, make a copy of [`auth/.env.template`](https://github.com/uberfastman/yfpy/blob/main/auth/.env.template) in the [`auth/`](https://github.com/uberfastman/yfpy/blob/main/auth/) directory and rename it to `.env`.
290304
* Copy your Yahoo `Client ID` and `Client Secret` into the environment variables in `.env` so that pytest can use them when hitting the Yahoo Fantasy Sports API.
291305
* If this is the first time running pytest with your Yahoo API credentials, you ***MUST*** allow interactive prompts within pytest by using the `-s` flag.
292-
* The fixture values in [`test/integration/conftest.py`](https://github.com/uberfastman/yfpy/blob/main/test/integration/conftest.py) are defined in [`quickstart/quickstart.py`](https://github.com/uberfastman/yfpy/blob/main/quickstart/quickstart.py), and can be changed for testing by uncommenting/commenting out the values inside each respective function.
306+
* The fixture values in [`test/integration/conftest.py`](https://github.com/uberfastman/yfpy/blob/main/test/integration/conftest.py) are defined in [`scripts/quickstart.py`](https://github.com/uberfastman/yfpy/blob/main/scripts/quickstart.py), and can be changed for testing by uncommenting/commenting out the values inside each respective function.
293307
294308
<a name="run-tests"></a>
295309
#### Run Tests
@@ -314,12 +328,12 @@ YFPY has only been tested extensively on macOS, but is written to be platform-ag
314328
<a name="python"></a>
315329
#### Python
316330
317-
YFPY requires Python 3.10 or later, and has been tested through Python 3.12.
331+
YFPY requires Python 3.10 or later, and has been tested through Python 3.13.
318332
319333
<a name="development"></a>
320334
#### Development
321335
322-
Direct project dependencies can be viewed in `requirements.txt`, and additional development and build dependencies (*not* including transitive dependencies) can be viewed in `requirements-dev.txt`.
336+
Run, development, and build dependencies (*not* including transitive dependencies) can be viewed in `pyproject.toml`.
323337
324338
---
325339
@@ -340,3 +354,8 @@ IndexError: list index out of range
340354
```
341355
342356
Typically, when the above error (or a similar error) occurs, it simply means that one of the Yahoo Fantasy Sports API calls failed and so no data was retrieved. This can be fixed by simply re-running data query.
357+
358+
<a name="jetbrains-and-pycharm"></a>
359+
#### JetBrains and PyCharm
360+
361+
If you are using PyCharm for development against this project and want the IDE to be aware of the installed dependencies in your Python interpreter, PyCharm currently has a bug with its `uv` integration that _requires_ the project to have the `uv` Python interpreter exists in a `.venv` directory in the project root. In the event that you have a `uv` Python interpreter configured elsewhere, you can run `ln -sf /path/to/uv/interpreter/directory .venv` in the YFPY project root, and then configure the Python interpreter in PyCharm to point to the Python executable in the `.venv` symbolic link, and all of your installed dependencies will show up and the IDE will be aware that they are installed.

VERSION.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# DO NOT EDIT - VERSIONING CONTROLLED BY GIT TAGS
2-
__version__ = "v16.0.3"
2+
__version__ = "16.0.3"

VERSION_PYTHON.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# minimum supported Python version
2-
__version_minimum_python__ = "3.10"
2+
__version_minimum_python__ = "3.10.0"
33

44
# minimum supported Python version
5-
__version_maximum_python__ = "3.12"
5+
__version_maximum_python__ = "3.13.7"

compose.build.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
services:
22
package:
33
build:
4-
# DO NOT EDIT PYTHON VERSION BUILD ARGUMENTS - VERSIONING CONTROLLED BY GIT TAGS
4+
# DO NOT EDIT PYTHON VERSION BUILD ARGUMENTS - VERSIONING CONTROLLED BY BUILD PROCESS
55
args:
66
- PYTHON_VERSION_MAJOR=3
7-
- PYTHON_VERSION_MINOR=12
8-
- PYTHON_VERSION_PATCH=0
7+
- PYTHON_VERSION_MINOR=13
8+
- PYTHON_VERSION_PATCH=7
99
- BUILD_PLATFORM=linux/amd64
1010
context: .
1111
dockerfile: docker/Dockerfile

0 commit comments

Comments
 (0)