Skip to content

Commit fc1ed1c

Browse files
authored
Merge pull request #282 from pypa/gha
Use GitHub Actions for x86_64 tests
2 parents 686024e + 01667eb commit fc1ed1c

24 files changed

+182
-89
lines changed

Diff for: .github/workflows/lint.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
lint:
9+
name: Lint
10+
runs-on: ubuntu-20.04
11+
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Install CPython 3.8
17+
uses: actions/setup-python@v2
18+
with:
19+
python-version: 3.8
20+
architecture: x64
21+
22+
- name: Install/fetch dependencies
23+
run: |
24+
set -exuo pipefail
25+
pip install --upgrade pip setuptools
26+
pip install tox
27+
28+
- name: Run linter
29+
run: tox -e lint

Diff for: .github/workflows/test.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
test:
9+
name: CPython ${{ matrix.python }}
10+
runs-on: ubuntu-20.04
11+
strategy:
12+
matrix:
13+
include:
14+
- python: "3.6"
15+
- python: "3.7"
16+
- python: "3.8"
17+
- python: "3.9"
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v2
22+
23+
- name: Install CPython ${{ matrix.python }}
24+
uses: actions/setup-python@v2
25+
with:
26+
python-version: ${{ matrix.python }}
27+
architecture: x64
28+
29+
- name: Install/fetch dependencies
30+
run: |
31+
set -exuo pipefail
32+
pip install --upgrade pip setuptools
33+
./tests/install.sh
34+
35+
- name: Run tests
36+
run: ./tests/travis.sh

Diff for: .travis.yml

+1-11
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ language: python
44

55
jobs:
66
include:
7-
- python: "3.6"
8-
- python: "3.7"
9-
- python: "3.8"
10-
- python: "3.9"
117
- python: "3.8"
128
arch: arm64-graviton2
139
virt: vm
@@ -16,8 +12,6 @@ jobs:
1612
arch: ppc64le
1713
- python: "3.8"
1814
arch: s390x
19-
- python: "3.8"
20-
env: LINTER=1
2115

2216
services:
2317
- docker
@@ -29,11 +23,7 @@ before_install:
2923
- pip install --upgrade pip setuptools
3024

3125
install:
32-
- pip install -r test-requirements.txt
33-
- pip install tox codecov
34-
- pip install -e .
35-
# pull manylinux images that will be used, this helps passing tests which would otherwise timeout.
36-
- python -c $'from tests.integration.test_manylinux import MANYLINUX_IMAGES\nfor image in MANYLINUX_IMAGES.values():\n print(image)' | xargs -L 1 docker pull
26+
- ./tests/install.sh
3727

3828
script:
3929
- tests/travis.sh

Diff for: auditwheel/condatools.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,36 @@
22
conda packages.
33
"""
44
import os
5+
from typing import List, Optional
56

67
from .tmpdirs import InTemporaryDirectory
78
from .tools import tarbz2todir
89

910

1011
class InCondaPkg(InTemporaryDirectory):
11-
def __init__(self, in_conda_pkg):
12+
def __init__(self, in_conda_pkg: str) -> None:
1213
"""Initialize in-conda-package context manager"""
1314
self.in_conda_pkg = os.path.abspath(in_conda_pkg)
1415
super().__init__()
1516

16-
def __enter__(self):
17+
def __enter__(self) -> str:
1718
tarbz2todir(self.in_conda_pkg, self.name)
1819
return super().__enter__()
1920

2021

2122
class InCondaPkgCtx(InCondaPkg):
22-
def __init__(self, in_conda_pkg):
23+
def __init__(self, in_conda_pkg: str) -> None:
2324
super().__init__(in_conda_pkg)
24-
self.path = None
25+
self.path: Optional[str] = None
2526

2627
def __enter__(self):
2728
self.path = super().__enter__()
2829
return self
2930

30-
def iter_files(self):
31+
def iter_files(self) -> List[str]:
32+
if self.path is None:
33+
raise ValueError(
34+
"This function should be called from context manager")
3135
files = os.path.join(self.path, 'info', 'files')
3236
with open(files) as f:
3337
return [line.strip() for line in f.readlines()]

Diff for: auditwheel/elfutils.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from os.path import basename, realpath, relpath
33
from .lddtree import parse_ld_paths
44

5-
from elftools.elf.elffile import ELFFile # type: ignore
6-
from elftools.common.exceptions import ELFError # type: ignore
5+
from elftools.elf.elffile import ELFFile
6+
from elftools.common.exceptions import ELFError
77
from typing import Iterator, Tuple, Optional, Dict, List
88

99

@@ -78,7 +78,8 @@ def elf_references_PyFPE_jbuf(elf: ELFFile) -> bool:
7878
return False
7979

8080

81-
def elf_is_python_extension(fn, elf) -> Tuple[bool, Optional[int]]:
81+
def elf_is_python_extension(fn: str,
82+
elf: ELFFile) -> Tuple[bool, Optional[int]]:
8283
modname = basename(fn).split('.', 1)[0]
8384
module_init_f = {
8485
'init' + modname: 2,

Diff for: auditwheel/genericpkgctx.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
from typing import Optional, Union
12
from .wheeltools import InWheelCtx
23
from .condatools import InCondaPkgCtx
34

45

5-
def InGenericPkgCtx(in_path, out_path=None):
6+
def InGenericPkgCtx(
7+
in_path: str, out_path: Optional[str] = None
8+
) -> Union[InWheelCtx, InCondaPkgCtx]:
69
"""Factory that returns a InWheelCtx or InCondaPkgCtx
710
context manager depending on the file extension
811
"""

Diff for: auditwheel/hashfile.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import hashlib
2+
from typing import BinaryIO
23

34

4-
def hashfile(afile, blocksize=65536):
5+
def hashfile(afile: BinaryIO, blocksize: int = 65536) -> str:
56
"""Hash the contents of an open file handle with SHA256"""
67
hasher = hashlib.sha256()
78
buf = afile.read(blocksize)

Diff for: auditwheel/lddtree.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
import errno
1818
import logging
1919
import functools
20-
from typing import List, Dict, Optional, Any
20+
from typing import List, Dict, Optional, Any, Tuple
2121

22-
from elftools.elf.elffile import ELFFile # type: ignore
22+
from elftools.elf.elffile import ELFFile
2323

2424
log = logging.getLogger(__name__)
2525
__all__ = ['lddtree']
@@ -75,7 +75,7 @@ def dedupe(items: List[str]) -> List[str]:
7575
return [seen.setdefault(x, x) for x in items if x not in seen]
7676

7777

78-
def parse_ld_paths(str_ldpaths, root='', path=None) -> List[str]:
78+
def parse_ld_paths(str_ldpaths: str, path: str, root: str = '') -> List[str]:
7979
"""Parse the colon-delimited list of paths and apply ldso rules to each
8080
8181
Note the special handling as dictated by the ldso:
@@ -204,7 +204,7 @@ def load_ld_paths(root: str = '/', prefix: str = '') -> Dict[str, List[str]]:
204204
return ldpaths
205205

206206

207-
def compatible_elfs(elf1, elf2):
207+
def compatible_elfs(elf1: ELFFile, elf2: ELFFile) -> bool:
208208
"""See if two ELFs are compatible
209209
210210
This compares the aspects of the ELF to see if they're compatible:
@@ -232,7 +232,8 @@ def compatible_elfs(elf1, elf2):
232232
elf1.header['e_machine'] == elf2.header['e_machine'])
233233

234234

235-
def find_lib(elf, lib, ldpaths, root='/'):
235+
def find_lib(elf: ELFFile, lib: str, ldpaths: List[str],
236+
root: str = '/') -> Tuple[Optional[str], Optional[str]]:
236237
"""Try to locate a ``lib`` that is compatible to ``elf`` in the given
237238
``ldpaths``
238239
@@ -370,13 +371,13 @@ def lddtree(path: str,
370371
if t.entry.d_tag == 'DT_RPATH':
371372
rpaths = parse_ld_paths(
372373
t.rpath,
373-
root=root,
374-
path=path)
374+
path=path,
375+
root=root)
375376
elif t.entry.d_tag == 'DT_RUNPATH':
376377
runpaths = parse_ld_paths(
377378
t.runpath,
378-
root=root,
379-
path=path)
379+
path=path,
380+
root=root)
380381
elif t.entry.d_tag == 'DT_NEEDED':
381382
libs.append(t.needed)
382383
if runpaths:
@@ -412,7 +413,7 @@ def lddtree(path: str,
412413
'path': fullpath,
413414
'needed': [],
414415
}
415-
if fullpath:
416+
if realpath and fullpath:
416417
lret = lddtree(realpath,
417418
root,
418419
prefix,

Diff for: auditwheel/main.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@
22
import sys
33
import logging
44
import argparse
5-
import pkg_resources # type: ignore
5+
import pkg_resources
6+
from typing import Optional
67

78
from . import main_show
89
from . import main_addtag
910
from . import main_lddtree
1011
from . import main_repair
1112

1213

13-
def main():
14+
def main() -> Optional[int]:
1415
if sys.platform != 'linux':
1516
print('Error: This tool only supports Linux')
1617
return 1
@@ -45,7 +46,7 @@ def main():
4546

4647
if not hasattr(args, 'func'):
4748
p.print_help()
48-
return
49+
return None
4950

5051
rval = args.func(args, p)
5152

Diff for: auditwheel/main_addtag.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def configure_parser(sub_parsers):
2222

2323
def execute(args, p):
2424
import os
25-
from ._vendor.wheel.wheelfile import WHEEL_INFO_RE # type: ignore
25+
from ._vendor.wheel.wheelfile import WHEEL_INFO_RE
2626
from .wheeltools import InWheelCtx, add_platforms, WheelToolsError
2727
from .wheel_abi import analyze_wheel_abi, NonPlatformWheel
2828

Diff for: auditwheel/main_lddtree.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import logging
2-
32
logger = logging.getLogger(__name__)
43

54

Diff for: auditwheel/main_show.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def configure_parser(sub_parsers):
1212
p.set_defaults(func=execute)
1313

1414

15-
def printp(text):
15+
def printp(text: str) -> None:
1616
from textwrap import wrap
1717
print()
1818
print('\n'.join(wrap(text)))

Diff for: auditwheel/patcher.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def _verify_patchelf() -> None:
4646

4747

4848
class Patchelf(ElfPatcher):
49-
def __init__(self):
49+
def __init__(self) -> None:
5050
_verify_patchelf()
5151

5252
def replace_needed(self,

Diff for: auditwheel/policy/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import sys
22
import json
33
import platform as _platform_module
4-
from typing import Optional
4+
from typing import Optional, List
55
from os.path import join, dirname, abspath
66
import logging
77

@@ -12,7 +12,7 @@
1212
bits = 8 * (8 if sys.maxsize > 2 ** 32 else 4)
1313

1414

15-
def get_arch_name():
15+
def get_arch_name() -> str:
1616
machine = _platform_module.machine()
1717
if machine not in {'x86_64', 'i686'}:
1818
return machine
@@ -56,7 +56,7 @@ def get_policy_name(priority: int) -> Optional[str]:
5656
return matches[0]
5757

5858

59-
def get_priority_by_name(name: str):
59+
def get_priority_by_name(name: str) -> Optional[int]:
6060
matches = [p['priority'] for p in _POLICIES if p['name'] == name]
6161
if len(matches) == 0:
6262
return None
@@ -65,7 +65,7 @@ def get_priority_by_name(name: str):
6565
return matches[0]
6666

6767

68-
def get_replace_platforms(name: str):
68+
def get_replace_platforms(name: str) -> List[str]:
6969
"""Extract platform tag replacement rules from policy
7070
7171
>>> get_replace_platforms('linux_x86_64')

Diff for: auditwheel/policy/external_references.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import re
22
import logging
3-
from typing import Dict, List, Set, Any
3+
from typing import Dict, Set, Any, Generator
44

55
from ..elfutils import is_subdir
66
from . import load_policies
@@ -9,12 +9,13 @@
99
LIBPYTHON_RE = re.compile(r'^libpython\d\.\dm?.so(.\d)*$')
1010

1111

12-
def lddtree_external_references(lddtree: Dict, wheel_path: str):
12+
def lddtree_external_references(lddtree: Dict, wheel_path: str) -> Dict:
1313
# XXX: Document the lddtree structure, or put it in something
1414
# more stable than a big nested dict
1515
policies = load_policies()
1616

17-
def filter_libs(libs, whitelist):
17+
def filter_libs(libs: Set[str],
18+
whitelist: Set[str]) -> Generator[str, None, None]:
1819
for lib in libs:
1920
if 'ld-linux' in lib or lib in ['ld64.so.2', 'ld64.so.1']:
2021
# always exclude ELF dynamic linker/loader
@@ -30,7 +31,7 @@ def filter_libs(libs, whitelist):
3031
continue
3132
yield lib
3233

33-
def get_req_external(libs: Set[str], whitelist: Set[str]):
34+
def get_req_external(libs: Set[str], whitelist: Set[str]) -> Set[str]:
3435
# get all the required external libraries
3536
libs = libs.copy()
3637
reqs = set()
@@ -44,7 +45,7 @@ def get_req_external(libs: Set[str], whitelist: Set[str]):
4445

4546
ret = {} # type: Dict[str, Dict[str, Any]]
4647
for p in policies:
47-
needed_external_libs = [] # type: List[str]
48+
needed_external_libs = set() # type: Set[str]
4849

4950
if not (p['name'] == 'linux' and p['priority'] == 0):
5051
# special-case the generic linux platform here, because it

0 commit comments

Comments
 (0)