pyappify 1.0.9__tar.gz → 1.0.10__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.9
3
+ Version: 1.0.10
4
4
  Summary: My awesome Python application
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -58,13 +58,14 @@ except ImportError:
58
58
 
59
59
 
60
60
  def find_pyappify_executable(start_dir=None, environ=None):
61
- """Find the launcher configured by PyAppify or in a parent directory."""
61
+ """Find the configured launcher or an app launcher above ``working``."""
62
62
  environ = os.environ if environ is None else environ
63
63
  configured = environ.get("PYAPPIFY_EXECUTABLE")
64
64
  if configured:
65
65
  configured_path = Path(configured).expanduser()
66
66
  if configured_path.is_file():
67
67
  return str(configured_path.resolve())
68
+ return None
68
69
 
69
70
  current = Path(start_dir or os.getcwd()).expanduser()
70
71
  if current.is_file():
@@ -74,12 +75,52 @@ def find_pyappify_executable(start_dir=None, environ=None):
74
75
  except OSError:
75
76
  current = current.absolute()
76
77
 
77
- executable_names = ("pyappify.exe", "pyappify")
78
- for directory in (current,) + tuple(current.parents):
79
- for executable_name in executable_names:
80
- candidate = directory / executable_name
81
- if candidate.is_file():
82
- return str(candidate.resolve())
78
+ working_directory = next(
79
+ (
80
+ directory
81
+ for directory in (current,) + tuple(current.parents)
82
+ if directory.name.casefold() == "working" and directory.parent.name
83
+ ),
84
+ None,
85
+ )
86
+ if working_directory is None:
87
+ return None
88
+
89
+ app_name = working_directory.parent.name
90
+ apps_directory = working_directory.parent.parent
91
+ data_directory = apps_directory.parent
92
+ if apps_directory.name.casefold() != "apps" or data_directory.name.casefold() != "data":
93
+ return None
94
+
95
+ app_root = data_directory.parent
96
+ exact_launcher_name = "{} Launcher.exe".format(app_name).casefold()
97
+ search_directories = []
98
+ directory = working_directory
99
+ while True:
100
+ search_directories.append(directory)
101
+ if directory == app_root:
102
+ break
103
+ directory = directory.parent
104
+
105
+ for directory in search_directories:
106
+ try:
107
+ candidates = [
108
+ candidate
109
+ for candidate in directory.iterdir()
110
+ if candidate.is_file()
111
+ and candidate.suffix.casefold() == ".exe"
112
+ and candidate.name.casefold().startswith(app_name.casefold())
113
+ ]
114
+ except OSError:
115
+ continue
116
+ if candidates:
117
+ candidates.sort(
118
+ key=lambda candidate: (
119
+ candidate.name.casefold() != exact_launcher_name,
120
+ candidate.name.casefold(),
121
+ )
122
+ )
123
+ return str(candidates[0].resolve())
83
124
  return None
84
125
 
85
126
 
@@ -291,7 +332,8 @@ def _require_pyappify_executable():
291
332
  if not pyappify_executable:
292
333
  raise FileNotFoundError(
293
334
  "PyAppify executable was not found. Set PYAPPIFY_EXECUTABLE to an "
294
- "existing executable or place pyappify.exe in this directory or a parent directory."
335
+ "existing executable or place an executable whose name starts with the app name "
336
+ "in the working directory or a parent directory."
295
337
  )
296
338
  return pyappify_executable
297
339
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyappify
3
- Version: 1.0.9
3
+ Version: 1.0.10
4
4
  Summary: My awesome Python application
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "pyappify"
7
- version = "1.0.9"
7
+ version = "1.0.10"
8
8
  description = "My awesome Python application"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
File without changes
File without changes