Skip to content

Commit

Permalink
build: better communicate lack of support for Python 3.11
Browse files Browse the repository at this point in the history
  • Loading branch information
brycedrennan committed Sep 9, 2023
1 parent 1354cb9 commit 477d161
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ autoformat: ## Run the autoformatter.
@# ERA,T201
@-ruff --extend-ignore ANN,ARG001,C90,DTZ,D100,D101,D102,D103,D202,D203,D212,D415,E501,RET504,S101,UP006,UP007 --extend-select C,D400,I,W --unfixable T,ERA --fix-only .
@black .
@isort --atomic --profile black .
@isort --atomic --profile black --skip downloads/** .

test: ## Run the tests.
@pytest
Expand Down
11 changes: 11 additions & 0 deletions imaginairy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@
# tells pytorch to allow MPS usage (for Mac M1 compatibility)
os.putenv("PYTORCH_ENABLE_MPS_FALLBACK", "1")

import sys # noqa

from .api import imagine, imagine_image_files # noqa
from .schema import ( # noqa
ImaginePrompt,
ImagineResult,
LazyLoadingImage,
WeightedPrompt,
)

# if python version is 3.11 or higher, throw an exception
if sys.version_info >= (3, 11):
msg = (
"Imaginairy is not compatible with Python 3.11 or higher. Please use Python 3.8 - 3.10.\n"
"This is due to torch 1.13 not supporting Python 3.11 and this library not having yet switched "
"to torch 2.0"
)
raise RuntimeError(msg)
7 changes: 5 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def get_git_revision_hash() -> str:
"uvicorn>=0.16.0",
"xformers>=0.0.16; sys_platform!='darwin' and platform_machine!='aarch64'",
],
# torchvision doesn't support python 3.11 unless we switch to torch 2.0
python_requires=">=3.8,<3.11",
# don't specify maximum python versions as it can cause very long dependency resolution issues as the resolver
# goes back to older versions of packages that didn't specify a maximum
# https://discuss.python.org/t/requires-python-upper-limits/12663/75
# https://github.com/brycedrennan/imaginAIry/pull/341#issuecomment-1574723908
python_requires=">=3.8",
)

0 comments on commit 477d161

Please sign in to comment.