mirror of
https://github.com/fastapi-users/fastapi-users.git
synced 2025-11-01 18:48:14 +08:00
Use hatch for package management
This commit is contained in:
49
.github/workflows/build.yml
vendored
49
.github/workflows/build.yml
vendored
@ -11,33 +11,31 @@ jobs:
|
||||
python_version: [3.7, 3.8, 3.9, '3.10']
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: ${{ matrix.python_version }}
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flit
|
||||
flit install --deps develop --extras oauth,redis
|
||||
- name: Check codestyle
|
||||
pip install hatch
|
||||
hatch env create
|
||||
- name: Lint and typecheck
|
||||
run: |
|
||||
make format-check
|
||||
make lint
|
||||
- name: Typecheck
|
||||
hatch run lint-check
|
||||
- name: Test
|
||||
run: |
|
||||
make typecheck
|
||||
- name: Test with pytest
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
run: |
|
||||
pytest --cov=fastapi_users/
|
||||
codecov
|
||||
hatch run test-cov-xml
|
||||
- uses: codecov/codecov-action@v2
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
fail_ci_if_error: true
|
||||
verbose: true
|
||||
- name: Build and install it on system host
|
||||
run: |
|
||||
flit build --setup-py
|
||||
flit install --deps none --python $(which python)
|
||||
hatch build
|
||||
pip install dist/fastapi_users-*.whl
|
||||
python test_build.py
|
||||
|
||||
release:
|
||||
@ -46,19 +44,20 @@ jobs:
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v1
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flit
|
||||
flit install --deps develop --extras oauth,redis
|
||||
- name: Release on PyPI
|
||||
pip install hatch
|
||||
- name: Build and publish on PyPI
|
||||
env:
|
||||
FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }}
|
||||
FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }}
|
||||
HATCH_INDEX_USER: ${{ secrets.HATCH_INDEX_USER }}
|
||||
HATCH_INDEX_AUTH: ${{ secrets.HATCH_INDEX_AUTH }}
|
||||
run: |
|
||||
flit publish --setup-py
|
||||
hatch build
|
||||
hatch publish
|
||||
|
||||
8
.github/workflows/documentation.yml
vendored
8
.github/workflows/documentation.yml
vendored
@ -14,16 +14,16 @@ jobs:
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up Python 3.7
|
||||
uses: actions/setup-python@v3
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: 3.7
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install flit
|
||||
flit install --deps develop --extras oauth,redis
|
||||
pip install hatch
|
||||
- name: Build
|
||||
run: mkdocs build
|
||||
run: hatch run mkdocs build
|
||||
- name: Parse tag
|
||||
id: version_tag
|
||||
uses: battila7/get-version-action@v2
|
||||
|
||||
52
Makefile
52
Makefile
@ -1,52 +0,0 @@
|
||||
install:
|
||||
python -m pip install --upgrade pip
|
||||
pip install flit
|
||||
flit install --deps develop --extras oauth,redis
|
||||
|
||||
isort-src:
|
||||
isort ./fastapi_users ./tests
|
||||
|
||||
isort-docs:
|
||||
isort ./docs/src -o fastapi_users
|
||||
|
||||
isort-examples:
|
||||
isort ./examples -o fastapi_users -p app
|
||||
|
||||
format: isort-src isort-docs isort-examples
|
||||
black .
|
||||
|
||||
isort-src-check:
|
||||
isort --check-only ./fastapi_users ./tests
|
||||
|
||||
isort-docs-check:
|
||||
isort --check-only ./docs/src -o fastapi_users
|
||||
|
||||
isort-examples-check:
|
||||
isort --check-only ./examples -o fastapi_users -p app
|
||||
|
||||
format-check: isort-src-check isort-docs-check isort-examples-check
|
||||
black --check .
|
||||
|
||||
lint:
|
||||
flake8 ./fastapi_users ./tests
|
||||
|
||||
typecheck:
|
||||
mypy fastapi_users/
|
||||
|
||||
test:
|
||||
pytest --cov=fastapi_users/ --cov-report=term-missing --cov-fail-under=100
|
||||
|
||||
docs-serve:
|
||||
mkdocs serve
|
||||
|
||||
docs-publish:
|
||||
mkdocs gh-deploy
|
||||
|
||||
bumpversion-major:
|
||||
bumpversion major
|
||||
|
||||
bumpversion-minor:
|
||||
bumpversion minor
|
||||
|
||||
bumpversion-patch:
|
||||
bumpversion patch
|
||||
42
README.md
42
README.md
@ -178,40 +178,14 @@ This project follows the [all-contributors](https://github.com/all-contributors/
|
||||
|
||||
### Setup environment
|
||||
|
||||
You should create a virtual environment and activate it:
|
||||
|
||||
```bash
|
||||
python -m venv venv/
|
||||
```
|
||||
|
||||
```bash
|
||||
source venv/bin/activate
|
||||
```
|
||||
|
||||
And then install the development dependencies:
|
||||
|
||||
```bash
|
||||
make install
|
||||
```
|
||||
We use [Hatch](https://hatch.pypa.io/latest/install/) to manage the development environment and production build. Ensure it's installed on your system.
|
||||
|
||||
### Run unit tests
|
||||
|
||||
You can run all the tests with:
|
||||
|
||||
```bash
|
||||
make test
|
||||
```
|
||||
|
||||
Alternatively, you can run `pytest` yourself.
|
||||
|
||||
```bash
|
||||
pytest
|
||||
```
|
||||
|
||||
There are quite a few unit tests, so you might run into ulimit issues where there are too many open file descriptors. You may be able to set a new, higher limit temporarily with:
|
||||
|
||||
```bash
|
||||
ulimit -n 2048
|
||||
hatch run test
|
||||
```
|
||||
|
||||
### Format the code
|
||||
@ -219,9 +193,19 @@ ulimit -n 2048
|
||||
Execute the following command to apply `isort` and `black` formatting:
|
||||
|
||||
```bash
|
||||
make format
|
||||
hatch run lint
|
||||
```
|
||||
|
||||
### Serve the documentation
|
||||
|
||||
You can serve the documentation locally with the following command:
|
||||
|
||||
```bash
|
||||
hatch run docs
|
||||
```
|
||||
|
||||
The documentation will be available on [http://localhost:8000](http://localhost:8000).
|
||||
|
||||
## License
|
||||
|
||||
This project is licensed under the terms of the MIT license.
|
||||
|
||||
101
pyproject.toml
101
pyproject.toml
@ -31,12 +31,75 @@ markers = [
|
||||
"router",
|
||||
]
|
||||
|
||||
[build-system]
|
||||
requires = ["flit_core >=3.2,<4"]
|
||||
build-backend = "flit_core.buildapi"
|
||||
[tool.hatch]
|
||||
|
||||
[tool.flit.module]
|
||||
name = "fastapi_users"
|
||||
[tool.hatch.metadata]
|
||||
allow-direct-references = true
|
||||
|
||||
[tool.hatch.version]
|
||||
source = "regex_commit"
|
||||
commit_extra_args = ["-e"]
|
||||
path = "fastapi_users/__init__.py"
|
||||
|
||||
[tool.hatch.envs.default]
|
||||
features = [
|
||||
"sqlalchemy",
|
||||
"beanie",
|
||||
"oauth",
|
||||
"redis",
|
||||
]
|
||||
dependencies = [
|
||||
"flake8",
|
||||
"pytest",
|
||||
"requests",
|
||||
"isort",
|
||||
"pytest-asyncio",
|
||||
"flake8-docstrings",
|
||||
"mike",
|
||||
"mkdocs",
|
||||
"mkdocs-material",
|
||||
"mkdocs-mermaid2-plugin",
|
||||
"black",
|
||||
"mypy",
|
||||
"pytest-cov",
|
||||
"pytest-mock",
|
||||
"flit",
|
||||
"markdown-include",
|
||||
"pygments",
|
||||
"pymdown-extensions",
|
||||
"bumpversion",
|
||||
"httpx-oauth",
|
||||
"httpx",
|
||||
"asgi_lifespan",
|
||||
"uvicorn",
|
||||
"types-redis",
|
||||
]
|
||||
|
||||
[tool.hatch.envs.default.scripts]
|
||||
test = "pytest --cov=fastapi_users/ --cov-report=term-missing --cov-fail-under=100"
|
||||
test-cov-xml = "pytest --cov=fastapi_users/ --cov-report=xml --cov-fail-under=100"
|
||||
lint = [
|
||||
"isort ./fastapi_users ./tests",
|
||||
"isort ./docs/src -o fastapi_users",
|
||||
"isort ./examples -o fastapi_users -p app",
|
||||
"black . ",
|
||||
"mypy fastapi_users/",
|
||||
]
|
||||
lint-check = [
|
||||
"isort --check-only ./fastapi_users ./tests",
|
||||
"isort --check-only ./docs/src -o fastapi_users",
|
||||
"isort --check-only ./examples -o fastapi_users -p app",
|
||||
"black --check .",
|
||||
"mypy fief_client/",
|
||||
]
|
||||
docs = "mkdocs serve"
|
||||
|
||||
[tool.hatch.build.targets.sdist]
|
||||
support-legacy = true # Create setup.py
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling", "hatch-regex-commit"]
|
||||
build-backend = "hatchling.build"
|
||||
|
||||
[project]
|
||||
name = "fastapi-users"
|
||||
@ -71,33 +134,6 @@ dependencies = [
|
||||
]
|
||||
|
||||
[project.optional-dependencies]
|
||||
dev = [
|
||||
"flake8",
|
||||
"pytest",
|
||||
"requests",
|
||||
"isort",
|
||||
"pytest-asyncio",
|
||||
"flake8-docstrings",
|
||||
"mike",
|
||||
"mkdocs",
|
||||
"mkdocs-material",
|
||||
"mkdocs-mermaid2-plugin",
|
||||
"black",
|
||||
"mypy",
|
||||
"codecov",
|
||||
"pytest-cov",
|
||||
"pytest-mock",
|
||||
"flit",
|
||||
"markdown-include",
|
||||
"pygments",
|
||||
"pymdown-extensions",
|
||||
"bumpversion",
|
||||
"httpx-oauth",
|
||||
"httpx",
|
||||
"asgi_lifespan",
|
||||
"uvicorn",
|
||||
"types-redis",
|
||||
]
|
||||
sqlalchemy = [
|
||||
"fastapi-users-db-sqlalchemy >=4.0.0",
|
||||
]
|
||||
@ -113,3 +149,4 @@ redis = [
|
||||
|
||||
[project.urls]
|
||||
Documentation = "https://fastapi-users.github.io/fastapi-users/"
|
||||
Source = "https://github.com/fastapi-users/fastapi-users"
|
||||
|
||||
Reference in New Issue
Block a user