Skip to content

Commit

Permalink
fix: make watermark package optional
Browse files Browse the repository at this point in the history
  • Loading branch information
mwong009 committed Jun 19, 2024
1 parent cae7f96 commit 9a56fc5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
31 changes: 23 additions & 8 deletions pycmtensor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,9 @@
__author__ = """Melvin Wong"""
__version__ = "1.12.0"

import importlib

import aesara
from watermark import watermark

import pycmtensor.defaultconfig as defaultconfig
import pycmtensor.optimizers as optimizers
Expand Down Expand Up @@ -117,10 +118,24 @@

def about():
"""Returns a `watermark.watermark` of various system information for debugging"""
return watermark(
python=True,
datename=True,
updated=True,
packages="pycmtensor,aesara,numpy,scipy",
machine=True,
)

def import_watermark():
try:
importlib.import_module("watermark")
return True
except ImportError:
return False

if import_watermark():
from watermark import watermark

return watermark(
python=True,
datename=True,
updated=True,
packages="pycmtensor,aesara,numpy,scipy",
machine=True,
)
else:
print("{0:11}: {1}".format("pycmtensor", __version__))
print("{0:11}: {1}".format("aesara", aesara.__version__))
12 changes: 5 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,18 @@ classifiers = [
"Operating System :: OS Independent",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.9",
]

[tool.poetry.dependencies]
python = ">=3.9,<3.13"
python = "<3.12"
aesara = "2.9.3"
numpy = "<1.26.0"
scipy = "<1.12.0"
pandas = "<2.1.0"
seaborn = "<0.14.0"
watermark = "2.4.3"
numpy = "1.25.2"
scipy = "1.13.1"
pandas = "2.2.2"
seaborn = "0.13.2"

[tool.poetry.group.docs]
optional = true
Expand Down

0 comments on commit 9a56fc5

Please sign in to comment.