Skip to content

Commit

Permalink
Update setup.py
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegmd committed Feb 7, 2024
1 parent 4609e3b commit 73e72db
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""setup.py for axolotl"""

import platform
import re
from importlib.metadata import PackageNotFoundError, version

from packaging.version import Version, parse
from setuptools import find_packages, setup


Expand Down Expand Up @@ -31,10 +31,20 @@ def parse_requirements():
if "Darwin" in platform.system():
_install_requires.pop(_install_requires.index("xformers==0.0.22"))
else:
torch_version = parse(version("torch"))
torch_version = version("torch")
_install_requires.append(f"torch=={torch_version}")

if torch_version >= Version("2.1"):
version_match = re.match(r"^(\d+)\.(\d+)(?:\.(\d+))?", torch_version)
if version_match:
major, minor, patch = version_match.groups()
major, minor = int(major), int(minor)
patch = (
int(patch) if patch is not None else 0
) # Default patch to 0 if not present
else:
raise ValueError("Invalid version format")

if (major, minor) >= (2, 1):
_install_requires.pop(_install_requires.index("xformers==0.0.22"))
_install_requires.append("xformers>=0.0.23")
except PackageNotFoundError:
Expand Down

0 comments on commit 73e72db

Please sign in to comment.