batplot 1.4.8__tar.gz → 1.4.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {batplot-1.4.8 → batplot-1.4.9}/PKG-INFO +1 -1
- {batplot-1.4.8 → batplot-1.4.9}/batplot/__init__.py +1 -1
- {batplot-1.4.8 → batplot-1.4.9}/batplot/cli.py +9 -0
- batplot-1.4.9/batplot/version_check.py +132 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot.egg-info/PKG-INFO +1 -1
- {batplot-1.4.8 → batplot-1.4.9}/batplot.egg-info/SOURCES.txt +1 -0
- {batplot-1.4.8 → batplot-1.4.9}/pyproject.toml +1 -1
- {batplot-1.4.8 → batplot-1.4.9}/LICENSE +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/README.md +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/args.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/batch.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/batplot.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/batplot_new.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/cif.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/converters.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/cpc_interactive.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/electrochem_interactive.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/interactive.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/modes.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/operando.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/operando_ec_interactive.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/plotting.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/readers.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/session.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/style.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/ui.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot/utils.py +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot.egg-info/dependency_links.txt +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot.egg-info/entry_points.txt +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot.egg-info/requires.txt +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/batplot.egg-info/top_level.txt +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/setup.cfg +0 -0
- {batplot-1.4.8 → batplot-1.4.9}/setup.py +0 -0
|
@@ -17,6 +17,15 @@ def main(argv: Optional[list] = None) -> int:
|
|
|
17
17
|
Returns:
|
|
18
18
|
Exit code (0 for success, non-zero for error)
|
|
19
19
|
"""
|
|
20
|
+
# Check for updates (non-blocking, cached daily)
|
|
21
|
+
try:
|
|
22
|
+
from . import __version__
|
|
23
|
+
from .version_check import check_for_updates
|
|
24
|
+
check_for_updates(__version__)
|
|
25
|
+
except Exception:
|
|
26
|
+
# Silently ignore any errors in version checking
|
|
27
|
+
pass
|
|
28
|
+
|
|
20
29
|
# Import here to avoid side effects at module import time
|
|
21
30
|
if argv is not None:
|
|
22
31
|
# Temporarily replace sys.argv for argument parsing
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
"""Version checking utility for batplot.
|
|
2
|
+
|
|
3
|
+
Checks PyPI for newer versions and notifies users.
|
|
4
|
+
Caches the check result to avoid excessive API calls.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import os
|
|
8
|
+
import sys
|
|
9
|
+
import json
|
|
10
|
+
import time
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Optional, Tuple
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def get_cache_file() -> Path:
|
|
16
|
+
"""Get the path to the version check cache file."""
|
|
17
|
+
# Use user's cache directory
|
|
18
|
+
if sys.platform == 'win32':
|
|
19
|
+
cache_dir = Path(os.environ.get('LOCALAPPDATA', Path.home() / 'AppData' / 'Local')) / 'batplot'
|
|
20
|
+
elif sys.platform == 'darwin':
|
|
21
|
+
cache_dir = Path.home() / 'Library' / 'Caches' / 'batplot'
|
|
22
|
+
else: # Linux and other Unix-like
|
|
23
|
+
cache_dir = Path(os.environ.get('XDG_CACHE_HOME', Path.home() / '.cache')) / 'batplot'
|
|
24
|
+
|
|
25
|
+
cache_dir.mkdir(parents=True, exist_ok=True)
|
|
26
|
+
return cache_dir / 'version_check.json'
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def get_latest_version() -> Optional[str]:
|
|
30
|
+
"""Fetch the latest version from PyPI.
|
|
31
|
+
|
|
32
|
+
Returns:
|
|
33
|
+
Latest version string, or None if check fails
|
|
34
|
+
"""
|
|
35
|
+
try:
|
|
36
|
+
import urllib.request
|
|
37
|
+
import urllib.error
|
|
38
|
+
|
|
39
|
+
# Set a short timeout to avoid blocking
|
|
40
|
+
url = "https://pypi.org/pypi/batplot/json"
|
|
41
|
+
with urllib.request.urlopen(url, timeout=2) as response:
|
|
42
|
+
data = json.loads(response.read().decode())
|
|
43
|
+
return data['info']['version']
|
|
44
|
+
except Exception:
|
|
45
|
+
# Silently fail - don't interrupt user's work
|
|
46
|
+
return None
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def parse_version(version_str: str) -> Tuple[int, ...]:
|
|
50
|
+
"""Parse version string into tuple of integers for comparison.
|
|
51
|
+
|
|
52
|
+
Args:
|
|
53
|
+
version_str: Version string like "1.4.8"
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
Tuple of integers like (1, 4, 8)
|
|
57
|
+
"""
|
|
58
|
+
try:
|
|
59
|
+
return tuple(int(x) for x in version_str.split('.'))
|
|
60
|
+
except Exception:
|
|
61
|
+
return (0,)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def check_for_updates(current_version: str, force: bool = False) -> None:
|
|
65
|
+
"""Check if a newer version is available and notify user.
|
|
66
|
+
|
|
67
|
+
Args:
|
|
68
|
+
current_version: Current installed version
|
|
69
|
+
force: If True, ignore cache and always check
|
|
70
|
+
"""
|
|
71
|
+
# Allow disabling version check via environment variable
|
|
72
|
+
if os.environ.get('BATPLOT_NO_VERSION_CHECK', '').lower() in ('1', 'true', 'yes'):
|
|
73
|
+
return
|
|
74
|
+
|
|
75
|
+
cache_file = get_cache_file()
|
|
76
|
+
now = time.time()
|
|
77
|
+
|
|
78
|
+
# Check cache unless forced
|
|
79
|
+
if not force and cache_file.exists():
|
|
80
|
+
try:
|
|
81
|
+
with open(cache_file, 'r') as f:
|
|
82
|
+
cache = json.load(f)
|
|
83
|
+
# Check once per day (86400 seconds)
|
|
84
|
+
if now - cache.get('timestamp', 0) < 86400:
|
|
85
|
+
# Use cached result
|
|
86
|
+
latest = cache.get('latest_version')
|
|
87
|
+
if latest and parse_version(latest) > parse_version(current_version):
|
|
88
|
+
_print_update_message(current_version, latest)
|
|
89
|
+
return
|
|
90
|
+
except Exception:
|
|
91
|
+
# Cache read failed, continue to check
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
# Fetch latest version from PyPI
|
|
95
|
+
latest = get_latest_version()
|
|
96
|
+
|
|
97
|
+
# Update cache
|
|
98
|
+
try:
|
|
99
|
+
with open(cache_file, 'w') as f:
|
|
100
|
+
json.dump({
|
|
101
|
+
'timestamp': now,
|
|
102
|
+
'latest_version': latest,
|
|
103
|
+
'current_version': current_version
|
|
104
|
+
}, f)
|
|
105
|
+
except Exception:
|
|
106
|
+
# Cache write failed, not critical
|
|
107
|
+
pass
|
|
108
|
+
|
|
109
|
+
# Notify user if newer version available
|
|
110
|
+
if latest and parse_version(latest) > parse_version(current_version):
|
|
111
|
+
_print_update_message(current_version, latest)
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _print_update_message(current: str, latest: str) -> None:
|
|
115
|
+
"""Print update notification message.
|
|
116
|
+
|
|
117
|
+
Args:
|
|
118
|
+
current: Current version
|
|
119
|
+
latest: Latest available version
|
|
120
|
+
"""
|
|
121
|
+
print(f"\n\033[93m╭{'─' * 68}╮\033[0m")
|
|
122
|
+
print(f"\033[93m│\033[0m \033[1mA new version of batplot is available!\033[0m" + " " * 31 + "\033[93m│\033[0m")
|
|
123
|
+
print(f"\033[93m│\033[0m Current: \033[91m{current}\033[0m → Latest: \033[92m{latest}\033[0m" + " " * (42 - len(current) - len(latest)) + "\033[93m│\033[0m")
|
|
124
|
+
print(f"\033[93m│\033[0m Update with: \033[96mpip install --upgrade batplot\033[0m" + " " * 20 + "\033[93m│\033[0m")
|
|
125
|
+
print(f"\033[93m│\033[0m To disable this check: \033[96mexport BATPLOT_NO_VERSION_CHECK=1\033[0m" + " " * 7 + "\033[93m│\033[0m")
|
|
126
|
+
print(f"\033[93m╰{'─' * 68}╯\033[0m\n")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if __name__ == '__main__':
|
|
130
|
+
# Test the version checker
|
|
131
|
+
from batplot import __version__
|
|
132
|
+
check_for_updates(__version__, force=True)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "batplot"
|
|
7
|
-
version = "1.4.
|
|
7
|
+
version = "1.4.9"
|
|
8
8
|
description = "Interactive plotting for XRD, PDF, and XAS data (.xye, .xy, .qye, .dat, .csv, .gr, .nor, .chik, .chir)"
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Tian Dai", email = "tianda@uio.no" }
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|