Skip to content

Commit

Permalink
fix(build): support pyproject version
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Nov 15, 2023
1 parent 2ec0c0a commit 6fdc75f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion bench/utils/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import re
import sys
import subprocess
import importlib.metadata
from typing import List
from functools import lru_cache

Expand Down Expand Up @@ -270,12 +271,22 @@ def check_existing_dir(bench_path, repo_name):
def get_current_version(app, bench_path="."):
current_version = None
repo_dir = get_repo_dir(app, bench_path=bench_path)
pyproject_path = os.path.join(repo_dir, "pyproject.toml")
config_path = os.path.join(repo_dir, "setup.cfg")
init_path = os.path.join(repo_dir, os.path.basename(repo_dir), "__init__.py")
setup_path = os.path.join(repo_dir, "setup.py")

try:
if os.path.exists(config_path):
if os.path.exists(pyproject_path):
try:
from tomli import load
except ImportError:
from tomllib import load

with open(pyproject_path, "rb") as f:
current_version = load(f).get("project", {}).get("version")

if not current_version and os.path.exists(config_path):
from setuptools.config import read_configuration

config = read_configuration(config_path)
Expand Down

0 comments on commit 6fdc75f

Please sign in to comment.