Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: drop python 3.6 #400

Merged
merged 1 commit into from
Nov 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.6
python-version: "3.7"
- uses: pre-commit/action@v3.0.0

test-dist:
Expand All @@ -42,7 +42,6 @@ jobs:
fail-fast: false
matrix:
include:
- python: "3.6"
- python: "3.7"
- python: "3.8"
- python: "3.9"
Expand Down
14 changes: 8 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# See https://pre-commit.com/hooks.html for more hooks

default_language_version:
python: python3.6
python: python3.7

exclude: ^src/auditwheel/_vendor/

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
rev: v4.3.0
hooks:
- id: check-builtin-literals
- id: check-added-large-files
Expand All @@ -23,28 +23,30 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/asottile/pyupgrade
rev: v2.30.1
rev: v3.1.0
hooks:
- id: pyupgrade
args: ["--py36-plus"]
args: ["--py37-plus"]

- repo: https://github.com/psf/black
rev: 22.8.0
rev: 22.10.0
hooks:
- id: black

- repo: https://github.com/PyCQA/isort
rev: 5.10.1
hooks:
- id: isort
args: ["-a", "from __future__ import annotations"]
exclude: ^tests/integration/.*/src/.*pyx$

- repo: https://github.com/PyCQA/flake8
rev: 5.0.4
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.931
rev: v0.982
hooks:
- id: mypy
exclude: ^tests/integration/.*/.*$
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ advised that bundling, like static linking, may implicate copyright concerns.
Requirements
------------
- OS: Linux
- Python: 3.6+
- Python: 3.7+
- `patchelf <https://github.com/NixOS/patchelf>`_: 0.14+

Only systems that use `ELF
Expand Down Expand Up @@ -135,7 +135,7 @@ daemon. These tests will pull a number of docker images if they are not already
available on your system, but it won't update existing images.
To update these images manually, run::

docker pull python:3.6-slim
docker pull python:3.7-slim
docker pull quay.io/pypa/manylinux1_x86_64
docker pull quay.io/pypa/manylinux2010_x86_64
docker pull quay.io/pypa/manylinux2014_x86_64
Expand Down
9 changes: 5 additions & 4 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
from __future__ import annotations

import os
import sys
from pathlib import Path
from typing import List

import nox

nox.options.sessions = ["lint", "test-dist"]

PYTHON_ALL_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"]
PYTHON_ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"]
RUNNING_CI = "TRAVIS" in os.environ or "GITHUB_ACTIONS" in os.environ


@nox.session(python=["3.6"], reuse_venv=True)
@nox.session(python=["3.7"], reuse_venv=True)
def lint(session: nox.Session) -> None:
"""
Run linters on the codebase.
Expand All @@ -36,7 +37,7 @@ def coverage(session: nox.Session) -> None:
)


def _docker_images(session: nox.Session) -> List[str]:
def _docker_images(session: nox.Session) -> list[str]:
tmp_dir = Path(session.create_tmp())
script = tmp_dir / "list_images.py"
images_file = tmp_dir / "images.lst"
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ build-backend = "setuptools.build_meta"
# enable version inference

[tool.black]
target-version = ["py36", "py37", "py38", "py39"]
target-version = ["py37", "py38", "py39", "py310"]
extend-exclude = "src/auditwheel/_vendor"

[tool.isort]
Expand Down
2 changes: 2 additions & 0 deletions scripts/calculate_symbol_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
defined version (.gnu.version_d) from libraries in lib_whitelist.
This should be run inside a manylinux Docker container.
"""
from __future__ import annotations

import argparse
import json
import os
Expand Down
3 changes: 1 addition & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ classifier =
License :: OSI Approved :: MIT License
Operating System :: POSIX :: Linux
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Programming Language :: Python :: 3.9
Expand All @@ -32,7 +31,7 @@ install_requires =
packages = find:
package_dir =
=src
python_requires = >=3.6
python_requires = >=3.7
zip_safe = False

[options.package_data]
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

from setuptools import setup

extras = {
Expand Down
2 changes: 2 additions & 0 deletions src/auditwheel/__main__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import sys

from .main import main
Expand Down
7 changes: 4 additions & 3 deletions src/auditwheel/condatools.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Context managers like those in wheeltools.py for unpacking
conda packages.
"""
from __future__ import annotations

import os
from typing import List, Optional

from .tmpdirs import InTemporaryDirectory
from .tools import tarbz2todir
Expand All @@ -22,13 +23,13 @@ def __enter__(self) -> str:
class InCondaPkgCtx(InCondaPkg):
def __init__(self, in_conda_pkg: str) -> None:
super().__init__(in_conda_pkg)
self.path: Optional[str] = None
self.path: str | None = None

def __enter__(self):
self.path = super().__enter__()
return self

def iter_files(self) -> List[str]:
def iter_files(self) -> list[str]:
if self.path is None:
raise ValueError("This function should be called from context manager")
files = os.path.join(self.path, "info", "files")
Expand Down
20 changes: 11 additions & 9 deletions src/auditwheel/elfutils.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
from __future__ import annotations

import os
from os.path import basename, realpath, relpath
from typing import Dict, Iterator, List, Optional, Set, Tuple
from typing import Dict, Iterator, List

from elftools.common.exceptions import ELFError
from elftools.elf.elffile import ELFFile

from .lddtree import parse_ld_paths


def elf_read_dt_needed(fn: str) -> List[str]:
def elf_read_dt_needed(fn: str) -> list[str]:
needed = []
with open(fn, "rb") as f:
elf = ELFFile(f)
Expand All @@ -23,7 +25,7 @@ def elf_read_dt_needed(fn: str) -> List[str]:
return needed


def elf_file_filter(paths: Iterator[str]) -> Iterator[Tuple[str, ELFFile]]:
def elf_file_filter(paths: Iterator[str]) -> Iterator[tuple[str, ELFFile]]:
"""Filter through an iterator of filenames and load up only ELF
files
"""
Expand All @@ -41,7 +43,7 @@ def elf_file_filter(paths: Iterator[str]) -> Iterator[Tuple[str, ELFFile]]:
continue


def elf_find_versioned_symbols(elf: ELFFile) -> Iterator[Tuple[str, str]]:
def elf_find_versioned_symbols(elf: ELFFile) -> Iterator[tuple[str, str]]:
section = elf.get_section_by_name(".gnu.version_r")

if section is not None:
Expand Down Expand Up @@ -84,7 +86,7 @@ def elf_references_PyFPE_jbuf(elf: ELFFile) -> bool:
return False


def elf_is_python_extension(fn: str, elf: ELFFile) -> Tuple[bool, Optional[int]]:
def elf_is_python_extension(fn: str, elf: ELFFile) -> tuple[bool, int | None]:
modname = basename(fn).split(".", 1)[0]
module_init_f = {
"init" + modname: 2,
Expand All @@ -108,7 +110,7 @@ def elf_is_python_extension(fn: str, elf: ELFFile) -> Tuple[bool, Optional[int]]
return False, None


def elf_read_rpaths(fn: str) -> Dict[str, List[str]]:
def elf_read_rpaths(fn: str) -> dict[str, list[str]]:
result = {"rpaths": [], "runpaths": []} # type: Dict[str, List[str]]

with open(fn, "rb") as f:
Expand Down Expand Up @@ -139,7 +141,7 @@ def is_subdir(path: str, directory: str) -> bool:
return True


def get_undefined_symbols(path: str) -> Set[str]:
def get_undefined_symbols(path: str) -> set[str]:
undef_symbols = set()
with open(path, "rb") as f:
elf = ELFFile(f)
Expand All @@ -153,8 +155,8 @@ def get_undefined_symbols(path: str) -> Set[str]:


def filter_undefined_symbols(
path: str, symbols: Dict[str, List[str]]
) -> Dict[str, List[str]]:
path: str, symbols: dict[str, list[str]]
) -> dict[str, list[str]]:
if not symbols:
return {}
undef_symbols = set("*") | get_undefined_symbols(path)
Expand Down
3 changes: 3 additions & 0 deletions src/auditwheel/error.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import annotations


class AuditwheelException(Exception):
pass

Expand Down
6 changes: 3 additions & 3 deletions src/auditwheel/genericpkgctx.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from typing import Optional, Union
from __future__ import annotations

from .condatools import InCondaPkgCtx
from .wheeltools import InWheelCtx


def InGenericPkgCtx(
in_path: str, out_path: Optional[str] = None
) -> Union[InWheelCtx, InCondaPkgCtx]:
in_path: str, out_path: str | None = None
) -> InWheelCtx | InCondaPkgCtx:
"""Factory that returns a InWheelCtx or InCondaPkgCtx
context manager depending on the file extension
"""
Expand Down
2 changes: 2 additions & 0 deletions src/auditwheel/hashfile.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import hashlib
from typing import BinaryIO

Expand Down
24 changes: 13 additions & 11 deletions src/auditwheel/lddtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
a flat list.
"""

from __future__ import annotations

import errno
import functools
import glob
import logging
import os
from pathlib import Path
from typing import Any, Dict, List, Optional, Tuple
from typing import Any, Dict, List, Optional

from elftools.elf.elffile import ELFFile

Expand Down Expand Up @@ -72,13 +74,13 @@ def readlink(path: str, root: str, prefixed: bool = False) -> str:
return normpath((root + path) if prefixed else path)


def dedupe(items: List[str]) -> List[str]:
def dedupe(items: list[str]) -> list[str]:
"""Remove all duplicates from ``items`` (keeping order)"""
seen = {} # type: Dict[str, str]
return [seen.setdefault(x, x) for x in items if x not in seen]


def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> List[str]:
def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> list[str]:
"""Parse the colon-delimited list of paths and apply ldso rules to each

Note the special handling as dictated by the ldso:
Expand Down Expand Up @@ -113,7 +115,7 @@ def parse_ld_paths(str_ldpaths: str, path: str, root: str = "") -> List[str]:


@functools.lru_cache()
def parse_ld_so_conf(ldso_conf: str, root: str = "/", _first: bool = True) -> List[str]:
def parse_ld_so_conf(ldso_conf: str, root: str = "/", _first: bool = True) -> list[str]:
"""Load all the paths from a given ldso config file

This should handle comments, whitespace, and "include" statements.
Expand Down Expand Up @@ -165,7 +167,7 @@ def parse_ld_so_conf(ldso_conf: str, root: str = "/", _first: bool = True) -> Li


@functools.lru_cache()
def load_ld_paths(root: str = "/", prefix: str = "") -> Dict[str, List[str]]:
def load_ld_paths(root: str = "/", prefix: str = "") -> dict[str, list[str]]:
"""Load linker paths from common locations

This parses the ld.so.conf and LD_LIBRARY_PATH env var.
Expand Down Expand Up @@ -258,8 +260,8 @@ def compatible_elfs(elf1: ELFFile, elf2: ELFFile) -> bool:


def find_lib(
elf: ELFFile, lib: str, ldpaths: List[str], root: str = "/"
) -> Tuple[Optional[str], Optional[str]]:
elf: ELFFile, lib: str, ldpaths: list[str], root: str = "/"
) -> tuple[str | None, str | None]:
"""Try to locate a ``lib`` that is compatible to ``elf`` in the given
``ldpaths``

Expand Down Expand Up @@ -296,11 +298,11 @@ def lddtree(
path: str,
root: str = "/",
prefix: str = "",
ldpaths: Optional[Dict[str, List[str]]] = None,
display: Optional[str] = None,
ldpaths: dict[str, list[str]] | None = None,
display: str | None = None,
_first: bool = True,
_all_libs: Dict = {},
) -> Dict:
_all_libs: dict = {},
) -> dict:
"""Parse the ELF dependency tree of the specified file

Parameters
Expand Down
2 changes: 2 additions & 0 deletions src/auditwheel/libc.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from __future__ import annotations

import logging
from enum import IntEnum

Expand Down
Loading