File tree Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Expand file tree Collapse file tree 4 files changed +12
-8
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 10
10
class Toolbar :
11
11
def __init__ (self , request ):
12
12
self .request = request
13
- self .version = settings .ADMIN_TOOLBAR_VERSION
13
+ self .version = settings .APP_VERSION
14
14
15
15
def should_render (self ):
16
16
if settings .DEBUG :
Original file line number Diff line number Diff line change 3
3
by the PLAIN_SETTINGS_MODULE environment variable.
4
4
"""
5
5
6
- from .utils import get_app_name_from_pyproject
6
+ from .utils import get_app_info_from_pyproject
7
7
8
8
# MARK: Core Settings
9
9
10
10
DEBUG : bool = False
11
11
12
- APP_NAME : str = get_app_name_from_pyproject ()
12
+ name , version = get_app_info_from_pyproject ()
13
+ APP_NAME : str = name
14
+ APP_VERSION : str = version
13
15
14
16
# List of strings representing installed packages.
15
17
INSTALLED_PACKAGES : list [str ] = []
Original file line number Diff line number Diff line change 2
2
from pathlib import Path
3
3
4
4
5
- def get_app_name_from_pyproject ():
6
- """Get the project name from the nearest pyproject.toml file."""
5
+ def get_app_info_from_pyproject ():
6
+ """Get the project name and version from the nearest pyproject.toml file."""
7
7
current_path = Path .cwd ()
8
8
9
9
# Walk up the directory tree looking for pyproject.toml
@@ -13,8 +13,11 @@ def get_app_name_from_pyproject():
13
13
try :
14
14
with pyproject_path .open ("rb" ) as f :
15
15
pyproject = tomllib .load (f )
16
- return pyproject .get ("project" , {}).get ("name" , "App" )
16
+ project = pyproject .get ("project" , {})
17
+ name = project .get ("name" , "App" )
18
+ version = project .get ("version" , "dev" )
19
+ return name , version
17
20
except (tomllib .TOMLDecodeError , OSError ):
18
21
continue
19
22
20
- return "App"
23
+ return "App" , "dev"
You can’t perform that action at this time.
0 commit comments