Skip to content

Commit

Permalink
read version from _version.py file
Browse files Browse the repository at this point in the history
  • Loading branch information
eitanturok authored Jul 31, 2024
1 parent 461a402 commit f23c7ce
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
5 changes: 2 additions & 3 deletions llmfoundry/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
' in LLM Foundry setup.py and update accordingly. The latest Docker image can be found in the README.',
) from e

from llmfoundry._version import __version__
from llmfoundry.utils.logging_utils import SpecificWarningFilter

# Filter out Hugging Face warning for not using a pinned revision of the model
Expand Down Expand Up @@ -86,6 +87,4 @@
'optim',
'tokenizers',
'utils',
]

__version__ = '0.11.0.dev0'
]
6 changes: 6 additions & 0 deletions llmfoundry/_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright 2024 MosaicML LLM Foundry authors
# SPDX-License-Identifier: Apache-2.0

"""The LLM Foundry Version."""

__version__ = '0.10.0'
17 changes: 8 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import copy
import os
import re
from typing import Any, Dict, Mapping

import setuptools
from setuptools import setup
Expand All @@ -15,17 +16,15 @@
_REPO_REAL_PATH = os.path.dirname(os.path.realpath(__file__))
_PACKAGE_REAL_PATH = os.path.join(_REPO_REAL_PATH, _PACKAGE_DIR)

# Read the repo version
# Read the composer version
# We can't use `.__version__` from the library since it's not installed yet
with open(os.path.join(_PACKAGE_REAL_PATH, '__init__.py')) as f:
version_path = os.path.join(_PACKAGE_REAL_PATH, '_version.py')
with open(version_path, encoding='utf-8') as f:
version_globals: Dict[str, Any] = {}
version_locals: Mapping[str, object] = {}
content = f.read()
# regex: '__version__', whitespace?, '=', whitespace, quote, version, quote
# we put parens around the version so that it becomes elem 1 of the match
expr = re.compile(
r"""^__version__\s*=\s*['"]([0-9]+\.[0-9]+\.[0-9]+(?:\.\w+)?)['"]""",
re.MULTILINE,
)
repo_version = expr.findall(content)[0]
exec(content, version_globals, version_locals)
repo_version = version_locals['__version__']

# Use repo README for PyPi description
with open('README.md', 'r', encoding='utf-8') as fh:
Expand Down

0 comments on commit f23c7ce

Please sign in to comment.