Skip to content

Commit

Permalink
Merge branch 'master' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
gi0baro committed Oct 13, 2024
2 parents 5d38c24 + 8ec0ced commit 97d541c
Show file tree
Hide file tree
Showing 141 changed files with 7,180 additions and 15,113 deletions.
1 change: 1 addition & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
github: [gi0baro]
polar: emmett-framework
7 changes: 7 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: 2
updates:
- package-ecosystem: "github-actions"
target-branch: "master"
directory: "/"
schedule:
interval: "monthly"
30 changes: 30 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: lint

on:
pull_request:
types: [opened, synchronize]
branches:
- master

env:
PYTHON_VERSION: 3.12

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
uv sync --dev
- name: Lint
run: |
source .venv/bin/activate
make lint
28 changes: 16 additions & 12 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,24 @@ on:
jobs:
publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/emmett
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.9
- name: Install and configure Poetry
uses: gi0baro/setup-poetry-bin@v1
with:
virtualenvs-in-project: true
- name: Publish
python-version: 3.12
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Build distributions
run: |
poetry build
poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
uv build
- name: Publish package to pypi
uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true
56 changes: 27 additions & 29 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,20 @@ name: Tests
on:
push:
branches:
- "**"
tags-ignore:
- "**"
- master
- release
pull_request:
types: [opened, synchronize]
branches:
- master

jobs:
Linux:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']

services:
postgres:
Expand All @@ -25,68 +28,63 @@ jobs:
- 5432:5432

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: gi0baro/setup-poetry-bin@v1
with:
virtualenvs-in-project: true
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
poetry install -v
uv sync --dev
- name: Test
env:
POSTGRES_URI: postgres:postgres@localhost:5432/test
run: |
poetry run pytest -v tests
uv run pytest -v tests
MacOS:
runs-on: macos-13
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: gi0baro/setup-poetry-bin@v1
with:
virtualenvs-in-project: true
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies
run: |
poetry install -v
uv sync --dev
- name: Test
run: |
poetry run pytest -v tests
uv run pytest -v tests
Windows:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
python-version: [3.8, 3.9, '3.10', '3.11', '3.12']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install and configure Poetry
uses: gi0baro/setup-poetry-bin@v1
with:
virtualenvs-in-project: true
- name: Install uv
uses: astral-sh/setup-uv@v3
- name: Install dependencies
shell: bash
run: |
poetry install -v
uv sync --dev
- name: Test
shell: bash
run: |
poetry run pytest -v tests
uv run pytest -v tests
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ build/*
dist/*
Emmett.egg-info/*
poetry.lock
uv.lock

examples/*/databases
examples/*/logs
Expand Down
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Emmett changelog
================

Version 2.6
-----------

Released on October 14th 2024, codename Gutenberg

- Added Python 3.13 support
- Re-implemented router matching algorithm in Rust
- Re-implemented multipart parsing in Rust
- Added `Response` wrap methods
- Refactored `Request.files` implementation
- Support iteration on `Request.body`
- Added `iter`, `aiter`, `http` and `snippet` to routes' outputs
- Testing client is now using RSGI protocol in place of ASGI
- Logger now uses stdout in place of files under default configuration

Version 2.5
-----------

Expand Down
18 changes: 0 additions & 18 deletions LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,3 @@ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


Some parts in Emmett's components are derived from web2py framework,
and contains the original copyright credits:
Copyrighted (c) by Massimo Di Pierro (2007-2013)

Due to the original license limitations, some of these components are
distributed under LGPLv3 license, in particular:

* emmett/security.py
* emmett/validators

For futher details, check out the web2py's license:
https://github.com/web2py/web2py/blob/master/LICENSE


Emmett also contains third party software in the 'libs' directory: each
file/module in this directory is distributed under its original license.
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.DEFAULT_GOAL := all
pysources = emmett tests

.PHONY: format
format:
ruff check --fix $(pysources)
ruff format $(pysources)

.PHONY: lint
lint:
ruff check $(pysources)
ruff format --check $(pysources)

.PHONY: test
test:
pytest -v tests

.PHONY: all
all: format lint test
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,9 @@ async def todo():
return {'tasks': tasks}
```

[![pip version](https://img.shields.io/pypi/v/emmett.svg?style=flat)](https://pypi.python.org/pypi/emmett)
![Tests Status](https://github.com/emmett-framework/emmett/workflows/Tests/badge.svg)

## Documentation

The documentation is available at [https://emmett.sh/docs](https://emmett.sh/docs).
The documentation is available at [https://emmett.sh/docs](https://emmett.sh/docs).
The sources are available under the [docs folder](https://github.com/emmett-framework/emmett/tree/master/docs).

## Examples
Expand Down Expand Up @@ -76,6 +73,4 @@ We would be very glad if you contributed to the project in one or all of these w

Emmett is released under the BSD License.

However, due to original license limitations, some components are included
in Emmett under their original licenses. Please check the LICENSE file for
more details.
However, due to original license limitations, contents under [validators](https://github.com/emmett-framework/emmett/tree/master/emmett/validators) and [libs](https://github.com/emmett-framework/emmett/tree/master/emmett/libs) are included in Emmett under their original licenses. Please check the source code for more details.
7 changes: 4 additions & 3 deletions docs/forms.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ Here is the complete list of parameters accepted by `Form` class:
> **Note:** the `fields` and `exclude_fields` parameters should not be used together. If you need to hide just a few fields, you'd better using the `exclude_fields`, and you should use `fields` if you have to show only few table fields. The advantages of these parameters are lost if you use both.
### Uploads with forms

As we saw above, the `upload` parameter of forms needs an URL for download. Let's focus a bit on uploads and see an example to completely understand this requirement.

Let's say you want to handle the upload of avatar images from your user. So, in your model you would have an upload field:
Expand All @@ -99,14 +100,14 @@ Let's say you want to handle the upload of avatar images from your user. So, in
avatar = Field.upload()
```

and the forms produced by Emmett will handle uploads for you. How would you display this image in your template? You need a streaming function like this:
and the forms produced by Emmett will handle uploads for you. How would you display this image in your template? You need a route which will send back the uploaded files' contents:

```python
from emmett.helpers import stream_dbfile
from emmett import response

@app.route("/download/<str:filename>")
async def download(filename):
stream_dbfile(db, filename)
return response.wrap_dbfile(db, filename)
```

and then, in your template, you can create an `img` tag pointing to the `download` function you've just exposed:
Expand Down
Loading

0 comments on commit 97d541c

Please sign in to comment.