Skip to content

Commit d5c6afc

Browse files
authored
use a GA caching scheme (#15)
1 parent 1d6d1de commit d5c6afc

7 files changed

Lines changed: 42 additions & 33 deletions

File tree

.github/workflows/build-test.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,29 @@ jobs:
2222
runs-on: ${{ matrix.os }}
2323
steps:
2424
- uses: actions/checkout@v2
25+
2526
- name: Set up Python ${{ matrix.python-version }}
2627
uses: actions/setup-python@v2
2728
with:
2829
python-version: ${{ matrix.python-version }}
2930
architecture: x64
31+
32+
# block below based on:
33+
# https://medium.com/ai2-blog/python-caching-in-github-actions-e9452698e98d
34+
- uses: actions/cache@v2
35+
with:
36+
path: ${{ env.pythonLocation }}
37+
key: ${{ env.pythonLocation }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements.txt') }}-${{ hashFiles('pip-freeze.txt') }}
38+
3039
- name: Install dependencies
3140
run: |
32-
pip install setuptools wheel
33-
pip install -r requirements.txt
34-
pip install .
41+
pip install --upgrade --upgrade-strategy eager setuptools wheel
42+
pip install --upgrade --upgrade-strategy eager -r requirements.txt
43+
pip install --upgrade --upgrade-strategy eager -e .
44+
pip freeze > pip-freeze.txt
45+
3546
- name: Test with pytest
36-
run: python -m pytest
47+
run: |
48+
python setup.py build_ext --inplace
49+
pip install -e .
50+
python -m pytest

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ commands:
110110
111111
git clone https://github.com/escherba/python-metrohash.git
112112
cd python-metrohash
113-
make env # creates a Python virtualenv
113+
make env # create a Python virtualenv
114114
make test # run Python tests
115115
make cpp-test # run C++ tests
116116

pip-freeze.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,27 @@ attrs==21.4.0
22
backcall==0.2.0
33
Cython==0.29.26
44
decorator==5.1.0
5-
distlib==0.3.4
6-
filelock==3.4.2
75
importlib-metadata==4.10.0
86
iniconfig==1.1.1
97
ipdb==0.13.9
108
ipython==7.30.1
119
jedi==0.18.1
1210
matplotlib-inline==0.1.3
13-
-e git+https://github.com/escherba/python-metrohash@c0d6ef1dac61d9cfb3cba5bb8533f69df3c445e6#egg=metrohash
11+
-e git+https://github.com/escherba/python-metrohash@03ec8e4b0b21bf4a9726b3625d5ebc6e791b2a82#egg=metrohash
1412
numpy==1.21.5
1513
packaging==21.3
1614
parso==0.8.3
1715
pexpect==4.8.0
1816
pickleshare==0.7.5
19-
platformdirs==2.4.1
2017
pluggy==1.0.0
2118
prompt-toolkit==3.0.24
2219
ptyprocess==0.7.0
2320
py==1.11.0
2421
Pygments==2.11.0
2522
pyparsing==3.0.6
2623
pytest==6.2.5
27-
six==1.16.0
2824
toml==0.10.2
2925
traitlets==5.1.1
3026
typing_extensions==4.0.1
31-
virtualenv==20.11.2
3227
wcwidth==0.2.5
3328
zipp==3.7.0

requirements.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,3 @@ ipdb
33
ipython
44
numpy
55
pytest
6-
setuptools
7-
virtualenv

setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33
import os
4-
import warnings
54
from os.path import join, dirname
65
from setuptools import setup
76
from setuptools.extension import Extension
@@ -32,8 +31,9 @@ def is_pure(self):
3231

3332
CXXFLAGS = []
3433

34+
print(f"building for platform: {os.name}")
3535
if os.name == "nt":
36-
CXXFLAGS.extend(["/O3"])
36+
CXXFLAGS.extend(["/O2"])
3737
else:
3838
CXXFLAGS.extend([
3939
"-O3",
@@ -43,10 +43,10 @@ def is_pure(self):
4343

4444

4545
if 'sse4_2' in CPU_FLAGS:
46-
warnings.warn("Compiling with SSE4.2 enabled")
46+
print("Compiling with SSE4.2 enabled")
4747
CXXFLAGS.append('-msse4.2')
4848
else:
49-
warnings.warn("compiling without SSE4.2 support")
49+
print("compiling without SSE4.2 support")
5050

5151

5252
INCLUDE_DIRS = ['include']
@@ -67,6 +67,7 @@ def is_pure(self):
6767
EXT_MODULES = []
6868

6969
if USE_CYTHON:
70+
print("building extension using Cython")
7071
CMDCLASS['build_ext'] = build_ext
7172
EXT_MODULES.append(
7273
Extension(
@@ -79,6 +80,7 @@ def is_pure(self):
7980
)
8081
)
8182
else:
83+
print("building extension w/o Cython")
8284
EXT_MODULES.append(
8385
Extension(
8486
"metrohash",
@@ -91,7 +93,7 @@ def is_pure(self):
9193
)
9294

9395

94-
VERSION = '0.1.1.post1'
96+
VERSION = '0.1.1.post2'
9597
URL = "https://github.com/escherba/python-metrohash"
9698

9799

src/metrohash.cpp

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/metrohash.pyx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Python wrapper for MetroHash, a fast non-cryptographic hashing algorithm
1010

1111
__author__ = "Eugene Scherba"
1212
__email__ = "escherba+metrohash@gmail.com"
13-
__version__ = "0.1.1.post1"
13+
__version__ = "0.1.1.post2"
1414
__all__ = [
1515
"metrohash64",
1616
"metrohash128",
@@ -325,7 +325,7 @@ cdef class MetroHash64(object):
325325
def hexdigest(self) -> str:
326326
"""Obtain a string digest in hexadecimal form
327327
Returns:
328-
bytes: hash string
328+
str: hash string
329329
"""
330330
return bytes2hex(self.digest())
331331
@@ -409,7 +409,7 @@ cdef class MetroHash128(object):
409409
def hexdigest(self) -> str:
410410
"""Obtain a string digest in hexadecimal form
411411
Returns:
412-
bytes: hash string
412+
str: hash string
413413
"""
414414
return bytes2hex(self.digest())
415415

0 commit comments

Comments
 (0)