Skip to content

Commit ade65a1

Browse files
authored
Major Packaging Refactor: migrate to uv (#377)
Based upon the https://github.com/fpgmaas/cookiecutter-uv repository with some modifications. This should simplify python version management.
1 parent eb44bff commit ade65a1

36 files changed

+2082
-978
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: "Setup Python Environment"
2+
description: "Set up Python environment for the given Python version"
3+
4+
inputs:
5+
python-version:
6+
description: "Python version to use"
7+
required: true
8+
default: "3.12"
9+
uv-version:
10+
description: "uv version to use"
11+
required: true
12+
default: "0.6.2"
13+
14+
runs:
15+
using: "composite"
16+
steps:
17+
- name: Install uv
18+
uses: astral-sh/setup-uv@v5
19+
with:
20+
version: ${{ inputs.uv-version }}
21+
enable-cache: true
22+
python-version: ${{ inputs.python-version }}
23+
- name: Install Python dependencies
24+
run: uv sync --frozen
25+
shell: bash

.github/workflows/main.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Main
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
types: [opened, synchronize, reopened, ready_for_review]
9+
10+
jobs:
11+
quality:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Check out
15+
uses: actions/checkout@v4
16+
17+
- uses: actions/cache@v4
18+
with:
19+
path: ~/.cache/pre-commit
20+
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
21+
22+
- name: Set up the environment
23+
uses: ./.github/actions/setup-python-env
24+
25+
- name: Run checks
26+
run: make check
27+
28+
tests-and-type-check:
29+
runs-on: ubuntu-latest
30+
strategy:
31+
matrix:
32+
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
33+
fail-fast: false
34+
defaults:
35+
run:
36+
shell: bash
37+
steps:
38+
- name: Check out
39+
uses: actions/checkout@v4
40+
41+
- name: Set up the environment
42+
uses: ./.github/actions/setup-python-env
43+
with:
44+
python-version: ${{ matrix.python-version }}
45+
46+
- name: Run tests
47+
run: uv run python -m pytest tests --cov --cov-config=pyproject.toml --cov-report=xml
48+
49+
# - name: Check typing
50+
# run: uv run mypy .
51+
52+
- name: Upload coverage reports to Codecov with GitHub Action on Python 3.11
53+
uses: codecov/codecov-action@v4
54+
if: ${{ matrix.python-version == '3.11' }}
55+
56+
check-docs:
57+
runs-on: ubuntu-latest
58+
steps:
59+
- name: Check out
60+
uses: actions/checkout@v4
61+
62+
- name: Set up the environment
63+
uses: ./.github/actions/setup-python-env
64+
65+
- name: Check if documentation can be built
66+
run: uv run mkdocs build
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: release-main
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
set-version:
9+
runs-on: ubuntu-24.04
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Export tag
14+
id: vars
15+
run: echo tag=${GITHUB_REF#refs/*/} >> $GITHUB_OUTPUT
16+
if: ${{ github.event_name == 'release' }}
17+
18+
- name: Update project version
19+
run: |
20+
sed -i "s/^version = \".*\"/version = \"$RELEASE_VERSION\"/" pyproject.toml
21+
sed -i "s/__version__ .*/__version__ = \"$RELEASE_VERSION\"/" flask_cors/version.py
22+
23+
env:
24+
RELEASE_VERSION: ${{ steps.vars.outputs.tag }}
25+
if: ${{ github.event_name == 'release' }}
26+
27+
- name: Upload updated pyproject.toml
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: pyproject-toml
31+
path: pyproject.toml
32+
33+
publish:
34+
runs-on: ubuntu-latest
35+
needs: [set-version]
36+
steps:
37+
- name: Check out
38+
uses: actions/checkout@v4
39+
40+
- name: Set up the environment
41+
uses: ./.github/actions/setup-python-env
42+
43+
- name: Download updated pyproject.toml
44+
uses: actions/download-artifact@v4
45+
with:
46+
name: pyproject-toml
47+
48+
- name: Build package
49+
run: uv build
50+
51+
- name: Publish package
52+
run: uv publish
53+
54+
deploy-docs:
55+
needs: publish
56+
runs-on: ubuntu-latest
57+
steps:
58+
- name: Check out
59+
uses: actions/checkout@v4
60+
61+
- name: Set up the environment
62+
uses: ./.github/actions/setup-python-env
63+
64+
- name: Deploy documentation
65+
run: uv run mkdocs gh-deploy --force

.github/workflows/release.yml

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

.github/workflows/unittests.yaml

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: validate-codecov-config
2+
3+
on:
4+
pull_request:
5+
paths: [codecov.yaml]
6+
push:
7+
branches: [main]
8+
9+
jobs:
10+
validate-codecov-config:
11+
runs-on: ubuntu-22.04
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Validate codecov configuration
15+
run: curl -sSL --fail-with-body --data-binary @codecov.yaml https://codecov.io/validate

.pre-commit-config.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: "v4.4.0"
4+
hooks:
5+
- id: check-case-conflict
6+
- id: check-merge-conflict
7+
- id: check-toml
8+
- id: check-yaml
9+
- id: end-of-file-fixer
10+
- id: trailing-whitespace
11+
12+
- repo: https://github.com/astral-sh/ruff-pre-commit
13+
rev: "v0.6.3"
14+
hooks:
15+
- id: ruff
16+
args: [--exit-non-zero-on-fix]
17+
- id: ruff-format
18+
19+
- repo: https://github.com/pre-commit/mirrors-prettier
20+
rev: "v3.0.3"
21+
hooks:
22+
- id: prettier

CONTRIBUTING.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Contributing to `flask-cors`
2+
3+
Contributions are welcome, and they are greatly appreciated!
4+
Every little bit helps, and credit will always be given.
5+
6+
You can contribute in many ways:
7+
8+
# Types of Contributions
9+
10+
## Report Bugs
11+
12+
Report bugs at https://github.com/corydolphin/flask-cors/issues
13+
14+
If you are reporting a bug, please include:
15+
16+
- Your operating system name and version.
17+
- Any details about your local setup that might be helpful in troubleshooting.
18+
- Detailed steps to reproduce the bug.
19+
20+
## Fix Bugs
21+
22+
Look through the GitHub issues for bugs.
23+
Anything tagged with "bug" and "help wanted" is open to whoever wants to implement a fix for it.
24+
25+
## Implement Features
26+
27+
Look through the GitHub issues for features.
28+
Anything tagged with "enhancement" and "help wanted" is open to whoever wants to implement it.
29+
30+
## Write Documentation
31+
32+
flask-cors could always use more documentation, whether as part of the official docs, in docstrings, or even on the web in blog posts, articles, and such.
33+
34+
## Submit Feedback
35+
36+
The best way to send feedback is to file an issue at https://github.com/corydolphin/flask-cors/issues.
37+
38+
If you are proposing a new feature:
39+
40+
- Explain in detail how it would work.
41+
- Keep the scope as narrow as possible, to make it easier to implement.
42+
- Remember that this is a volunteer-driven project, and that contributions
43+
are welcome :)
44+
45+
# Get Started!
46+
47+
Ready to contribute? Here's how to set up `flask-cors` for local development.
48+
Please note this documentation assumes you already have `uv` and `Git` installed and ready to go.
49+
50+
1. Fork the `flask-cors` repo on GitHub.
51+
52+
2. Clone your fork locally:
53+
54+
```bash
55+
cd <directory_in_which_repo_should_be_created>
56+
git clone [email protected]:YOUR_NAME/flask-cors.git
57+
```
58+
59+
3. Now we need to install the environment. Navigate into the directory
60+
61+
```bash
62+
cd flask-cors
63+
```
64+
65+
Then, install and activate the environment with:
66+
67+
```bash
68+
uv sync
69+
```
70+
71+
4. Install pre-commit to run linters/formatters at commit time:
72+
73+
```bash
74+
uv run pre-commit install
75+
```
76+
77+
5. Create a branch for local development:
78+
79+
```bash
80+
git checkout -b name-of-your-bugfix-or-feature
81+
```
82+
83+
Now you can make your changes locally.
84+
85+
6. Don't forget to add test cases for your added functionality to the `tests` directory.
86+
87+
7. When you're done making changes, check that your changes pass the formatting tests.
88+
89+
```bash
90+
make check
91+
```
92+
93+
Now, validate that all unit tests are passing:
94+
95+
```bash
96+
make test
97+
```
98+
99+
9. Before raising a pull request you should also run tox.
100+
This will run the tests across different versions of Python:
101+
102+
```bash
103+
tox
104+
```
105+
106+
This requires you to have multiple versions of python installed.
107+
This step is also triggered in the CI/CD pipeline, so you could also choose to skip this step locally.
108+
109+
10. Commit your changes and push your branch to GitHub:
110+
111+
```bash
112+
git add .
113+
git commit -m "Your detailed description of your changes."
114+
git push origin name-of-your-bugfix-or-feature
115+
```
116+
117+
11. Submit a pull request through the GitHub website.
118+
119+
# Pull Request Guidelines
120+
121+
Before you submit a pull request, check that it meets these guidelines:
122+
123+
1. The pull request should include tests.
124+
125+
2. If the pull request adds functionality, the docs should be updated.
126+
Put your new functionality into a function with a docstring, and add the feature to the list in `README.md`.

LICENSE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
Copyright (C) 2016 Cory Dolphin, Olin College
1+
Copyright (C) 2025 Cory Dolphin
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
44

55
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
66

7-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

0 commit comments

Comments
 (0)