Skip to content

Commit e2aa3b6

Browse files
fix m1 tf issue
1 parent 86612d7 commit e2aa3b6

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## Unreleased
44

5+
### Fixed
6+
7+
- Fix installation issue with tensorflow requirements on MACOS with M1 chip
8+
59
## 0.1.1
610

711
### Added

setup.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import setuptools
2+
import platform
3+
24
from tensorcircuit import __version__, __author__
35

46

57
with open("README.md", "r") as fh:
68
long_description = fh.read()
79

10+
install_requires = ["numpy", "scipy", "tensornetwork", "networkx"]
11+
12+
if platform.processor() != "arm":
13+
install_requires.append("tensorflow")
14+
# avoid the embarassing macos M1 chip case, where the package is called tensorflow-macos
815

916
setuptools.setup(
1017
name="tensorcircuit",
@@ -17,16 +24,16 @@
1724
url="https://github.com/refraction-ray/tensorcircuit",
1825
packages=setuptools.find_packages(),
1926
include_package_data=True,
20-
install_requires=["numpy", "scipy", "tensornetwork", "networkx", "tensorflow"],
27+
install_requires=install_requires,
2128
tests_require=[
2229
"pytest",
2330
"pytest-lazy-fixture",
2431
"pytest-cov",
2532
"pytest-benchmark",
2633
"pytest-xdist",
2734
],
28-
classifiers=(
35+
classifiers=[
2936
"Programming Language :: Python :: 3",
3037
"Operating System :: OS Independent",
31-
),
38+
],
3239
)

tensorcircuit/quantum.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -1377,11 +1377,10 @@ def ps2coo_core(
13771377
)
13781378
return tf.SparseTensor(indices=indices, values=values, dense_shape=(s, s)) # type: ignore
13791379

1380-
except NameError:
1380+
except (NameError, ImportError):
13811381
logger.warning(
13821382
"tensorflow is not installed, and sparse Hamiltonian generation utilities are disabled"
13831383
)
1384-
# TODO(@refraction-ray): backend agnostic sparse matrix generation?
13851384

13861385
# some quantum quatities below
13871386

0 commit comments

Comments
 (0)