Skip to content

Commit

Permalink
v1.20.4 CI (#132)
Browse files Browse the repository at this point in the history
* v1.20.4

* compat blake2b hash 2.x
  • Loading branch information
wimglenn committed Dec 4, 2023
1 parent 6df2a5b commit 102db09
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 18 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
branches: ["main", "1.x"]
workflow_dispatch:

jobs:
tests:
name: "Python ${{ matrix.python-version }} on ${{ matrix.os }}"
name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}

strategy:
Expand All @@ -25,36 +25,40 @@ jobs:
python-version: "3.7"

steps:
- uses: "actions/checkout@v3"
- uses: "actions/setup-python@v4"
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "${{ matrix.python-version }}"
- name: "Install dependencies"
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |
python -VV
python -m pip install -r requirements-dev.txt
- name: "Run tests for ${{ matrix.python-version }} on ${{ matrix.os }}"
- name: Run tests for ${{ matrix.python-version }} on ${{ matrix.os }}
run: python -m pytest

- name: Upload coverage to Codecov
uses: "codecov/codecov-action@v3"
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}

tests-27:
name: "Python 2.7 on ubuntu-20.04"
name: Python 2.7 on ubuntu-20.04
runs-on: ubuntu-20.04
container:
image: python:2.7-buster

steps:
- uses: "actions/checkout@v3"
- name: "Install dependencies"
- uses: actions/checkout@v3
- name: Install dependencies
run: |
python -VV
python -m pip install -r requirements-dev.txt
- name: "Run tests for Python 2.7 on ubuntu-20.04"
- name: Run tests for Python 2.7 on ubuntu-20.04
run: python -m pytest

- name: Upload coverage to Codecov
uses: "codecov/codecov-action@v3"
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
19 changes: 14 additions & 5 deletions johnnydep/pipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@

def compute_checksum(target, algorithm="sha256", blocksize=2 ** 13):
hashtype = getattr(hashlib, algorithm)
if algorithm == "blake2b":
hash_ = hashtype(digest_size=32)
else:
hash_ = hashtype()
hash_ = hashtype()
log.debug("computing checksum", target=target, algorithm=algorithm)
with open(target, "rb") as f:
for chunk in iter(lambda: f.read(blocksize), b""):
Expand All @@ -46,6 +43,18 @@ def compute_checksum(target, algorithm="sha256", blocksize=2 ** 13):
return result


def _warehouse_hash(target):
try:
blake2b = hashlib.blake2b
except AttributeError:
# Python < 3.6
import pyblake2
blake2b = pyblake2.blake2b
with open(target, "rb") as f:
b2b = blake2b(f.read(), digest_size=32)
return b2b.hexdigest()


def _get_pip_version():
# try to get pip version without actually importing pip
# setuptools gets upset if you import pip before importing setuptools..
Expand Down Expand Up @@ -213,7 +222,7 @@ def get(dist_name, index_url=None, env=None, extra_index_url=None, tmpdir=None,
except ValueError:
pass
else:
b2b = compute_checksum(whl, "blake2b")
b2b = _warehouse_hash(whl)
path = "/".join([b2b[:2], b2b[2:4], b2b[4:], os.path.basename(whl)])
urls = {x for x in out.split() if x.startswith("http") and x.endswith(path)}
if len(urls) == 1:
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"colorama ; python_version < '3.7' or platform_system == 'Windows'", # structlog
"cachetools",
"oyaml",
"pyblake2 ; python_version < '3.6'",
"toml",
"pip",
"packaging >= 17, != 22",
Expand Down

0 comments on commit 102db09

Please sign in to comment.