Skip to content

Commit

Permalink
Merge pull request #1145 from vloncar/qkeras_install_hook
Browse files Browse the repository at this point in the history
Temporary workaround for QKeras installation
  • Loading branch information
JanFSchulte authored Dec 9, 2024
2 parents cfcd46c + 5dd7715 commit cc4fbf9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
32 changes: 31 additions & 1 deletion hls4ml/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,34 @@
from hls4ml import converters, report, utils # noqa: F401
# Temporary workaround for QKeras installation requirement, will be removed after 1.0.0
def maybe_install_qkeras():
import subprocess
import sys

QKERAS_PKG_NAME = 'QKeras'
# QKERAS_PKG_SOURCE = QKERAS_PKG_NAME
QKERAS_PKG_SOURCE = 'qkeras@git+https://github.com/fastmachinelearning/qkeras.git'

def pip_list():
p = subprocess.run([sys.executable, '-m', 'pip', 'list'], check=True, capture_output=True)
return p.stdout.decode()

def pip_install(package):
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])

all_pkgs = pip_list()
if QKERAS_PKG_NAME not in all_pkgs:
print('QKeras installation not found, installing one...')
pip_install(QKERAS_PKG_SOURCE)
print('QKeras installed.')


try:
maybe_install_qkeras()
except Exception:
print('Could not find QKeras installation, make sure you have QKeras installed.')

# End of workaround

from hls4ml import converters, report, utils # noqa: F401, E402

try:
from ._version import version as __version__
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ install_requires =
pydigitalwavetools==1.1
pyparsing
pyyaml
qkeras@git+https://github.com/google/qkeras.git
tabulate
tensorflow>=2.8.0,<=2.14.1
tensorflow-model-optimization<=0.7.5
Expand Down

0 comments on commit cc4fbf9

Please sign in to comment.