Skip to content

Commit 02772de

Browse files
committed
Build wheels.
1 parent dc31621 commit 02772de

18 files changed

Lines changed: 2847 additions & 89 deletions

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pdqhash/_version.py export-subst

.github/workflows/ci.yaml

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
11
name: pdqhash-python CI/CD
22

3-
on:
4-
push:
5-
branches:
6-
- '**'
3+
on: workflow_dispatch
74

85
jobs:
9-
test:
10-
name: Test pdqhash-python
6+
build:
7+
name: Build Package
118
strategy:
129
matrix:
13-
python-version: [3.6]
14-
runs-on: ubuntu-latest
10+
python: ['3.7', '3.8', '3.9', '3.10']
11+
os: [windows-latest, macos-latest, ubuntu-20.04]
12+
runs-on: ${{ matrix.os }}
1513
steps:
1614
- name: Checkout Code
17-
uses: actions/checkout@v2
18-
- name: Get submodules
19-
run: |
20-
git submodule init
21-
git submodule update --remote
22-
- name: Set up Python ${{ matrix.python-version }}
23-
uses: actions/setup-python@v2
15+
uses: actions/checkout@v3
2416
with:
25-
python-version: ${{ matrix.python-version }}
26-
- name: Install Pipenv
27-
run: |
28-
pip install pipenv
29-
- name: Make Host Environment
30-
run: |
31-
make init
32-
- name: Test Source
33-
run: |
34-
make test
17+
submodules: true
18+
fetch-depth: 0
19+
- name: Set up Python ${{ matrix.python }}
20+
id: python
21+
uses: actions/setup-python@v4
22+
with:
23+
python-version: ${{ matrix.python }}
24+
- name: Cache Environment
25+
uses: actions/cache@v3
26+
with:
27+
path: .venv
28+
key: ${{ runner.os }}-${{ steps.python.outputs.python-version }}
29+
- name: Initialize
30+
run: make init
31+
- name: Test
32+
run: make test
33+
- name: Package
34+
run: make package
35+
- uses: actions/upload-artifact@v3
36+
with:
37+
name: wheels
38+
path: dist/*

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ pdqhash/bindings.cpp
88
.DS_Store
99
*.egg-info
1010
pdqhash/bindings.c
11-
.eggs
11+
.eggs
12+
ThreatExchange/pdq/cpp/common

.vscode/settings.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
2-
"python.linting.pylintArgs": [
3-
"--rcfile=setup.cfg"
4-
],
5-
"python.pythonPath": ".venv/bin/python",
6-
"python.formatting.provider": "yapf",
7-
"editor.formatOnSave": true
8-
}
2+
"python.linting.pylintArgs": ["--rcfile=setup.cfg"],
3+
"python.pythonPath": ".venv/bin/python",
4+
"python.formatting.provider": "yapf",
5+
"editor.formatOnSave": false
6+
}

Dockerfile

Lines changed: 0 additions & 12 deletions
This file was deleted.

MANIFEST.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ recursive-exclude ThreatExchange *
22
recursive-include ThreatExchange/pdq *.cpp *.h
33
include ThreatExchange/pdq/LICENSE.txt
44
recursive-include pdqhash *.py *pyx
5-
recursive-exclude pdqhash *.so *.dll *.cpp *.c
5+
recursive-exclude pdqhash *.so *.dll *.cpp *.cinclude versioneer.py
6+
include pdqhash/_version.py
7+
recursive-include include *.h

Makefile

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,15 @@
1-
TEST_SCOPE?=tests/
1+
ifeq ($(OS),Windows_NT)
2+
PYTHON = .venv/Scripts/python.exe
3+
else
4+
PYTHON = .venv/bin/python
5+
endif
26

3-
IMAGE_NAME = pdqhash
4-
DOCKER_ARGS = -v $(PWD)/tests:/usr/src/tests
5-
IN_DOCKER = docker run $(DOCKER_ARGS) $(IMAGE_NAME)
6-
TEST_SCOPE?=tests/
7-
8-
.PHONY: build
97
init:
10-
PIPENV_VENV_IN_PROJECT=true pipenv install --dev --skip-lock
11-
pipenv run pip install -e .
8+
python -m venv .venv
9+
$(PYTHON) -m pip install -r requirements.txt
10+
$(PYTHON) -m pip install -e .
1211
test:
13-
pipenv run pytest -s $(TEST_SCOPE)
14-
docker_build:
15-
docker build --rm --force-rm -t $(IMAGE_NAME) .
16-
docker_test: docker_build
17-
$(IN_DOCKER) make test
18-
docker_bash:
19-
docker run -it $(DOCKER_ARGS) $(IMAGE_NAME) bash
12+
$(PYTHON) -m pytest -s
2013
package:
2114
rm -rf dist
22-
pipenv run python setup.py sdist
15+
$(PYTHON) setup.py sdist bdist_wheel

Pipfile

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
# pdqhash-python [![CircleCI](https://circleci.com/gh/faustomorales/pdqhash-python.svg?style=svg)](https://circleci.com/gh/faustomorales/pdqhash-python)
1+
# pdqhash-python
2+
23
These are Python bindings to the PDQ perceptual hash released by Facebook. Note that the bindings are provided under the MIT license but the PDQ source code is licensed separately under its own license (see the `ThreatExchange/hashing/pdq` folder).
34

45
## Installation
@@ -33,6 +34,7 @@ hash_vector_float, quality = pdqhash.compute_float(image)
3334
```
3435

3536
## Contributing
37+
3638
- Set up local development using `make init` (you need to have `pipenv` installed)
3739
- Run tests using `make test`
38-
- Run tests in Docker using `make docker_test`
40+
- Run tests in Docker using `make docker_test`

include/patches.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifdef _MSC_VER
2+
# include <intrin.h>
3+
# include <stdlib.h>
4+
# define __builtin_popcount __popcnt
5+
# define random rand
6+
#endif

0 commit comments

Comments
 (0)