fix packaging with pyinstaller
This commit is contained in:
parent
37172f31dc
commit
07d1f3ada3
|
@ -108,7 +108,7 @@ jobs:
|
|||
- name: Install dependencies
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install pytest hypothesis pandas mypy
|
||||
pip install pytest hypothesis pandas mypy pyinstaller[hook_testing]
|
||||
|
||||
- name: build
|
||||
run: |
|
||||
|
@ -126,3 +126,7 @@ jobs:
|
|||
if: runner.os != 'Linux'
|
||||
run: |
|
||||
pytest tests
|
||||
|
||||
- name: test pyinstaller packaging
|
||||
run: |
|
||||
python -m PyInstaller.utils.run_tests --include_only rapidfuzz.
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
## Changelog
|
||||
|
||||
### [2.12.0] - 2022-10-22
|
||||
### [2.12.0] - 2022-10-24
|
||||
#### Changed
|
||||
- drop support for Python 3.6
|
||||
|
||||
#### Added
|
||||
- added `Prefix`/`Suffix` similarity
|
||||
|
||||
#### Fixed
|
||||
- fixed packaging with pyinstaller
|
||||
|
||||
### [2.11.1] - 2022-10-05
|
||||
#### Fixed
|
||||
|
|
|
@ -24,7 +24,6 @@ warn_unreachable = true
|
|||
minversion = "6.0"
|
||||
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
|
||||
xfail_strict = true
|
||||
filterwarnings = ["error"]
|
||||
log_cli_level = "info"
|
||||
testpaths = ["tests"]
|
||||
|
||||
|
|
8
setup.py
8
setup.py
|
@ -31,7 +31,13 @@ setup_args = {
|
|||
"Programming Language :: Python :: 3.11",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
],
|
||||
"packages": ["rapidfuzz", "rapidfuzz.distance"],
|
||||
"packages": ["rapidfuzz", "rapidfuzz.distance", "rapidfuzz.__pyinstaller"],
|
||||
"entry_points": {
|
||||
"pyinstaller40": [
|
||||
"hook-dirs = rapidfuzz.__pyinstaller:get_hook_dirs",
|
||||
"tests = rapidfuzz.__pyinstaller:get_PyInstaller_tests",
|
||||
],
|
||||
},
|
||||
"package_dir": {
|
||||
"": "src",
|
||||
},
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
import os
|
||||
|
||||
|
||||
def get_hook_dirs():
|
||||
return [os.path.dirname(__file__)]
|
||||
|
||||
|
||||
def get_PyInstaller_tests():
|
||||
return [os.path.dirname(__file__)]
|
|
@ -0,0 +1,33 @@
|
|||
# Pyinstaller hook to successfully freeze: https://pyinstaller.readthedocs.io/en/stable/hooks.html
|
||||
hiddenimports = [
|
||||
"array.array",
|
||||
"rapidfuzz.fuzz_py",
|
||||
"rapidfuzz.fuzz_cpp",
|
||||
"rapidfuzz.utils_py",
|
||||
"rapidfuzz.utils_cpp",
|
||||
"rapidfuzz.process_py",
|
||||
"rapidfuzz.process_cpp",
|
||||
# distances
|
||||
"rapidfuzz.distance._initialize_py",
|
||||
"rapidfuzz.distance._initialize_cpp",
|
||||
"rapidfuzz.distance.DamerauLevenshtein_py",
|
||||
"rapidfuzz.distance.DamerauLevenshtein_cpp",
|
||||
"rapidfuzz.distance.Hamming_py",
|
||||
"rapidfuzz.distance.Hamming_cpp",
|
||||
"rapidfuzz.distance.Indel_py",
|
||||
"rapidfuzz.distance.Indel_cpp",
|
||||
"rapidfuzz.distance.Jaro_py",
|
||||
"rapidfuzz.distance.Jaro_cpp",
|
||||
"rapidfuzz.distance.JaroWinkler_py",
|
||||
"rapidfuzz.distance.JaroWinkler_cpp",
|
||||
"rapidfuzz.distance.LCSseq_py",
|
||||
"rapidfuzz.distance.LCSseq_cpp",
|
||||
"rapidfuzz.distance.Levenshtein_py",
|
||||
"rapidfuzz.distance.Levenshtein_cpp",
|
||||
"rapidfuzz.distance.OSA_py",
|
||||
"rapidfuzz.distance.OSA_cpp",
|
||||
"rapidfuzz.distance.Prefix_py",
|
||||
"rapidfuzz.distance.Prefix_cpp",
|
||||
"rapidfuzz.distance.Postfix_py",
|
||||
"rapidfuzz.distance.Postfix_cpp",
|
||||
]
|
|
@ -0,0 +1,34 @@
|
|||
import subprocess
|
||||
|
||||
from PyInstaller import __main__ as pyi_main
|
||||
|
||||
# Test out the package by importing it, then running functions from it.
|
||||
def test_pyi_hooksample(tmp_path):
|
||||
app_name = "userapp"
|
||||
workpath = tmp_path / "build"
|
||||
distpath = tmp_path / "dist"
|
||||
app = tmp_path / (app_name + ".py")
|
||||
app.write_text(
|
||||
"\n".join(
|
||||
[
|
||||
"import rapidfuzz",
|
||||
"from rapidfuzz.distance import Levenshtein_py",
|
||||
"from rapidfuzz.distance import Levenshtein_cpp",
|
||||
"rapidfuzz.distance.Levenshtein.distance('test', 'teste')",
|
||||
"Levenshtein_py.distance('test', 'teste')",
|
||||
"Levenshtein_cpp.distance('test', 'teste')",
|
||||
]
|
||||
)
|
||||
)
|
||||
args = [
|
||||
# Place all generated files in ``tmp_path``.
|
||||
"--workpath",
|
||||
str(workpath),
|
||||
"--distpath",
|
||||
str(distpath),
|
||||
"--specpath",
|
||||
str(tmp_path),
|
||||
str(app),
|
||||
]
|
||||
pyi_main.run(args)
|
||||
subprocess.run([str(distpath / app_name / app_name)], check=True)
|
Loading…
Reference in New Issue