Skip to content

Commit

Permalink
Merge branch 'master' into rcfox-symlink-dst
Browse files Browse the repository at this point in the history
  • Loading branch information
pohmelie committed Dec 11, 2024
2 parents 4394925 + 8453684 commit 49afcd2
Show file tree
Hide file tree
Showing 15 changed files with 175 additions and 89 deletions.
70 changes: 70 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: ci/cd
on: [push, pull_request]
env:
lowest_python_version: 3.9
python_package_distributions: python-package-distributions

jobs:

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.lowest_python_version }}
- run: python -m pip install -e ./[dev]
- run: python -m pre_commit run -a

test:
needs: lint
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- run: python -m pip install -e ./[dev]
- run: python -m pytest
- uses: codecov/codecov-action@v4
with:
fail_ci_if_error: true
verbose: true
token: ${{ secrets.CODECOV_TOKEN }}

build:
needs: test
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: ${{ env.lowest_python_version }}
- run: python -m pip install build
- run: python -m build
- uses: actions/upload-artifact@v4
with:
name: ${{ env.python_package_distributions }}
path: dist/*
if-no-files-found: error
retention-days: 14

publish:
needs: build
runs-on: ubuntu-latest
if: github.ref_type == 'tag'
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
environment:
name: pypi
url: https://pypi.org/project/aioftp
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ env.python_package_distributions }}
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
46 changes: 0 additions & 46 deletions .github/workflows/ci.yaml

This file was deleted.

20 changes: 13 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

.python-linters: &python-linters
pass_filenames: false
fail_fast: true
language: system
types: [python]

Expand All @@ -11,19 +12,24 @@ repos:
rev: v4.5.0
hooks:
- id: check-ast
fail_fast: true
- id: trailing-whitespace
- id: check-toml
fail_fast: true
- id: end-of-file-fixer
fail_fast: true

- repo: https://github.com/asottile/add-trailing-comma
rev: v2.1.0
rev: v3.1.0
hooks:
- id: add-trailing-comma
fail_fast: true

- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: v2.1.0
rev: v2.14.0
hooks:
- id: pretty-format-yaml
fail_fast: true
args:
- --autofix
- --preserve-quotes
Expand All @@ -32,13 +38,13 @@ repos:
- repo: local
hooks:
- <<: *python-linters
id: black
name: Format with Black
entry: black
args: ["."]
id: ruff format
name: Format with ruff
entry: ruff
args: ["format", "."]

- <<: *python-linters
id: ruff
name: Check with ruff
entry: ruff
args: ["check", "--diff", "."]
args: ["check", "--fix", "."]
17 changes: 17 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "3.11"

# Build from the docs/ directory with Sphinx
sphinx:
configuration: docs/conf.py

# Explicitly set the version of Python and its requirements
python:
install:
- requirements: docs/requirements.txt
- method: pip
path: .
10 changes: 6 additions & 4 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ aioftp
.. image:: https://pepy.tech/badge/aioftp/month
:target: https://pypi.python.org/pypi/aioftp

ftp client/server for asyncio (http://aioftp.readthedocs.org)
ftp client/server for asyncio (https://aioftp.rtfd.io)

.. _GitHub: https://github.com/aio-libs/aioftp

Expand Down Expand Up @@ -100,14 +100,16 @@ pyftpdlib 1.5.2
Dependencies
------------

- Python 3.11+

0.21.4 is the last version which supports python 3.7+
- Python 3.8+

0.13.0 is the last version which supports python 3.5.3+

0.16.1 is the last version which supports python 3.6+

0.21.4 is the last version which supports python 3.7+

0.22.3 is the last version which supports python 3.8+

License
-------

Expand Down
8 changes: 5 additions & 3 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,16 @@ pyftpdlib 1.5.2
Dependencies
------------

- Python 3.11+

0.21.4 is the last version which supports python 3.7+
- Python 3.9+

0.13.0 is the last version which supports python 3.5.3+

0.16.1 is the last version which supports python 3.6+

0.21.4 is the last version which supports python 3.7+

0.22.3 is the last version which supports python 3.8+

License
-------

Expand Down
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx==5.3.0
alabaster==0.7.13
docutils==0.17.1
22 changes: 21 additions & 1 deletion history.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
x.x.x (xx-xx-xxxx)

0.22.0 (xx-xx-xxxx)
0.23.1 (14-10-2024)
- update ci

0.23.0 (14-10-2024)
- server: fix pathlib `relative_to` issue (#179)
- minimal python version upgraded to 3.9

0.22.3 (05-01-2024)
- minimal python version downgraded to 3.8

0.22.2 (29-12-2023)
-------------------
- ci: separate build and publish jobs

0.22.1 (29-12-2023)
-------------------
- docs: update/fix readthedocs configuration
- ci: fix workflow file extension from `yaml` to `yml`

0.22.0 (29-12-2023)
-------------------
- client.list: fix infinite symlink loop for `.` and `..` on FTP servers with UNIX-like filesystem for `client.list(path, recursive=True)`
- project file structure: refactor to use `pyproject.toml`
- minimal python version bumped to 3.11
- ci: update publish/deploy job (#171)

0.21.4 (13-10-2022)
-------------------
Expand Down
24 changes: 13 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[project]
name = "aioftp"
version = "0.21.4"
version = "0.23.1"
description = "ftp client/server for asyncio"
readme = "README.rst"
requires-python = ">= 3.11"
requires-python = ">= 3.9"
license = {file = "license.txt"}
authors = [
{name = "pohmelie", email = "[email protected]"},
Expand Down Expand Up @@ -40,7 +40,7 @@ classifiers = [

[project.urls]
Github = "https://github.com/aio-libs/aioftp"
Documentation = "https://aioftp.readthedocs.io"
Documentation = "https://aioftp.rtfd.io"

[project.optional-dependencies]
socks = [
Expand All @@ -57,7 +57,6 @@ dev = [

# linters
"pre-commit",
"black",
"ruff",

# docs
Expand All @@ -74,23 +73,26 @@ build-backend = "setuptools.build_meta"
packages.find.where = ["src"]

# tools
[tool.black]
line-length = 120
target-version = ["py311"]

[tool.ruff]
line-length = 120
target-version = "py311"
select = ["E", "W", "F", "Q", "UP", "I", "ASYNC"]
target-version = "py39"
lint.select = ["E", "W", "F", "Q", "UP", "I", "ASYNC"]
src = ["src"]

[tool.coverage]
run.source = ["./src/aioftp"]
run.omit = ["./src/aioftp/__main__.py"]
report.show_missing = true
report.precision = 2

[tool.pytest.ini_options]
addopts = "-x --durations 10 -p no:anyio --cov"
addopts = [
"-x",
"--durations", "10",
"-p", "no:anyio",
"--cov",
"--import-mode=importlib",
]
testpaths = "tests"
log_format = "%(asctime)s.%(msecs)03d %(name)-20s %(levelname)-8s %(filename)-15s %(lineno)-4d %(message)s"
log_date_format = "%H:%M:%S"
Expand Down
1 change: 1 addition & 0 deletions src/aioftp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""ftp client/server for asyncio"""

# flake8: noqa

import importlib.metadata
Expand Down
1 change: 1 addition & 0 deletions src/aioftp/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Simple aioftp-based server with one user (anonymous or not)"""

import argparse
import asyncio
import contextlib
Expand Down
8 changes: 7 additions & 1 deletion src/aioftp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1209,7 +1209,13 @@ async def abort(self, *, wait=True):
@classmethod
@contextlib.asynccontextmanager
async def context(
cls, host, port=DEFAULT_PORT, user=DEFAULT_USER, password=DEFAULT_PASSWORD, account=DEFAULT_ACCOUNT, **kwargs
cls,
host,
port=DEFAULT_PORT,
user=DEFAULT_USER,
password=DEFAULT_PASSWORD,
account=DEFAULT_ACCOUNT,
**kwargs,
):
"""
Classmethod async context manager. This create
Expand Down
6 changes: 2 additions & 4 deletions src/aioftp/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,11 +1031,9 @@ def get_paths(connection, path):
else:
resolved_virtual_path /= part
base_path = connection.user.base_path
real_path = base_path / resolved_virtual_path.relative_to("/")
real_path = base_path / str(resolved_virtual_path.relative_to("/"))
# replace with `is_relative_to` check after 3.9+ requirements lands
try:
real_path.relative_to(base_path)
except ValueError:
if not real_path.is_relative_to(base_path):
real_path = base_path
resolved_virtual_path = pathlib.PurePosixPath("/")
return real_path, resolved_virtual_path
Expand Down
Loading

0 comments on commit 49afcd2

Please sign in to comment.