pyappify 1.0.0__tar.gz → 1.0.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyappify
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: My awesome Python application
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -74,7 +74,7 @@ def hide_pyappify():
74
74
  pass
75
75
 
76
76
  def upgrade(to_version, executable_sha256, executable_zip_urls, stop_event=None):
77
- if not pyappify_upgradeable or (to_version and pyappify_version and to_version.lstrip('v') == pyappify_version.lstrip('v')):
77
+ if not pyappify_upgradeable or not is_greater_version(to_version, pyappify_version):
78
78
  if logger:
79
79
  logger.info(f"pyappify no need to upgrade {pyappify_upgradeable} {to_version} {executable_sha256} {executable_zip_urls}")
80
80
  return
@@ -137,7 +137,7 @@ def upgrade(to_version, executable_sha256, executable_zip_urls, stop_event=None)
137
137
  for byte_block in iter(lambda: f.read(4096), b""):
138
138
  sha256_hash.update(byte_block)
139
139
 
140
- if sha256_hash.hexdigest() != executable_sha256:
140
+ if executable_sha256 and sha256_hash.hexdigest() != executable_sha256:
141
141
  if logger:
142
142
  logger.error("pyappify SHA256 checksum mismatch.")
143
143
  return
@@ -155,4 +155,25 @@ def upgrade(to_version, executable_sha256, executable_zip_urls, stop_event=None)
155
155
 
156
156
  thread = threading.Thread(target=_do_upgrade)
157
157
  thread.daemon = True
158
- thread.start()
158
+ thread.start()
159
+
160
+ def is_greater_version(version1, version2):
161
+ """
162
+ Compares two semantic version strings.
163
+
164
+ Args:
165
+ version1 (str): The first version string.
166
+ version2 (str): The second version string.
167
+
168
+ Returns:
169
+ bool: True if version1 is strictly greater than version2,
170
+ False otherwise or if parsing fails.
171
+ """
172
+ try:
173
+ version1 = version1.lstrip('v')
174
+ version2 = version2.lstrip('v')
175
+ v1_parts = [int(p) for p in version1.split('.')]
176
+ v2_parts = [int(p) for p in version2.split('.')]
177
+ return v1_parts > v2_parts
178
+ except (ValueError, AttributeError):
179
+ return False
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyappify
3
- Version: 1.0.0
3
+ Version: 1.0.2
4
4
  Summary: My awesome Python application
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -6,4 +6,5 @@ pyappify.egg-info/SOURCES.txt
6
6
  pyappify.egg-info/dependency_links.txt
7
7
  pyappify.egg-info/entry_points.txt
8
8
  pyappify.egg-info/requires.txt
9
- pyappify.egg-info/top_level.txt
9
+ pyappify.egg-info/top_level.txt
10
+ tests/TestVersion.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyappify"
7
- version = "1.0.0"
7
+ version = "1.0.2"
8
8
  description = "My awesome Python application"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
@@ -0,0 +1,33 @@
1
+ # filename: test_pyappify.is_greater_version.py
2
+ import unittest
3
+ import pyappify
4
+
5
+ class TestIsGreaterVersion(unittest.TestCase):
6
+
7
+ def test_version1_is_greater(self):
8
+ self.assertTrue(pyappify.is_greater_version("2.0.0", "1.9.9"))
9
+ self.assertTrue(pyappify.is_greater_version("1.2.0", "v1.1.9"))
10
+ self.assertTrue(pyappify.is_greater_version("v1.1.2", "1.1.1"))
11
+ self.assertTrue(pyappify.is_greater_version("1.1.0", "1.1"))
12
+ self.assertTrue(pyappify.is_greater_version("v10.0.0", "9.0.0"))
13
+
14
+ def test_version1_is_not_greater(self):
15
+ self.assertFalse(pyappify.is_greater_version("v1.0.0", "2.0.0"))
16
+ self.assertFalse(pyappify.is_greater_version("1.1.0", "v1.2.0"))
17
+ self.assertFalse(pyappify.is_greater_version("1.1.1", "1.1.2"))
18
+ self.assertFalse(pyappify.is_greater_version("1.1", "1.1.0"))
19
+
20
+ def test_versions_are_equal(self):
21
+ self.assertFalse(pyappify.is_greater_version("qwer", "1.0.0"))
22
+ self.assertFalse(pyappify.is_greater_version("1.2.3", "1.2.3"))
23
+
24
+ def test_invalid_or_edge_cases(self):
25
+ self.assertFalse(pyappify.is_greater_version(None, "1.0.0"))
26
+ self.assertFalse(pyappify.is_greater_version("1.0.0", None))
27
+ self.assertFalse(pyappify.is_greater_version(None, None))
28
+ self.assertFalse(pyappify.is_greater_version("v1.a.0", "1.0.0"))
29
+ self.assertFalse(pyappify.is_greater_version("1.0.0", "invalid"))
30
+ self.assertFalse(pyappify.is_greater_version("", "1.0.0"))
31
+
32
+ if __name__ == '__main__':
33
+ unittest.main(argv=['first-arg-is-ignored'], exit=False)
File without changes
File without changes