-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
2,925 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
**/* | ||
** | ||
|
||
!src | ||
!**/*.py | ||
!build.py | ||
!pyproject.toml | ||
!poetry.lock | ||
!README.rst | ||
|
||
**/*.egg-info | ||
**/.DS_Store | ||
**/Thumbs.db | ||
**/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
src/audiomatch/popcount/_popcount.c linguist-detectable=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,14 +23,38 @@ jobs: | |
with: | ||
python-version: "3.8" | ||
|
||
- name: Publish Package to PyPI | ||
- name: Install poetry | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
- name: Build Package | ||
run: | | ||
poetry build --format sdist | ||
- name: Unpack sdist to build wheels | ||
env: | ||
TAG: ${{ steps.tag_name.outputs.TAG }} | ||
run: | | ||
tar -xf dist/audiomatch-"${TAG}".tar.gz -C dist/ | ||
mv dist/audiomatch-"${TAG}" dist/audiomatch | ||
- name: Build manylinux wheels | ||
uses: RalfG/[email protected] | ||
with: | ||
python-versions: "cp38-cp38" | ||
package-path: 'dist/audiomatch' | ||
|
||
- name: Copy wheel to dist | ||
run: | | ||
cp wheelhouse/*-manylinux*.whl dist/ | ||
rm -rf dist/audiomatch | ||
- name: Upload Package to PyPI | ||
env: | ||
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }} | ||
PYPI_PASSWORD: ${{ secrets.PYPI_PASSWORD }} | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install poetry | ||
poetry build | ||
poetry publish -u $PYPI_USERNAME -p $PYPI_PASSWORD | ||
- name: Wait for PyPI to update indexes | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
FROM python:3.8-alpine | ||
|
||
RUN apk update \ | ||
&& apk add --no-cache ffmpeg ffmpeg-libs \ | ||
RUN apk add --no-cache ffmpeg ffmpeg-libs \ | ||
&& echo "http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories \ | ||
&& apk add --no-cache chromaprint-dev | ||
|
||
ARG package_version | ||
ENV PACKAGE_VERSION=$package_version | ||
|
||
RUN pip3 install "audiomatch==${PACKAGE_VERSION}" | ||
RUN apk add --virtual .build-deps gcc libc-dev libffi-dev openssl-dev \ | ||
&& pip3 install "audiomatch==${PACKAGE_VERSION}" \ | ||
&& apk del .build-deps gcc libc-dev libffi-dev openssl-dev | ||
|
||
ENTRYPOINT ["audiomatch"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import os | ||
from distutils.extension import Extension | ||
|
||
|
||
def _get_bool(key: str, default: bool = False) -> bool: | ||
value = os.getenv(key) | ||
if value is not None: | ||
return value.lower() in ["true", "1", "t"] | ||
return default | ||
|
||
|
||
def _get_extensions(): | ||
return [ | ||
Extension( | ||
"audiomatch.popcount._popcount", | ||
sources=["src/audiomatch/popcount/_popcount.c"], | ||
) | ||
] | ||
|
||
|
||
def build(setup_kwargs): | ||
"""This function is mandatory in order to build the extensions.""" | ||
use_extensions = not _get_bool("AUDIOMATCH_NO_EXTENSIONS", default=False) | ||
|
||
if use_extensions: | ||
setup_kwargs.update({"ext_modules": _get_extensions()}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
try: | ||
from audiomatch.popcount._popcount import popcount | ||
except ImportError: | ||
# Source: | ||
# http://www.valuedlessons.com/2009/01/popcount-in-python-with-benchmarks.html | ||
# | ||
# This popcount version works slightly faster than 'bin(x).count("1")' | ||
|
||
def _popcount_table(size): | ||
table = [0] * 2 ** size | ||
for i in range(len(table)): | ||
table[i] = (i & 1) + table[i >> 1] | ||
return table | ||
|
||
_POPCOUNT_TABLE16 = _popcount_table(16) | ||
|
||
def popcount(x): | ||
return _POPCOUNT_TABLE16[x & 0xFFFF] + _POPCOUNT_TABLE16[(x >> 16) & 0xFFFF] |
Oops, something went wrong.