python-project-doctor-cli 0.1.0__py3-none-any.whl
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.
- main.py +305 -0
- python_project_doctor_cli-0.1.0.dist-info/METADATA +298 -0
- python_project_doctor_cli-0.1.0.dist-info/RECORD +7 -0
- python_project_doctor_cli-0.1.0.dist-info/WHEEL +5 -0
- python_project_doctor_cli-0.1.0.dist-info/entry_points.txt +2 -0
- python_project_doctor_cli-0.1.0.dist-info/licenses/LICENSE +21 -0
- python_project_doctor_cli-0.1.0.dist-info/top_level.txt +1 -0
main.py
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"""Minimal command-line entry point for pyenv-doctor."""
|
|
2
|
+
|
|
3
|
+
import argparse
|
|
4
|
+
import json
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# These files are the simplest markers for a Python project in this MVP.
|
|
11
|
+
PROJECT_MARKER_FILES = [
|
|
12
|
+
"requirements.txt",
|
|
13
|
+
"pyproject.toml",
|
|
14
|
+
"setup.py",
|
|
15
|
+
"setup.cfg",
|
|
16
|
+
"Pipfile",
|
|
17
|
+
"poetry.lock",
|
|
18
|
+
"uv.lock",
|
|
19
|
+
"environment.yml",
|
|
20
|
+
".python-version",
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class JsonAwareArgumentParser(argparse.ArgumentParser):
|
|
25
|
+
"""Argument parser that can return JSON-formatted errors when requested."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, *args, **kwargs) -> None:
|
|
28
|
+
"""Create the parser and remember whether JSON mode is requested."""
|
|
29
|
+
super().__init__(*args, **kwargs)
|
|
30
|
+
self.json_output = False
|
|
31
|
+
|
|
32
|
+
def error(self, message: str) -> None:
|
|
33
|
+
"""Print a JSON error instead of plain text when JSON mode is enabled."""
|
|
34
|
+
if self.json_output:
|
|
35
|
+
print_json_result(build_result(error=f"Argument error: {message}"))
|
|
36
|
+
raise SystemExit(2)
|
|
37
|
+
|
|
38
|
+
super().error(message)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def build_parser() -> JsonAwareArgumentParser:
|
|
42
|
+
"""Create the command-line argument parser."""
|
|
43
|
+
parser = JsonAwareArgumentParser(
|
|
44
|
+
prog="pyenv-doctor",
|
|
45
|
+
description="Scan a directory and check whether it looks like a Python project.",
|
|
46
|
+
)
|
|
47
|
+
# This optional path keeps the CLI simple: no argument means current directory.
|
|
48
|
+
parser.add_argument(
|
|
49
|
+
"path",
|
|
50
|
+
nargs="?",
|
|
51
|
+
help="Optional directory path to scan. If omitted, the current directory is used.",
|
|
52
|
+
)
|
|
53
|
+
# This flag switches the output from human-readable text to structured JSON.
|
|
54
|
+
parser.add_argument(
|
|
55
|
+
"--json",
|
|
56
|
+
action="store_true",
|
|
57
|
+
help="Print the result as JSON.",
|
|
58
|
+
)
|
|
59
|
+
return parser
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def get_scan_path(path_argument: str | None) -> tuple[Path | None, str | None, str | None]:
|
|
63
|
+
"""Return the scan path, an optional error message, and the displayed path string."""
|
|
64
|
+
# If no path was provided, keep the original behavior and scan the current directory.
|
|
65
|
+
if path_argument is None:
|
|
66
|
+
scan_path = Path.cwd().resolve()
|
|
67
|
+
return scan_path, None, str(scan_path)
|
|
68
|
+
|
|
69
|
+
# Expand user input so paths like `~` work on supported systems.
|
|
70
|
+
scan_path = Path(path_argument).expanduser()
|
|
71
|
+
|
|
72
|
+
# Return a clear error when the path does not exist.
|
|
73
|
+
if not scan_path.exists():
|
|
74
|
+
return None, f"Error: path does not exist: {scan_path}", str(scan_path)
|
|
75
|
+
|
|
76
|
+
# Return a clear error when the path exists but is not a directory.
|
|
77
|
+
if not scan_path.is_dir():
|
|
78
|
+
return None, f"Error: path is not a directory: {scan_path}", str(scan_path)
|
|
79
|
+
|
|
80
|
+
# Resolve the final directory so the output shows a clear absolute path.
|
|
81
|
+
resolved_path = scan_path.resolve()
|
|
82
|
+
return resolved_path, None, str(resolved_path)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def find_marker_files(scan_path: Path) -> list[str]:
|
|
86
|
+
"""Return the project marker files found in the current directory."""
|
|
87
|
+
found_files: list[str] = []
|
|
88
|
+
|
|
89
|
+
# Check each file one by one so the logic stays easy to read.
|
|
90
|
+
for file_name in PROJECT_MARKER_FILES:
|
|
91
|
+
if (scan_path / file_name).is_file():
|
|
92
|
+
found_files.append(file_name)
|
|
93
|
+
|
|
94
|
+
return found_files
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def is_virtual_environment_detected() -> bool:
|
|
98
|
+
"""Return True when the current Python looks like it runs in a virtual environment."""
|
|
99
|
+
# Conda usually exposes these environment variables when an environment is active.
|
|
100
|
+
if os.environ.get("CONDA_PREFIX") or os.environ.get("CONDA_DEFAULT_ENV"):
|
|
101
|
+
return True
|
|
102
|
+
|
|
103
|
+
# venv changes sys.prefix while keeping the original value in sys.base_prefix.
|
|
104
|
+
if getattr(sys, "base_prefix", sys.prefix) != sys.prefix:
|
|
105
|
+
return True
|
|
106
|
+
|
|
107
|
+
# Older virtualenv versions may set sys.real_prefix.
|
|
108
|
+
if hasattr(sys, "real_prefix"):
|
|
109
|
+
return True
|
|
110
|
+
|
|
111
|
+
return False
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def build_suggestions(
|
|
115
|
+
found_files: list[str] | None = None,
|
|
116
|
+
error: str | None = None,
|
|
117
|
+
virtual_environment_detected: bool = False,
|
|
118
|
+
) -> list[str]:
|
|
119
|
+
"""Build a short list of beginner-friendly next steps."""
|
|
120
|
+
detected_files = found_files if found_files is not None else []
|
|
121
|
+
|
|
122
|
+
# Error suggestions should stay focused on fixing the immediate problem first.
|
|
123
|
+
if error is not None:
|
|
124
|
+
if "path does not exist" in error:
|
|
125
|
+
return ["Check the path spelling and try again."]
|
|
126
|
+
if "path is not a directory" in error:
|
|
127
|
+
return ["Pass the project directory path instead of a single file."]
|
|
128
|
+
if "Argument error:" in error:
|
|
129
|
+
return ["Run pyenv-doctor --help to review the available arguments."]
|
|
130
|
+
return []
|
|
131
|
+
|
|
132
|
+
suggestions: list[str] = []
|
|
133
|
+
|
|
134
|
+
# If nothing was detected, the safest first step is to confirm the scan location.
|
|
135
|
+
if not detected_files:
|
|
136
|
+
suggestions.append("Verify that you are scanning the project root directory.")
|
|
137
|
+
|
|
138
|
+
# pyproject.toml often defines the project's preferred install and run workflow.
|
|
139
|
+
if "pyproject.toml" in detected_files:
|
|
140
|
+
suggestions.append("Open pyproject.toml to check how this project should be installed or run.")
|
|
141
|
+
|
|
142
|
+
# Pipfile usually means the project expects a Pipenv-style workflow.
|
|
143
|
+
if "Pipfile" in detected_files:
|
|
144
|
+
suggestions.append("Open Pipfile to review the project's dependencies and environment settings.")
|
|
145
|
+
|
|
146
|
+
# poetry.lock usually appears in Poetry-based projects.
|
|
147
|
+
if "poetry.lock" in detected_files:
|
|
148
|
+
suggestions.append("If this project uses Poetry, review pyproject.toml and try poetry install.")
|
|
149
|
+
|
|
150
|
+
# uv.lock usually appears in uv-managed projects.
|
|
151
|
+
if "uv.lock" in detected_files:
|
|
152
|
+
suggestions.append("If this project uses uv, review the project instructions and try uv sync.")
|
|
153
|
+
|
|
154
|
+
# environment.yml usually points to a Conda environment definition.
|
|
155
|
+
if "environment.yml" in detected_files:
|
|
156
|
+
suggestions.append("If this project uses Conda, create the environment from environment.yml before running it.")
|
|
157
|
+
|
|
158
|
+
# .python-version often records the expected Python version for the project.
|
|
159
|
+
if ".python-version" in detected_files:
|
|
160
|
+
suggestions.append("Check .python-version to see which Python version this project expects.")
|
|
161
|
+
|
|
162
|
+
# Only suggest a virtual environment when one is not already active.
|
|
163
|
+
if "requirements.txt" in detected_files and not virtual_environment_detected:
|
|
164
|
+
suggestions.append("Create and activate a virtual environment before installing dependencies.")
|
|
165
|
+
|
|
166
|
+
return suggestions
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def build_result(
|
|
170
|
+
scanned_directory: str | None = None,
|
|
171
|
+
found_files: list[str] | None = None,
|
|
172
|
+
error: str | None = None,
|
|
173
|
+
virtual_environment_detected: bool | None = None,
|
|
174
|
+
) -> dict[str, object]:
|
|
175
|
+
"""Build a structured result that works for both text and JSON output."""
|
|
176
|
+
# Default to an empty list so the JSON structure stays predictable.
|
|
177
|
+
detected_files = found_files if found_files is not None else []
|
|
178
|
+
env_detected = (
|
|
179
|
+
virtual_environment_detected
|
|
180
|
+
if virtual_environment_detected is not None
|
|
181
|
+
else is_virtual_environment_detected()
|
|
182
|
+
)
|
|
183
|
+
suggestions = build_suggestions(
|
|
184
|
+
found_files=detected_files,
|
|
185
|
+
error=error,
|
|
186
|
+
virtual_environment_detected=env_detected,
|
|
187
|
+
)
|
|
188
|
+
|
|
189
|
+
return {
|
|
190
|
+
"scanned_directory": scanned_directory,
|
|
191
|
+
"found_files": detected_files,
|
|
192
|
+
"looks_like_python_project": bool(detected_files),
|
|
193
|
+
"virtual_environment_detected": env_detected,
|
|
194
|
+
"error": error,
|
|
195
|
+
"suggestions": suggestions,
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def print_json_result(result: dict[str, object]) -> None:
|
|
200
|
+
"""Print a JSON result with stable formatting for humans and scripts."""
|
|
201
|
+
# Indented JSON stays readable while still being valid machine output.
|
|
202
|
+
print(json.dumps(result, indent=2))
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def print_project_result(scan_path: Path, found_files: list[str]) -> None:
|
|
206
|
+
"""Print the project file detection result in a clear format."""
|
|
207
|
+
print(f"Scanned directory: {scan_path}")
|
|
208
|
+
print()
|
|
209
|
+
print("Project file detection:")
|
|
210
|
+
|
|
211
|
+
# Print the status for every marker file in a fixed order.
|
|
212
|
+
for file_name in PROJECT_MARKER_FILES:
|
|
213
|
+
status = "found" if file_name in found_files else "not found"
|
|
214
|
+
print(f"- {file_name}: {status}")
|
|
215
|
+
|
|
216
|
+
print()
|
|
217
|
+
|
|
218
|
+
# If at least one marker file exists, the directory probably is a Python project.
|
|
219
|
+
if found_files:
|
|
220
|
+
print("Conclusion: this looks like a Python project")
|
|
221
|
+
print(f"Reason: detected {', '.join(found_files)}")
|
|
222
|
+
else:
|
|
223
|
+
print("Conclusion: no clear Python project markers were found")
|
|
224
|
+
print("Details: common Python project files were not found in this directory.")
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
def print_virtual_environment_result(virtual_environment_detected: bool) -> None:
|
|
228
|
+
"""Print the virtual environment detection result."""
|
|
229
|
+
print()
|
|
230
|
+
print("Virtual environment detection:")
|
|
231
|
+
|
|
232
|
+
if virtual_environment_detected:
|
|
233
|
+
print("Virtual environment: detected")
|
|
234
|
+
else:
|
|
235
|
+
print("Virtual environment: not detected")
|
|
236
|
+
print("Recommendation: use venv or Conda for an isolated Python environment")
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def print_suggestions(suggestions: list[str], stream=None) -> None:
|
|
240
|
+
"""Print a short suggestions section after the main result."""
|
|
241
|
+
output_stream = stream if stream is not None else sys.stdout
|
|
242
|
+
print(file=output_stream)
|
|
243
|
+
print("Suggestions:", file=output_stream)
|
|
244
|
+
|
|
245
|
+
if not suggestions:
|
|
246
|
+
print("- No immediate suggestions.", file=output_stream)
|
|
247
|
+
return
|
|
248
|
+
|
|
249
|
+
# Keep each suggestion short and actionable for beginners.
|
|
250
|
+
for suggestion in suggestions:
|
|
251
|
+
print(f"- {suggestion}", file=output_stream)
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
def main(argv: list[str] | None = None) -> int:
|
|
255
|
+
"""Run the program and return an exit code."""
|
|
256
|
+
# Allow tests and the console script to pass arguments explicitly when needed.
|
|
257
|
+
arguments = argv if argv is not None else sys.argv[1:]
|
|
258
|
+
|
|
259
|
+
# Parse arguments now so the CLI structure stays ready for small future changes.
|
|
260
|
+
parser = build_parser()
|
|
261
|
+
# Detect JSON mode early so parse errors can also return JSON when requested.
|
|
262
|
+
parser.json_output = "--json" in arguments
|
|
263
|
+
args = parser.parse_args(arguments)
|
|
264
|
+
virtual_environment_detected = is_virtual_environment_detected()
|
|
265
|
+
|
|
266
|
+
# Scan either the provided directory or, by default, the current working directory.
|
|
267
|
+
scan_path, error_message, displayed_path = get_scan_path(args.path)
|
|
268
|
+
|
|
269
|
+
# Keep the existing non-zero exit behavior for invalid paths.
|
|
270
|
+
if error_message is not None:
|
|
271
|
+
error_result = build_result(
|
|
272
|
+
scanned_directory=displayed_path,
|
|
273
|
+
error=error_message,
|
|
274
|
+
virtual_environment_detected=virtual_environment_detected,
|
|
275
|
+
)
|
|
276
|
+
if args.json:
|
|
277
|
+
print_json_result(error_result)
|
|
278
|
+
else:
|
|
279
|
+
print(error_message, file=sys.stderr)
|
|
280
|
+
print_suggestions(error_result["suggestions"], stream=sys.stderr)
|
|
281
|
+
return 1
|
|
282
|
+
|
|
283
|
+
# At this point the scan path is valid and safe to inspect.
|
|
284
|
+
assert scan_path is not None
|
|
285
|
+
found_files = find_marker_files(scan_path)
|
|
286
|
+
result = build_result(
|
|
287
|
+
scanned_directory=displayed_path,
|
|
288
|
+
found_files=found_files,
|
|
289
|
+
virtual_environment_detected=virtual_environment_detected,
|
|
290
|
+
)
|
|
291
|
+
|
|
292
|
+
# JSON mode returns only structured data and skips the human-readable text blocks.
|
|
293
|
+
if args.json:
|
|
294
|
+
print_json_result(result)
|
|
295
|
+
return 0
|
|
296
|
+
|
|
297
|
+
print_project_result(scan_path, found_files)
|
|
298
|
+
print_virtual_environment_result(virtual_environment_detected)
|
|
299
|
+
print_suggestions(result["suggestions"])
|
|
300
|
+
return 0
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
if __name__ == "__main__":
|
|
304
|
+
# Allow direct execution with `python main.py` and return a process exit code.
|
|
305
|
+
sys.exit(main())
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: python-project-doctor-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A beginner-friendly CLI that checks whether a directory looks like a Python project and suggests what to do next.
|
|
5
|
+
Author: x1958075990h-pixel
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2026 x1958075990h-pixel
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/x1958075990h-pixel/pyenv-doctor
|
|
29
|
+
Project-URL: Repository, https://github.com/x1958075990h-pixel/pyenv-doctor
|
|
30
|
+
Project-URL: Issues, https://github.com/x1958075990h-pixel/issues
|
|
31
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
32
|
+
Classifier: Operating System :: OS Independent
|
|
33
|
+
Classifier: Programming Language :: Python :: 3
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
37
|
+
Requires-Python: >=3.11
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
License-File: LICENSE
|
|
40
|
+
Dynamic: license-file
|
|
41
|
+
|
|
42
|
+
# pyenv-doctor
|
|
43
|
+
|
|
44
|
+
`pyenv-doctor` is a minimal Python command-line tool for beginners.
|
|
45
|
+
|
|
46
|
+
It scans a directory, checks whether it looks like a Python project, and tells you whether the current Python interpreter is running inside a virtual environment.
|
|
47
|
+
|
|
48
|
+
## What It Checks
|
|
49
|
+
|
|
50
|
+
This MVP checks for these common Python project files:
|
|
51
|
+
|
|
52
|
+
- `requirements.txt`
|
|
53
|
+
- `pyproject.toml`
|
|
54
|
+
- `setup.py`
|
|
55
|
+
- `setup.cfg`
|
|
56
|
+
- `Pipfile`
|
|
57
|
+
- `poetry.lock`
|
|
58
|
+
- `uv.lock`
|
|
59
|
+
- `environment.yml`
|
|
60
|
+
- `.python-version`
|
|
61
|
+
|
|
62
|
+
If at least one of them exists, the tool prints:
|
|
63
|
+
|
|
64
|
+
`Conclusion: this looks like a Python project`
|
|
65
|
+
|
|
66
|
+
It also checks whether the current Python is running in a virtual environment.
|
|
67
|
+
After the scan, it prints a short list of beginner-friendly suggestions based on the result.
|
|
68
|
+
|
|
69
|
+
Supported common cases:
|
|
70
|
+
|
|
71
|
+
- `venv`
|
|
72
|
+
- `virtualenv`
|
|
73
|
+
- `Conda`
|
|
74
|
+
|
|
75
|
+
## Why Virtual Environments Are Useful
|
|
76
|
+
|
|
77
|
+
Virtual environments help keep project dependencies isolated.
|
|
78
|
+
This makes it easier to avoid version conflicts between different Python projects on the same machine.
|
|
79
|
+
|
|
80
|
+
## Project Structure
|
|
81
|
+
|
|
82
|
+
```text
|
|
83
|
+
pyenv-doctor/
|
|
84
|
+
|-- .gitignore
|
|
85
|
+
|-- .github/
|
|
86
|
+
| |-- workflows/
|
|
87
|
+
| | |-- ci.yml
|
|
88
|
+
| | `-- publish.yml
|
|
89
|
+
|-- pyproject.toml
|
|
90
|
+
|-- README.md
|
|
91
|
+
|-- requirements.txt
|
|
92
|
+
|-- LICENSE
|
|
93
|
+
|-- main.py
|
|
94
|
+
`-- tests/
|
|
95
|
+
`-- test_main.py
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Installation
|
|
99
|
+
|
|
100
|
+
### 1. Make sure Python 3.11 or newer is available
|
|
101
|
+
|
|
102
|
+
```powershell
|
|
103
|
+
python --version
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### 2. Install from PyPI
|
|
107
|
+
|
|
108
|
+
The PyPI package name is:
|
|
109
|
+
|
|
110
|
+
```text
|
|
111
|
+
python-project-doctor-cli
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Install it with:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
python -m pip install python-project-doctor-cli
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
The installed command name is still:
|
|
121
|
+
|
|
122
|
+
```powershell
|
|
123
|
+
pyenv-doctor
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### 3. Install locally from source
|
|
127
|
+
|
|
128
|
+
Clone the repository, enter the project directory, and install it locally:
|
|
129
|
+
|
|
130
|
+
```powershell
|
|
131
|
+
python -m pip install .
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
For local development, you can also use editable install:
|
|
135
|
+
|
|
136
|
+
```powershell
|
|
137
|
+
python -m pip install -e .
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Run
|
|
141
|
+
|
|
142
|
+
Run the installed CLI command:
|
|
143
|
+
|
|
144
|
+
```powershell
|
|
145
|
+
pyenv-doctor
|
|
146
|
+
pyenv-doctor .
|
|
147
|
+
pyenv-doctor C:\my-project
|
|
148
|
+
pyenv-doctor . --json
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
Run the tool from source:
|
|
152
|
+
|
|
153
|
+
```powershell
|
|
154
|
+
python main.py
|
|
155
|
+
python main.py C:\my-project
|
|
156
|
+
python main.py C:\my-project --json
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Windows note for virtual environment detection
|
|
160
|
+
|
|
161
|
+
If you want to verify virtual environment detection on Windows, activate the virtual environment first and then run:
|
|
162
|
+
|
|
163
|
+
```powershell
|
|
164
|
+
python main.py
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
This is recommended because `py -3.14 main.py` may use the system interpreter instead of the currently activated virtual environment.
|
|
168
|
+
|
|
169
|
+
## Run Tests
|
|
170
|
+
|
|
171
|
+
Run the test suite with:
|
|
172
|
+
|
|
173
|
+
```powershell
|
|
174
|
+
python -m unittest discover -s tests -v
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
## Exit Codes
|
|
178
|
+
|
|
179
|
+
- `0`: the scan completed successfully
|
|
180
|
+
- non-zero: the scan failed because the path was invalid or the arguments were invalid
|
|
181
|
+
|
|
182
|
+
## JSON Output
|
|
183
|
+
|
|
184
|
+
Use `--json` to get machine-readable output:
|
|
185
|
+
|
|
186
|
+
```powershell
|
|
187
|
+
pyenv-doctor . --json
|
|
188
|
+
python main.py . --json
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
The JSON output includes:
|
|
192
|
+
|
|
193
|
+
- `scanned_directory`
|
|
194
|
+
- `found_files`
|
|
195
|
+
- `looks_like_python_project`
|
|
196
|
+
- `virtual_environment_detected`
|
|
197
|
+
- `error`
|
|
198
|
+
- `suggestions`
|
|
199
|
+
|
|
200
|
+
## Example Output
|
|
201
|
+
|
|
202
|
+
### Example 1: Python project detected, virtual environment detected
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
Scanned directory: C:\demo\my-project
|
|
206
|
+
|
|
207
|
+
Project file detection:
|
|
208
|
+
- requirements.txt: not found
|
|
209
|
+
- pyproject.toml: found
|
|
210
|
+
- setup.py: not found
|
|
211
|
+
- setup.cfg: not found
|
|
212
|
+
- Pipfile: not found
|
|
213
|
+
- poetry.lock: found
|
|
214
|
+
- uv.lock: not found
|
|
215
|
+
- environment.yml: not found
|
|
216
|
+
- .python-version: not found
|
|
217
|
+
|
|
218
|
+
Conclusion: this looks like a Python project
|
|
219
|
+
Reason: detected pyproject.toml, poetry.lock
|
|
220
|
+
|
|
221
|
+
Virtual environment detection:
|
|
222
|
+
Virtual environment: detected
|
|
223
|
+
|
|
224
|
+
Suggestions:
|
|
225
|
+
- Open pyproject.toml to check how this project should be installed or run.
|
|
226
|
+
- If this project uses Poetry, review pyproject.toml and try poetry install.
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Example 2: No project markers, no virtual environment
|
|
230
|
+
|
|
231
|
+
```text
|
|
232
|
+
Scanned directory: C:\demo\empty-folder
|
|
233
|
+
|
|
234
|
+
Project file detection:
|
|
235
|
+
- requirements.txt: not found
|
|
236
|
+
- pyproject.toml: not found
|
|
237
|
+
- setup.py: not found
|
|
238
|
+
- setup.cfg: not found
|
|
239
|
+
- Pipfile: not found
|
|
240
|
+
- poetry.lock: not found
|
|
241
|
+
- uv.lock: not found
|
|
242
|
+
- environment.yml: not found
|
|
243
|
+
- .python-version: not found
|
|
244
|
+
|
|
245
|
+
Conclusion: no clear Python project markers were found
|
|
246
|
+
Details: common Python project files were not found in this directory.
|
|
247
|
+
|
|
248
|
+
Virtual environment detection:
|
|
249
|
+
Virtual environment: not detected
|
|
250
|
+
Recommendation: use venv or Conda for an isolated Python environment
|
|
251
|
+
|
|
252
|
+
Suggestions:
|
|
253
|
+
- Verify that you are scanning the project root directory.
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Example 3: Invalid path
|
|
257
|
+
|
|
258
|
+
```text
|
|
259
|
+
Error: path does not exist: C:\does-not-exist
|
|
260
|
+
|
|
261
|
+
Suggestions:
|
|
262
|
+
- Check the path spelling and try again.
|
|
263
|
+
```
|
|
264
|
+
|
|
265
|
+
### Example 4: JSON output
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"scanned_directory": "C:\\demo\\my-project",
|
|
270
|
+
"found_files": [
|
|
271
|
+
"Pipfile",
|
|
272
|
+
".python-version"
|
|
273
|
+
],
|
|
274
|
+
"looks_like_python_project": true,
|
|
275
|
+
"virtual_environment_detected": false,
|
|
276
|
+
"error": null,
|
|
277
|
+
"suggestions": [
|
|
278
|
+
"Open Pipfile to review the project's dependencies and environment settings.",
|
|
279
|
+
"Check .python-version to see which Python version this project expects."
|
|
280
|
+
]
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
## Publishing
|
|
285
|
+
|
|
286
|
+
This repository includes a GitHub Actions workflow for trusted publishing to PyPI when a GitHub release is published.
|
|
287
|
+
|
|
288
|
+
To use it, first add this repository as a trusted publisher in your PyPI project settings.
|
|
289
|
+
Then create a GitHub release to trigger the publish workflow.
|
|
290
|
+
|
|
291
|
+
## Roadmap
|
|
292
|
+
|
|
293
|
+
- Improve test coverage
|
|
294
|
+
- Improve detection rules for different Python workflows
|
|
295
|
+
|
|
296
|
+
## License
|
|
297
|
+
|
|
298
|
+
This project is licensed under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
main.py,sha256=ewnCyaxX-AMw-F4-Us-nngTuYeFmZf3Pwnjb2ZWnRmw,11597
|
|
2
|
+
python_project_doctor_cli-0.1.0.dist-info/licenses/LICENSE,sha256=nakW2OxV8ZBQL-coZ-3Oi6zF7AGdb_SJtEkunWfh6Mc,1075
|
|
3
|
+
python_project_doctor_cli-0.1.0.dist-info/METADATA,sha256=wIYG9aNTmyzyRyir9f6wDVT9Pp0PkGpPTkHkZiQActc,7523
|
|
4
|
+
python_project_doctor_cli-0.1.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
5
|
+
python_project_doctor_cli-0.1.0.dist-info/entry_points.txt,sha256=ZLBoYWY0Ip48JbNKXdHRYkJXknwgFBnmQgs2dfvaXWI,43
|
|
6
|
+
python_project_doctor_cli-0.1.0.dist-info/top_level.txt,sha256=ZAMgPdWghn6xTRBO6Kc3ML1y3ZrZLnjZlqbboKXc_AE,5
|
|
7
|
+
python_project_doctor_cli-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 x1958075990h-pixel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
main
|