Skip to content

Commit

Permalink
Read version info from generated-version.py if it exists (neuralmagic#80
Browse files Browse the repository at this point in the history
)
  • Loading branch information
bnellnm authored Apr 12, 2021
1 parent f415a42 commit 9ba9248
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -765,4 +765,4 @@ MigrationBackup/

licenses/
engine-version.txt
src/deepsparse/version.py
src/deepsparse/generated-version.py
2 changes: 1 addition & 1 deletion src/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ deepsparse/avx2/
deepsparse/avx512/
arch.bin
cpu.py
version.py
generated-version.py
43 changes: 26 additions & 17 deletions src/deepsparse/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,33 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import os


"""
Placeholder file, will be overwritten by the backend on build.
Functionality for storing and setting the version info for DeepSparse
Functionality for storing and setting the version info for DeepSparse. If
a file named 'generated-version.py' exists, read version info from there, otherwise
fall back to defaults.
"""

__all__ = [
"__version__",
"version",
"version_major",
"version_minor",
"version_bug",
"version_build",
"version_major_minor",
]
__version__ = "0.2.0"
version_file = os.path.join("src", "deepsparse", "generated-version.py")

if os.path.isfile(version_file):
exec(open(version_file).read())
else:
__all__ = [
"__version__",
"version",
"version_major",
"version_minor",
"version_bug",
"version_build",
"version_major_minor",
]
__version__ = "0.2.0"

version = __version__
version_major, version_minor, version_bug, version_build = version.split(".") + (
[None] if len(version.split(".")) < 4 else []
) # handle conditional for version being 3 parts or 4 (4 containing build date)
version_major_minor = f"{version_major}.{version_minor}"
version = __version__
version_major, version_minor, version_bug, version_build = version.split(".") + (
[None] if len(version.split(".")) < 4 else []
) # handle conditional for version being 3 parts or 4 (4 containing build date)
version_major_minor = f"{version_major}.{version_minor}"

0 comments on commit 9ba9248

Please sign in to comment.