Skip to content

Commit cc4fbf9

Browse files
authored
Merge pull request #1145 from vloncar/qkeras_install_hook
Temporary workaround for QKeras installation
2 parents cfcd46c + 5dd7715 commit cc4fbf9

File tree

2 files changed

+31
-2
lines changed

2 files changed

+31
-2
lines changed

hls4ml/__init__.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
1-
from hls4ml import converters, report, utils # noqa: F401
1+
# Temporary workaround for QKeras installation requirement, will be removed after 1.0.0
2+
def maybe_install_qkeras():
3+
import subprocess
4+
import sys
5+
6+
QKERAS_PKG_NAME = 'QKeras'
7+
# QKERAS_PKG_SOURCE = QKERAS_PKG_NAME
8+
QKERAS_PKG_SOURCE = 'qkeras@git+https://github.com/fastmachinelearning/qkeras.git'
9+
10+
def pip_list():
11+
p = subprocess.run([sys.executable, '-m', 'pip', 'list'], check=True, capture_output=True)
12+
return p.stdout.decode()
13+
14+
def pip_install(package):
15+
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])
16+
17+
all_pkgs = pip_list()
18+
if QKERAS_PKG_NAME not in all_pkgs:
19+
print('QKeras installation not found, installing one...')
20+
pip_install(QKERAS_PKG_SOURCE)
21+
print('QKeras installed.')
22+
23+
24+
try:
25+
maybe_install_qkeras()
26+
except Exception:
27+
print('Could not find QKeras installation, make sure you have QKeras installed.')
28+
29+
# End of workaround
30+
31+
from hls4ml import converters, report, utils # noqa: F401, E402
232

333
try:
434
from ._version import version as __version__

setup.cfg

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ install_requires =
2929
pydigitalwavetools==1.1
3030
pyparsing
3131
pyyaml
32-
qkeras@git+https://github.com/google/qkeras.git
3332
tabulate
3433
tensorflow>=2.8.0,<=2.14.1
3534
tensorflow-model-optimization<=0.7.5

0 commit comments

Comments
 (0)