Skip to content

Commit

Permalink
fix: linter issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeut committed Aug 28, 2021
1 parent 29ee8e6 commit 3347adf
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 45 deletions.
8 changes: 4 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Released Apr. 3, 2021
### User-facing changes
- [BUGFIX] Patch RPATHs of non-Python extension dependencies ([#136](https://github.com/pypa/auditwheel/issues/136), [#298](https://github.com/pypa/auditwheel/pull/298))
- [BUGFIX] Ensure policies in `policy.json` are compliant with PEP600 ([#287](https://github.com/pypa/auditwheel/pull/287))
- This removes 2 non existing symbols from manylinux1 i686 policy and removes ncurses librairies from manylinux1 whitelist.
- This removes 2 non existing symbols from manylinux1 i686 policy and removes ncurses librairies from manylinux1 whitelist.
- [FEATURE] Use PEP600 policy names ([#288](https://github.com/pypa/auditwheel/pull/288), [#297](https://github.com/pypa/auditwheel/pull/297))
- The platform tag passed to `auditwheel repair` `--plat` argument can use either the PEP600 tag or the legacy tag. The repaired wheel will get both platform tags.
- Inform about aliases in `auditwheel repair --help`
- [FEATURE] Always repair as a single wheel ([#289](https://github.com/pypa/auditwheel/pull/289))
- Add argument `--only-plat` to `auditwheel repair` for those who were keeping only the lowest priority tag wheel (i.e. the one requested by `--plat` argument).
- Add argument `--only-plat` to `auditwheel repair` for those who were keeping only the lowest priority tag wheel (i.e. the one requested by `--plat` argument).
- [FEATURE] Add manylinux_2_27 policy ([#299](https://github.com/pypa/auditwheel/issues/299), [#300](https://github.com/pypa/auditwheel/pull/300))
- [FEATURE] Add libexpat.so.1 to whitelisted libraries starting with manylinux2010 ([#152](https://github.com/pypa/auditwheel/issues/152), [#301](https://github.com/pypa/auditwheel/pull/301))

Expand Down Expand Up @@ -63,7 +63,7 @@ Released Dec. 6, 2020
Released Jul. 1, 2020

### User-facing changes
- [FEATURE] Ensure that system-copied libraries are writable before running patchelf
- [FEATURE] Ensure that system-copied libraries are writable before running patchelf
([https://github.com/pypa/auditwheel/pull/237](#237))
- [FEATURE] Preserve RPATH in extension modules ([https://github.com/pypa/auditwheel/pull/245](#245))

Expand All @@ -86,7 +86,7 @@ Released Apr. 25, 2020
Released Jan. 29, 2020

### User-facing changes
- [FEATURE] Put libraries in `$WHEELNAME.libs` to avoid vendoring multiple copies
- [FEATURE] Put libraries in `$WHEELNAME.libs` to avoid vendoring multiple copies
of the same library ([#90](https://github.com/pypa/auditwheel/pull/90))

### Housekeeping
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The auditwheel package is covered by the MIT license.
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.


3rd party code and data
=======================
Expand Down
13 changes: 6 additions & 7 deletions noxfile.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
import os
import sys

from pathlib import Path
from typing import List

import nox


RUNNING_CI = "TRAVIS" in os.environ or "GITHUB_ACTIONS" in os.environ


@nox.session(reuse_venv=True)
def lint(session: nox.Session) -> str:
def lint(session: nox.Session) -> None:
"""
Run linters on the codebase.
"""
Expand All @@ -19,7 +18,7 @@ def lint(session: nox.Session) -> str:


@nox.session()
def coverage(session: nox.Session) -> str:
def coverage(session: nox.Session) -> None:
"""
Run coverage using unit tests.
"""
Expand All @@ -30,11 +29,11 @@ def coverage(session: nox.Session) -> str:
"pytest",
"tests/unit",
"--cov=auditwheel",
"--cov-report=term-missing"
"--cov-report=term-missing",
)


def _docker_images(session):
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 All @@ -51,7 +50,7 @@ def _docker_images(session):


@nox.session(python=["3.6", "3.7", "3.8", "3.9"])
def tests(session: nox.Session) -> str:
def tests(session: nox.Session) -> None:
"""
Run tests.
"""
Expand Down
44 changes: 22 additions & 22 deletions scripts/calculate_symbol_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
This should be run inside a manylinux Docker container.
"""
import argparse
import json
import os
import platform
import json

from elftools.elf.elffile import ELFFile

if platform.architecture()[0] == '64bit':
LIBRARY_PATHS = ['/lib64', '/usr/lib64']
if platform.architecture()[0] == "64bit":
LIBRARY_PATHS = ["/lib64", "/usr/lib64"]
else:
LIBRARY_PATHS = ['/lib', '/usr/lib']
LIBRARY_PATHS = ["/lib", "/usr/lib"]

parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("policy", help="The policy name")
Expand All @@ -26,9 +27,9 @@ def load_policies(path):

def choose_policy(name, policies):
try:
return next(policy for policy in policies if policy['name'] == name)
return next(policy for policy in policies if policy["name"] == name)
except StopIteration:
raise RuntimeError("Unknown policy {}".format(name))
raise RuntimeError(f"Unknown policy {name}")


def find_library(library):
Expand All @@ -37,12 +38,12 @@ def find_library(library):
if os.path.exists(path):
return path
else:
raise RuntimeError("Unknown library {}".format(library))
raise RuntimeError(f"Unknown library {library}")


def versionify(version_string):
try:
result = [int(n) for n in version_string.split('.')]
result = [int(n) for n in version_string.split(".")]
assert len(result) <= 3
except ValueError:
result = [999999, 999999, 999999, version_string]
Expand All @@ -51,30 +52,29 @@ def versionify(version_string):

def calculate_symbol_versions(libraries, symbol_versions, arch):
calculated_symbol_versions = {k: set() for k in symbol_versions}
prefixes = ['/lib', '/usr/lib']
if arch == '64bit':
prefixes = [p + '64' for p in prefixes]
prefixes = ["/lib", "/usr/lib"]
if arch == "64bit":
prefixes = [p + "64" for p in prefixes]

for library in libraries:
library_path = find_library(library)
with open(library_path, 'rb') as f:
with open(library_path, "rb") as f:
e = ELFFile(f)
section = e.get_section_by_name('.gnu.version_d')
section = e.get_section_by_name(".gnu.version_d")
if section:
for _, verdef_iter in section.iter_versions():
for vernaux in verdef_iter:
for symbol_name in symbol_versions:
try:
name, version = vernaux.name.split('_', 1)
name, version = vernaux.name.split("_", 1)
except ValueError:
pass
if name in calculated_symbol_versions \
and version != 'PRIVATE':
if (
name in calculated_symbol_versions
and version != "PRIVATE"
):
calculated_symbol_versions[name].add(version)
return {
k: sorted(v, key=versionify)
for k, v in calculated_symbol_versions.items()
}
return {k: sorted(v, key=versionify) for k, v in calculated_symbol_versions.items()}


def main():
Expand All @@ -85,8 +85,8 @@ def main():
print(
json.dumps(
calculate_symbol_versions(
policy['lib_whitelist'],
policy['symbol_versions'],
policy["lib_whitelist"],
policy["symbol_versions"],
arch,
)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/foo.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

subroutine selectedrealkind(p, r, res)
implicit none

integer, intent(in) :: p, r
!f2py integer :: r=0
integer, intent(out) :: res
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/sample_extension/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["setuptools >= 45.0.0", "cython"]
build-backend = "setuptools.build_meta"
build-backend = "setuptools.build_meta"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ def test_func(x):
return _test_func(x)

cdef _test_func(x):
return x + 1
return x + 1
9 changes: 6 additions & 3 deletions tests/integration/test_manylinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ def test_build_wheel_with_binary_executable(
[
"bash",
"-c",
"cd /auditwheel_src/tests/integration/testpackage && python -m pip wheel --no-deps -w /io .",
"cd /auditwheel_src/tests/integration/testpackage && "
"python -m pip wheel --no-deps -w /io .",
],
)

Expand Down Expand Up @@ -391,7 +392,8 @@ def test_build_wheel_with_image_dependencies(
assert "manylinux" not in orig_wheel

repair_command = (
"LD_LIBRARY_PATH=/auditwheel_src/tests/integration/testdependencies:$LD_LIBRARY_PATH "
"LD_LIBRARY_PATH="
"/auditwheel_src/tests/integration/testdependencies:$LD_LIBRARY_PATH "
"auditwheel -v repair --plat {policy} -w /io /io/{orig_wheel}"
)

Expand Down Expand Up @@ -522,7 +524,8 @@ def test_build_wheel_depending_on_library_with_rpath(
[
"bash",
"-c",
"LD_LIBRARY_PATH=/auditwheel_src/tests/integration/testrpath/a:$LD_LIBRARY_PATH "
"LD_LIBRARY_PATH="
"/auditwheel_src/tests/integration/testrpath/a:$LD_LIBRARY_PATH "
+ repair_command,
],
)
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/testpackage/testpackage/testprogram.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ int main(int argc, char **argv)
fputs("Expected command line argument to be a float\n", stderr);
return EXIT_FAILURE;
}

x = gsl_pow_2(x);
printf("%g\n", x);
return EXIT_SUCCESS;
Expand Down
1 change: 0 additions & 1 deletion tests/unit/test_elfpatcher.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import os
from subprocess import CalledProcessError
from unittest.mock import call, patch

Expand Down
2 changes: 1 addition & 1 deletion tests/unit/test_elfutils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from unittest.mock import MagicMock, Mock, patch
from unittest.mock import Mock, patch

import pytest
from elftools.common.exceptions import ELFError
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_wheel_abi.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ class TestGetWheelElfdata:
(
# A single invalid file
[os.sep.join(["purelib", "foo"])],
"Invalid binary wheel, found the following shared library/libraries in purelib folder:\n\tfoo\nThe wheel has to be platlib compliant in order to be repaired by auditwheel.",
"Invalid binary wheel, found the following shared library/libraries in"
" purelib folder:\n\tfoo\nThe wheel has to be platlib compliant in "
"order to be repaired by auditwheel.",
),
(
# Multiple invalid files
[os.sep.join(["purelib", "foo"]), os.sep.join(["purelib", "bar"])],
"Invalid binary wheel, found the following shared library/libraries in purelib folder:\n\tfoo\n\tbar\nThe wheel has to be platlib compliant in order to be repaired by auditwheel.",
"Invalid binary wheel, found the following shared library/libraries in"
" purelib folder:\n\tfoo\n\tbar\nThe wheel has to be platlib compliant"
" in order to be repaired by auditwheel.",
),
],
)
Expand Down

0 comments on commit 3347adf

Please sign in to comment.