-
Notifications
You must be signed in to change notification settings - Fork 620
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add version metadata and --version command
- Loading branch information
Showing
4 changed files
with
29 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import os | ||
import sys | ||
from importlib.metadata import version, PackageNotFoundError | ||
|
||
from pr_agent.log import get_logger | ||
|
||
def get_version() -> str: | ||
# First check pyproject.toml if running directly out of repository | ||
if os.path.exists("pyproject.toml"): | ||
if sys.version_info >= (3, 11): | ||
import tomllib | ||
with open("pyproject.toml", "rb") as f: | ||
data = tomllib.load(f) | ||
return data["project"]["version"] | ||
else: | ||
get_logger().error("Unable to determine local version from pyproject.toml") | ||
|
||
# Otherwise get the installed pip package version | ||
try: | ||
return version('pr-agent') | ||
except PackageNotFoundError: | ||
get_logger().error("Unable to find package named 'pr-agent'") | ||
return "unknown" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" | |
|
||
[project] | ||
name = "pr-agent" | ||
version = "0.2.4" | ||
version = "0.2.6" | ||
|
||
authors = [{ name = "CodiumAI", email = "[email protected]" }] | ||
|
||
|