pyappify 1.0.9__tar.gz → 1.0.11__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.11
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,37 @@ 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
+ executable_name = "{}.exe".format(app_name)
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
+ candidate = directory / executable_name
107
+ if candidate.is_file():
108
+ return str(candidate.resolve())
83
109
  return None
84
110
 
85
111
 
@@ -291,7 +317,8 @@ def _require_pyappify_executable():
291
317
  if not pyappify_executable:
292
318
  raise FileNotFoundError(
293
319
  "PyAppify executable was not found. Set PYAPPIFY_EXECUTABLE to an "
294
- "existing executable or place pyappify.exe in this directory or a parent directory."
320
+ "existing executable or place <app_name>.exe between the working directory "
321
+ "and the app root."
295
322
  )
296
323
  return pyappify_executable
297
324
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyappify
3
- Version: 1.0.9
3
+ Version: 1.0.11
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.11"
8
8
  description = "My awesome Python application"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.7"
File without changes
File without changes