Skip to content

Commit

Permalink
Fix build environment and make adjustments for Python 3.13 (#215)
Browse files Browse the repository at this point in the history
* Fix build environment and make adjustments for Python 3.13

* Fix up build env
  • Loading branch information
facelessuser committed May 4, 2024
1 parent 6d105d1 commit 09675ed
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 26 deletions.
24 changes: 11 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
max-parallel: 4
matrix:
platform: [ubuntu-latest, windows-latest]
python-version: [3.8, 3.9, '3.10', '3.11', '3.12-dev']
python-version: [3.8, 3.9, '3.10', '3.11', '3.12', '3.13']
include:
- python-version: 3.8
tox-env: py38
Expand All @@ -27,29 +27,26 @@ jobs:
tox-env: py310
- python-version: '3.11'
tox-env: py310
- python-version: '3.12-dev'
- python-version: '3.12'
tox-env: py312
- python-version: '3.13'
tox-env: py313
exclude:
- platform: windows-latest
python-version: '3.12-dev'
python-version: '3.13'

env:
TOXENV: ${{ matrix.tox-env }}

runs-on: ${{ matrix.platform }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
if: "!endsWith(matrix.python-version, '-dev')"
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Set up development Python ${{ matrix.python-version }}
if: endsWith(matrix.python-version, '-dev')
uses: deadsnakes/action@v2.1.1
with:
python-version: ${{ matrix.python-version }}
allow-prereleases: true
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools tox coverage
Expand All @@ -58,11 +55,12 @@ jobs:
python -m tox
- name: Upload Results
if: success()
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
file: ./coverage.xml
flags: unittests
name: ${{ matrix.platform }}-${{ matrix.tox-env }}
token: ${{ secrets.CODECOV_TOKEN }} # required
fail_ci_if_error: false

lint:
Expand All @@ -77,7 +75,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand All @@ -101,7 +99,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -40,7 +40,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: 3.11
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ show_error_codes = true
[tool.ruff]
line-length = 120

select = [
lint.select = [
"A", # flake8-builtins
"B", # flake8-bugbear
"D", # pydocstyle
Expand All @@ -87,7 +87,7 @@ select = [
"PERF" # Perflint
]

ignore = [
lint.ignore = [
"E741",
"D202",
"D401",
Expand Down
28 changes: 19 additions & 9 deletions wcmatch/pathlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _translate_path(self) -> str:
sep = ''
name = str(self)
if isinstance(self, Path) and name and self.is_dir():
sep = self._flavour.sep
sep = self.parser.sep if util.PY313 else self._flavour.sep

return name + sep

Expand Down Expand Up @@ -227,18 +227,28 @@ def rglob( # type: ignore[override]
yield from self.glob(patterns, flags=flags | _EXTMATCHBASE, limit=limit, exclude=exclude)


class PurePosixPath(PurePath):
"""Pure Posix path."""
if util.PY313:
class PurePosixPath(pathlib.PurePosixPath, PurePath):
"""Pure Posix path."""

_flavour = pathlib._posix_flavour if not util.PY312 else posixpath # type: ignore[attr-defined]
__slots__ = ()
__slots__ = ()

class PureWindowsPath(pathlib.PureWindowsPath, PurePath):
"""Pure Windows path."""

class PureWindowsPath(PurePath):
"""Pure Windows path."""
__slots__ = ()
else:
class PurePosixPath(PurePath): # type: ignore[no-redef]
"""Pure Posix path."""

_flavour = pathlib._windows_flavour if not util.PY312 else ntpath # type: ignore[attr-defined]
__slots__ = ()
_flavour = pathlib._posix_flavour if not util.PY312 else posixpath # type: ignore[attr-defined]
__slots__ = ()

class PureWindowsPath(PurePath): # type: ignore[no-redef]
"""Pure Windows path."""

_flavour = pathlib._windows_flavour if not util.PY312 else ntpath # type: ignore[attr-defined]
__slots__ = ()


class PosixPath(Path, PurePosixPath):
Expand Down
1 change: 1 addition & 0 deletions wcmatch/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

PY310 = (3, 10) <= sys.version_info
PY312 = (3, 12) <= sys.version_info
PY313 = (3, 13) <= sys.version_info

UNICODE = 0
BYTES = 1
Expand Down

0 comments on commit 09675ed

Please sign in to comment.