From 73e00ef12bb50bb886fe8a135b7a54085efd131a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= Date: Sat, 19 Feb 2022 17:19:59 +0000 Subject: [PATCH] Out of box suppor for nuitka (#68) Co-authored-by: Clouder --- .pre-commit-config.yaml | 14 +++++++------- CHANGES.rst | 4 ++++ src/platformdirs/__init__.py | 14 +++++++------- tox.ini | 4 +--- whitelist.txt | 1 + 5 files changed, 20 insertions(+), 17 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 83caccc..a067f34 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: end-of-file-fixer - id: trailing-whitespace - repo: https://github.com/asottile/pyupgrade - rev: v2.29.1 + rev: v2.31.0 hooks: - id: pyupgrade args: [ "--py36-plus" ] @@ -21,21 +21,21 @@ repos: hooks: - id: isort - repo: https://github.com/psf/black - rev: 21.12b0 + rev: 22.1.0 hooks: - id: black args: [ --safe ] - repo: https://github.com/asottile/blacken-docs - rev: v1.12.0 + rev: v1.12.1 hooks: - id: blacken-docs - additional_dependencies: [ black==21.12b0 ] + additional_dependencies: [ black==22.1.0 ] - repo: https://github.com/pre-commit/pygrep-hooks rev: v1.9.0 hooks: - id: rst-backticks - repo: https://github.com/tox-dev/tox-ini-fmt - rev: "0.5.1" + rev: "0.5.2" hooks: - id: tox-ini-fmt args: [ "-p", "fix" ] @@ -49,8 +49,8 @@ repos: hooks: - id: flake8 additional_dependencies: - - flake8-bugbear==21.11.29 - - flake8-comprehensions==3.7 + - flake8-bugbear==22.1.11 + - flake8-comprehensions==3.8 - flake8-pytest-style==1.6 - flake8-spellcheck==0.24 - flake8-unused-arguments==0.0.9 diff --git a/CHANGES.rst b/CHANGES.rst index d50cbb9..b33d57c 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,10 @@ platformdirs Changelog ====================== +platformdirs 2.5.1 +------------------ +- Add native support for nuitka + platformdirs 2.5.0 ------------------ - Add support for Termux subsystems diff --git a/src/platformdirs/__init__.py b/src/platformdirs/__init__.py index d66256d..eb7d032 100644 --- a/src/platformdirs/__init__.py +++ b/src/platformdirs/__init__.py @@ -4,7 +4,6 @@ """ from __future__ import annotations -import importlib import os import sys from pathlib import Path @@ -19,20 +18,21 @@ def _set_platform_dir_class() -> type[PlatformDirsABC]: if sys.platform == "win32": - module, name = "platformdirs.windows", "Windows" + from platformdirs.windows import Windows as Result elif sys.platform == "darwin": - module, name = "platformdirs.macos", "MacOS" + from platformdirs.macos import MacOS as Result else: - module, name = "platformdirs.unix", "Unix" + from platformdirs.unix import Unix as Result if os.getenv("ANDROID_DATA") == "/data" and os.getenv("ANDROID_ROOT") == "/system": from platformdirs.android import _android_folder if _android_folder() is not None: - module, name = "platformdirs.android", "Android" + from platformdirs.android import Android - result: type[PlatformDirsABC] = getattr(importlib.import_module(module), name) - return result + return Android # return to avoid redefinition of result + + return Result PlatformDirs = _set_platform_dir_class() #: Currently active platform diff --git a/tox.ini b/tox.ini index e1b4e46..2cb1cf5 100644 --- a/tox.ini +++ b/tox.ini @@ -39,7 +39,6 @@ description = run static analysis and style check using flake8 passenv = HOMEPATH PROGRAMDATA -basepython = python3.9 skip_install = true deps = pre-commit>=2 @@ -51,7 +50,7 @@ description = run type check on code base setenv = {tty:MYPY_FORCE_COLOR = 1} deps = - mypy==0.930 + mypy==0.931 commands = mypy --strict src mypy --strict tests @@ -97,7 +96,6 @@ commands = [testenv:dev] description = generate a DEV environment -basepython = python3.9 usedevelop = true extras = test diff --git a/whitelist.txt b/whitelist.txt index 1dd1935..f879983 100644 --- a/whitelist.txt +++ b/whitelist.txt @@ -19,6 +19,7 @@ isfunction jnius kernel32 lru +macos multipath normpath ord