Skip to content

Commit

Permalink
Use importlib.metadata to surface Basilisp version (#743)
Browse files Browse the repository at this point in the history
Fixes #617
  • Loading branch information
chrisrink10 authored Dec 27, 2023
1 parent 67987ab commit 0cd8ab7
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* Fixed issue with import modules aliasing using ns eval (#719)
* Fix issue with `ns-resolve` throwing an error on macros (#720)
* Fix issue with py module `readerwritelock` locks handling (#722)
* Fix issue with basilisp.io/writer :append mode not working (#741).
* Fix issue with basilisp.io/writer :append mode not working (#741)

### Removed
* Removed the dependency `astor` for versions of Python 3.9+ (#736)
* Removed `basilisp.__version__` in favor of using `importlib.metadata` for version info (#617)

## [v0.1.0a2]
### Added
Expand Down
3 changes: 0 additions & 3 deletions src/basilisp/__version__.py

This file was deleted.

7 changes: 3 additions & 4 deletions src/basilisp/cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import argparse
import importlib
import importlib.metadata
import io
import os
import sys
Expand Down Expand Up @@ -430,9 +430,8 @@ def _add_test_subcommand(parser: argparse.ArgumentParser) -> None:


def version(_, __):
from basilisp.__version__ import __version__

print(f"Basilisp {__version__}")
v = importlib.metadata.version("basilisp")
print(f"Basilisp {v}")


@_subcommand("version", help="print the version of Basilisp", handler=version)
Expand Down
10 changes: 6 additions & 4 deletions src/basilisp/lang/runtime.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import contextlib
import decimal
import functools
import importlib
import importlib.metadata
import inspect
import itertools
import logging
Expand Down Expand Up @@ -72,6 +72,10 @@
NS_VAR_NS = CORE_NS
REPL_DEFAULT_NS = "basilisp.user"
SUPPORTED_PYTHON_VERSIONS = frozenset({(3, 8), (3, 9), (3, 10), (3, 11), (3, 12)})
BASILISP_VERSION_STRING = importlib.metadata.version("basilisp")
BASILISP_VERSION = vec.vector(
(int(s) if s.isdigit() else s) for s in BASILISP_VERSION_STRING.split(".")
)

# Public basilisp.core symbol names
COMPILER_OPTIONS_VAR_NAME = "*compiler-options*"
Expand Down Expand Up @@ -2118,8 +2122,6 @@ def in_ns(s: sym.Symbol):
)

# Version info
from basilisp.__version__ import VERSION

Var.intern(
CORE_NS_SYM,
sym.symbol(PYTHON_VERSION_VAR_NAME),
Expand All @@ -2137,7 +2139,7 @@ def in_ns(s: sym.Symbol):
Var.intern(
CORE_NS_SYM,
sym.symbol(BASILISP_VERSION_VAR_NAME),
vec.vector(VERSION),
BASILISP_VERSION,
dynamic=True,
meta=lmap.map(
{
Expand Down

0 comments on commit 0cd8ab7

Please sign in to comment.