libsoulsearching 0.1.1__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.
Files changed (28) hide show
  1. libsoulsearching-0.1.1/.gitignore +68 -0
  2. libsoulsearching-0.1.1/LICENCING +25 -0
  3. libsoulsearching-0.1.1/LICENSE-0BSD +12 -0
  4. libsoulsearching-0.1.1/PKG-INFO +206 -0
  5. libsoulsearching-0.1.1/README.md +177 -0
  6. libsoulsearching-0.1.1/UNLICENSE +24 -0
  7. libsoulsearching-0.1.1/libsoulsearching/__init__.py +25 -0
  8. libsoulsearching-0.1.1/libsoulsearching/cli.py +185 -0
  9. libsoulsearching-0.1.1/libsoulsearching/core.py +150 -0
  10. libsoulsearching-0.1.1/libsoulsearching/detectors/__init__.py +43 -0
  11. libsoulsearching-0.1.1/libsoulsearching/detectors/hatch.py +84 -0
  12. libsoulsearching-0.1.1/libsoulsearching/detectors/pd.py +81 -0
  13. libsoulsearching-0.1.1/libsoulsearching/detectors/pipenv.py +63 -0
  14. libsoulsearching-0.1.1/libsoulsearching/detectors/poetry.py +67 -0
  15. libsoulsearching-0.1.1/libsoulsearching/detectors/pyenv.py +66 -0
  16. libsoulsearching-0.1.1/libsoulsearching/detectors/rye.py +78 -0
  17. libsoulsearching-0.1.1/libsoulsearching/detectors/utils.py +34 -0
  18. libsoulsearching-0.1.1/libsoulsearching/detectors/uv.py +40 -0
  19. libsoulsearching-0.1.1/libsoulsearching/detectors/venv.py +39 -0
  20. libsoulsearching-0.1.1/libsoulsearching/models.py +72 -0
  21. libsoulsearching-0.1.1/libsoulsearching/py.typed +0 -0
  22. libsoulsearching-0.1.1/pyproject.toml +74 -0
  23. libsoulsearching-0.1.1/tests/__init__.py +3 -0
  24. libsoulsearching-0.1.1/tests/conftest.py +162 -0
  25. libsoulsearching-0.1.1/tests/test_cli.py +135 -0
  26. libsoulsearching-0.1.1/tests/test_core.py +103 -0
  27. libsoulsearching-0.1.1/tests/test_detectors_edge_cases.py +548 -0
  28. libsoulsearching-0.1.1/tests/test_integration_real.py +317 -0
@@ -0,0 +1,68 @@
1
+ # python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.so
6
+ .Python
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ lib/
14
+ lib64/
15
+ parts/
16
+ sdist/
17
+ var/
18
+ wheels/
19
+ share/python-wheels/
20
+ *.egg-info/
21
+ .installed.cfg
22
+ *.egg
23
+ MANIFEST
24
+
25
+ # virtual environments
26
+ .env
27
+ .venv
28
+ env/
29
+ venv/
30
+ ENV/
31
+ env.bak/
32
+ venv.bak/
33
+
34
+ # ides
35
+ .vscode/
36
+ .idea/
37
+ *.swp
38
+ *.swo
39
+ *~
40
+
41
+ # testing
42
+ .pytest_cache/
43
+ .coverage
44
+ htmlcov/
45
+ .tox/
46
+ .nox/
47
+
48
+ # raiseattention cache
49
+ .raiseattention/
50
+
51
+ # misc
52
+ .DS_Store
53
+ *.log
54
+
55
+ # nix
56
+ result
57
+ result-*
58
+ .direnv/
59
+
60
+ # playground and debug files
61
+ playground/
62
+ test_debug*.py
63
+ test_env_config.py
64
+
65
+ # caches
66
+ .ruff_cache/
67
+ .pytest_cache/
68
+ .mypy_cache/
@@ -0,0 +1,25 @@
1
+ This software is unencumbered and free-as-in-freedom.
2
+
3
+ This project is dual-licenced under The Unlicense or the BSD Zero Clause
4
+ License. (SPDX: `Unlicense OR 0BSD`)
5
+
6
+ The spirit and intent of the project is to treat the work as public domain via
7
+ The Unlicense, but providing the BSD Zero Clause License where public domain
8
+ dedication is not possible due to policies bound to a contributor or their
9
+ employer. However, this is not a legal condition.
10
+
11
+ Either way, you are free to use the software as you wish, without any
12
+ restrictions or obligations, subject only to the warranty disclaimers in the
13
+ licence texts.
14
+
15
+ > Does dual licencing not invalidate the ethos behind The Unlicense?
16
+
17
+ Well yeah, but like, even if ten percent of code is 0BSD-licenced, the rest
18
+ is still unlicenced. And that's... good enough, and better than the
19
+ alternative of a fully 0BSD-licenced project. _Everyone should be able to
20
+ contribute._
21
+
22
+ ---
23
+
24
+ See the [CONTRIBUTING](./CONTRIBUTING), [UNLICENSE](./UNLICENSE), and
25
+ [LICENSE-0BSD](./LICENSE-0BSD) files for more information.
@@ -0,0 +1,12 @@
1
+ Copyright (C) 2024 by Mark Joshwel <mark@joshwel.co>
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for
4
+ any purpose with or without fee is hereby granted.
5
+
6
+ THE SOFTWARE IS PROVIDED “AS IS” AND THE AUTHOR DISCLAIMS ALL
7
+ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
8
+ OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
9
+ FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY
10
+ DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
11
+ AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
12
+ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,206 @@
1
+ Metadata-Version: 2.4
2
+ Name: libsoulsearching
3
+ Version: 0.1.1
4
+ Summary: universal python virtual environment finder
5
+ Project-URL: Documentation, https://github.com/markjoshwel/RaiseAttention/tree/main/src/libsoulsearching#readme
6
+ Project-URL: Repository, https://github.com/markjoshwel/RaiseAttention/tree/main/src/libsoulsearching
7
+ Project-URL: Issues, https://github.com/markjoshwel/RaiseAttention/issues
8
+ Author-email: Mark Joshwel <mark@joshwel.co>
9
+ Maintainer-email: Mark Joshwel <mark@joshwel.co>
10
+ License-Expression: Unlicense OR 0BSD
11
+ License-File: LICENCING
12
+ License-File: LICENSE-0BSD
13
+ Keywords: hatch,pdm,pipenv,poetry,pyenv,python,rye,uv,venv,virtualenv
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: The Unlicense (Unlicense)
17
+ Classifier: License :: OSI Approved :: Zero-Clause BSD (0BSD)
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Programming Language :: Python :: 3.13
22
+ Classifier: Topic :: Software Development :: Build Tools
23
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
24
+ Requires-Python: >=3.11
25
+ Requires-Dist: typing-extensions>=4.6.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
28
+ Description-Content-Type: text/markdown
29
+
30
+ # libsoulsearching
31
+
32
+ python virtual environment finder for most mainstream setups,
33
+ after multiple projects of mine needed to dig through a venv
34
+
35
+ ## installation
36
+
37
+ ```text
38
+ pip install libsoulsearching
39
+ ```
40
+
41
+ ## quickstart
42
+
43
+ ```python
44
+ from libsoulsearching import find_venv, find_all_venvs, ToolType
45
+
46
+ # find the first/best venv
47
+ info = find_venv("/path/to/project")
48
+ if info:
49
+ print(f"found {info.tool.value} venv at {info.venv_path}")
50
+
51
+ # find all venvs
52
+ all_venvs = find_all_venvs("/path/to/project")
53
+ for venv in all_venvs:
54
+ print(f"{venv.tool.value}: {venv.venv_path}")
55
+
56
+ # find specific tool only
57
+ poetry_venv = find_venv("/path/to/project", tool=ToolType.POETRY)
58
+ ```
59
+
60
+ ## supported tools
61
+
62
+ - **poetry**
63
+ `poetry.lock`, `pyproject.toml` with poetry config
64
+
65
+ - **pipenv**
66
+ `pipfile.lock`
67
+
68
+ - **pdm**
69
+ `pdm.lock`, `.pdm.toml`
70
+
71
+ - **uv**
72
+ `uv.lock`, `.venv`
73
+
74
+ - **rye**
75
+ `rye.lock`, `.python-version`
76
+
77
+ - **hatch**
78
+ `pyproject.toml` with `[tool.hatch.envs]`
79
+
80
+ - **venv**
81
+ `.venv/pyvenv.cfg`
82
+
83
+ - **pyenv**
84
+ `.python-version`
85
+
86
+ ## cli usage
87
+
88
+ ```text
89
+ # find first venv
90
+ venvfinder /path/to/project
91
+
92
+ # list all venvs
93
+ venvfinder /path/to/project --all
94
+
95
+ # find specific tool
96
+ venvfinder /path/to/project --tool poetry
97
+
98
+ # json output
99
+ venvfinder /path/to/project --json
100
+ ```
101
+
102
+ ## api reference
103
+
104
+ - `libsoulsearching.find_venv()`
105
+ find a virtual environment in the given project directory
106
+
107
+ - `libsoulsearching.find_all_venvs()`
108
+ find all virtual environments in the given project directory
109
+
110
+ - `libsoulsearching.ToolType`
111
+ enumeration of supported python environment management tools
112
+
113
+ - `libsoulsearching.VenvInfo`
114
+ information about a detected python virtual environment
115
+
116
+ ### def libsoulsearching.find_venv()
117
+
118
+ find a virtual environment in the given project directory
119
+
120
+ - signature:
121
+
122
+ ```python
123
+ def find_venv(
124
+ project_root: str | Path,
125
+ tool: ToolType | None = None,
126
+ ) -> VenvInfo | None: ...
127
+ ```
128
+
129
+ - arguments:
130
+ - `project_root: str | Path`
131
+ path to the project directory
132
+ - `tool: ToolType | None`
133
+ specific tool to detect. if none, uses priority order
134
+
135
+ - returns: `VenvInfo | None`
136
+ venvinfo if a venv is found, none otherwise
137
+
138
+ ### def libsoulsearching.find_all_venvs()
139
+
140
+ find all virtual environments in the given project directory
141
+
142
+ returns all detected venvs in priority order, including potentially
143
+ invalid ones (is_valid=false) if the tool's marker files exist but
144
+ the actual venv is missing
145
+
146
+ - signature:
147
+
148
+ ```python
149
+ def find_all_venvs(project_root: str | Path) -> list[VenvInfo]: ...
150
+ ```
151
+
152
+ - arguments:
153
+ - `project_root: str | Path`
154
+ path to the project directory
155
+
156
+ - returns: `list[VenvInfo]`
157
+ list of venvinfo objects (may be empty)
158
+
159
+ ### class libsoulsearching.ToolType
160
+
161
+ enumeration of supported python environment management tools
162
+
163
+ - attributes:
164
+ - `POETRY: str`
165
+ poetry package manager
166
+ - `PIPENV: str`
167
+ pipenv package manager
168
+ - `PDM: str`
169
+ pdm package manager
170
+ - `UV: str`
171
+ uv package manager
172
+ - `RYE: str`
173
+ rye package manager
174
+ - `HATCH: str`
175
+ hatch package manager
176
+ - `VENV: str`
177
+ standard venv module
178
+ - `PYENV: str`
179
+ pyenv version manager
180
+ - `ENV_VAR: str`
181
+ virtual environment from environment variable
182
+
183
+ ### class libsoulsearching.VenvInfo
184
+
185
+ information about a detected python virtual environment
186
+
187
+ - attributes:
188
+ - `tool: ToolType`
189
+ the detected tool type
190
+ - `venv_path: Path | None`
191
+ path to the virtual environment directory
192
+ - `python_executable: Path | None`
193
+ path to the python executable
194
+ - `python_version: str | None`
195
+ python version string (e.g., "3.10.5")
196
+ - `is_valid: bool`
197
+ whether the detected environment exists and is valid
198
+
199
+ ## licence
200
+
201
+ libsoulsearching is unencumbered, free-as-in-freedom, and is dual-licenced under
202
+ The Unlicense or the BSD Zero Clause License. (SPDX: `Unlicense OR 0BSD`)
203
+
204
+ you are free to use the software as you wish, without any restrictions or
205
+ obligations, subject only to the warranty disclaimers in the licence text
206
+ of your choosing.
@@ -0,0 +1,177 @@
1
+ # libsoulsearching
2
+
3
+ python virtual environment finder for most mainstream setups,
4
+ after multiple projects of mine needed to dig through a venv
5
+
6
+ ## installation
7
+
8
+ ```text
9
+ pip install libsoulsearching
10
+ ```
11
+
12
+ ## quickstart
13
+
14
+ ```python
15
+ from libsoulsearching import find_venv, find_all_venvs, ToolType
16
+
17
+ # find the first/best venv
18
+ info = find_venv("/path/to/project")
19
+ if info:
20
+ print(f"found {info.tool.value} venv at {info.venv_path}")
21
+
22
+ # find all venvs
23
+ all_venvs = find_all_venvs("/path/to/project")
24
+ for venv in all_venvs:
25
+ print(f"{venv.tool.value}: {venv.venv_path}")
26
+
27
+ # find specific tool only
28
+ poetry_venv = find_venv("/path/to/project", tool=ToolType.POETRY)
29
+ ```
30
+
31
+ ## supported tools
32
+
33
+ - **poetry**
34
+ `poetry.lock`, `pyproject.toml` with poetry config
35
+
36
+ - **pipenv**
37
+ `pipfile.lock`
38
+
39
+ - **pdm**
40
+ `pdm.lock`, `.pdm.toml`
41
+
42
+ - **uv**
43
+ `uv.lock`, `.venv`
44
+
45
+ - **rye**
46
+ `rye.lock`, `.python-version`
47
+
48
+ - **hatch**
49
+ `pyproject.toml` with `[tool.hatch.envs]`
50
+
51
+ - **venv**
52
+ `.venv/pyvenv.cfg`
53
+
54
+ - **pyenv**
55
+ `.python-version`
56
+
57
+ ## cli usage
58
+
59
+ ```text
60
+ # find first venv
61
+ venvfinder /path/to/project
62
+
63
+ # list all venvs
64
+ venvfinder /path/to/project --all
65
+
66
+ # find specific tool
67
+ venvfinder /path/to/project --tool poetry
68
+
69
+ # json output
70
+ venvfinder /path/to/project --json
71
+ ```
72
+
73
+ ## api reference
74
+
75
+ - `libsoulsearching.find_venv()`
76
+ find a virtual environment in the given project directory
77
+
78
+ - `libsoulsearching.find_all_venvs()`
79
+ find all virtual environments in the given project directory
80
+
81
+ - `libsoulsearching.ToolType`
82
+ enumeration of supported python environment management tools
83
+
84
+ - `libsoulsearching.VenvInfo`
85
+ information about a detected python virtual environment
86
+
87
+ ### def libsoulsearching.find_venv()
88
+
89
+ find a virtual environment in the given project directory
90
+
91
+ - signature:
92
+
93
+ ```python
94
+ def find_venv(
95
+ project_root: str | Path,
96
+ tool: ToolType | None = None,
97
+ ) -> VenvInfo | None: ...
98
+ ```
99
+
100
+ - arguments:
101
+ - `project_root: str | Path`
102
+ path to the project directory
103
+ - `tool: ToolType | None`
104
+ specific tool to detect. if none, uses priority order
105
+
106
+ - returns: `VenvInfo | None`
107
+ venvinfo if a venv is found, none otherwise
108
+
109
+ ### def libsoulsearching.find_all_venvs()
110
+
111
+ find all virtual environments in the given project directory
112
+
113
+ returns all detected venvs in priority order, including potentially
114
+ invalid ones (is_valid=false) if the tool's marker files exist but
115
+ the actual venv is missing
116
+
117
+ - signature:
118
+
119
+ ```python
120
+ def find_all_venvs(project_root: str | Path) -> list[VenvInfo]: ...
121
+ ```
122
+
123
+ - arguments:
124
+ - `project_root: str | Path`
125
+ path to the project directory
126
+
127
+ - returns: `list[VenvInfo]`
128
+ list of venvinfo objects (may be empty)
129
+
130
+ ### class libsoulsearching.ToolType
131
+
132
+ enumeration of supported python environment management tools
133
+
134
+ - attributes:
135
+ - `POETRY: str`
136
+ poetry package manager
137
+ - `PIPENV: str`
138
+ pipenv package manager
139
+ - `PDM: str`
140
+ pdm package manager
141
+ - `UV: str`
142
+ uv package manager
143
+ - `RYE: str`
144
+ rye package manager
145
+ - `HATCH: str`
146
+ hatch package manager
147
+ - `VENV: str`
148
+ standard venv module
149
+ - `PYENV: str`
150
+ pyenv version manager
151
+ - `ENV_VAR: str`
152
+ virtual environment from environment variable
153
+
154
+ ### class libsoulsearching.VenvInfo
155
+
156
+ information about a detected python virtual environment
157
+
158
+ - attributes:
159
+ - `tool: ToolType`
160
+ the detected tool type
161
+ - `venv_path: Path | None`
162
+ path to the virtual environment directory
163
+ - `python_executable: Path | None`
164
+ path to the python executable
165
+ - `python_version: str | None`
166
+ python version string (e.g., "3.10.5")
167
+ - `is_valid: bool`
168
+ whether the detected environment exists and is valid
169
+
170
+ ## licence
171
+
172
+ libsoulsearching is unencumbered, free-as-in-freedom, and is dual-licenced under
173
+ The Unlicense or the BSD Zero Clause License. (SPDX: `Unlicense OR 0BSD`)
174
+
175
+ you are free to use the software as you wish, without any restrictions or
176
+ obligations, subject only to the warranty disclaimers in the licence text
177
+ of your choosing.
@@ -0,0 +1,24 @@
1
+ This is free and unencumbered software released into the public domain.
2
+
3
+ Anyone is free to copy, modify, publish, use, compile, sell, or
4
+ distribute this software, either in source code form or as a compiled
5
+ binary, for any purpose, commercial or non-commercial, and by any
6
+ means.
7
+
8
+ In jurisdictions that recognize copyright laws, the author or authors
9
+ of this software dedicate any and all copyright interest in the
10
+ software to the public domain. We make this dedication for the benefit
11
+ of the public at large and to the detriment of our heirs and
12
+ successors. We intend this dedication to be an overt act of
13
+ relinquishment in perpetuity of all present and future rights to this
14
+ software under copyright law.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
+ IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
+ OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
+ ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
23
+
24
+ For more information, please refer to <https://unlicense.org/>
@@ -0,0 +1,25 @@
1
+ """
2
+ universal python virtual environment finder.
3
+
4
+ libsoulsearching detects virtual environments created by various python tools
5
+ including poetry, pipenv, pdm, uv, rye, hatch, standard venv, and pyenv.
6
+
7
+ functions:
8
+ `def find_venv(project_root: str | Path, tool: ToolType | None = None) -> VenvInfo | None`
9
+ find a virtual environment in the given project directory
10
+ `def find_all_venvs(project_root: str | Path) -> list[VenvInfo]`
11
+ find all virtual environments in the given project directory
12
+ """
13
+
14
+ from __future__ import annotations
15
+
16
+ from .core import find_venv, find_all_venvs
17
+ from .models import ToolType, VenvInfo
18
+
19
+ __version__ = "0.1.0"
20
+ __all__ = [
21
+ "find_venv",
22
+ "find_all_venvs",
23
+ "ToolType",
24
+ "VenvInfo",
25
+ ]