You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
py3req:/tmp/dummy/src/pkg1/mod1.py: "os" lines:[3] is possibly a self-providing dependency, skip it
64
+
py3req:/tmp/dummy/src/pkg1/mod1.py: "os.path" lines:[4] is possibly a self-providing dependency, skip it
65
+
py3req:/tmp/dummy/src/pkg1/mod1.py: "tmp.dummy.src.pkg1.subpkg" lines:[8] is possibly a self-providing dependency, skip it
66
+
py3req:/tmp/dummy/src/pkg1/subpkg/mod3.py: "ast" lines:[1] is possibly a self-providing dependency, skip it
67
+
py3req:/tmp/dummy/tests/test1.py: "unittest" lines:[1] is possibly a self-providing dependency, skip it
68
+
/tmp/dummy/src/pkg1/mod1.py:numpy
69
+
/tmp/dummy/tests/test1.py:pytest
70
+
```
71
+
72
+
As you can see, **py3req** recognised dependency from **src/pkg1/mod1.py** to **src/pkg1/subpkg/mod3.py**, but since it is provided by given file list, **py3req** filtered it out.
73
+
74
+
#### Filtering dependencies
75
+
76
+
According to the previouse example, **sys** was not classified as a dependency, because **sys** is built-in module, which is provided by interpreter by itself. So such deps are filtered out by **py3req**. To make it visible for **py3req** use option **--include_built-in**:
77
+
78
+
```shell
79
+
% py3req --include_built-in src tests
80
+
sys
81
+
numpy
82
+
pytest
83
+
```
84
+
85
+
Now let's include dependencies, that are provided by python3 standard library:
86
+
87
+
```shell
88
+
% py3req --include_stdlib src tests
27
89
re
90
+
numpy
91
+
os.path
92
+
os
93
+
ast
94
+
pytest
95
+
unittest
28
96
```
29
-
Feel free to make it more verbose:
97
+
98
+
But what if we have dependency, that is provided by our environment or another one package, so we want **py3req** to find it and exclude from dependencies? For such problem we have **--add_prov_path** option:
Finally, there can be deps, that are hidden inside conditions or function calls. For example:
121
+
122
+
**anime_dld.py**
123
+
```python3
124
+
import os
125
+
126
+
127
+
deffunc():
128
+
import pytest
129
+
130
+
131
+
try:
132
+
import specific_module
133
+
exceptExceptionas ex:
134
+
print(f"I'm sorry, but {ex}")
135
+
136
+
137
+
a =int(input())
138
+
if a ==10:
139
+
import ast
140
+
else:
141
+
import re
41
142
```
42
-
That's it! But what if we want to detect its provides, to understand which dependencies it could satisfy? Let's use py3prov!
143
+
144
+
In general it is impossible to check if condition **a == 10** is True or False. Moreover it is not clear if **specific_module** is really important for such project or not. So, by default **py3req** catch them all:
145
+
146
+
```shell
147
+
% py3req anime_dld.py
148
+
pytest
149
+
specific_module
43
150
```
44
-
% python3 -m py3dephell.py3prov src
45
-
test1
46
-
tests.test1
47
-
src.tests.test1
48
-
mod1
49
-
pkg1.mod1
151
+
152
+
But it is possible to ignore all deps, that are hidden inside contexts:
153
+
```shell
154
+
% py3req --exclude_hidden_deps anime_dld.py
155
+
%
156
+
```
157
+
158
+
Other options are little bit specific, but there is clear **--help** option output. Please, check it.
159
+
160
+
161
+
### Detecting provides
162
+
163
+
While dependency is something, that is required (imported) by your project, provides are requirements, that are exported by other projects for yours.
164
+
165
+
To detect provides for our **src** use **py3prov**:
166
+
167
+
```shell
168
+
% py3prov src
169
+
src.pkg1.subpkg.mod3
50
170
src.pkg1.mod1
171
+
```
172
+
173
+
To get all possible provides (including even modules) use **--full_mode**:
174
+
175
+
```shell
176
+
% py3prov --full_mode src
51
177
mod3
52
178
subpkg.mod3
53
179
pkg1.subpkg.mod3
54
180
src.pkg1.subpkg.mod3
181
+
mod1
182
+
pkg1.mod1
183
+
src.pkg1.mod1
55
184
```
56
-
Yeah, let's enhance the verbosity level!
185
+
186
+
But all provides are prefixed by **src**, while your project should install **pkg1** in user system. To remove such prefixes use **--prefixes** option:
Other options, such as **--only_prefix** and **--skip_pth** are little bit specific, but it is clear, what they can be used for. **--only_prefix** exclude those provides, that are not under prefixes. **--skip_pth** ignore [**.pth**](https://docs.python.org/3/library/site.html) files
207
+
208
+
209
+
# API documentation
210
+
For **API** documentation just use **help** command from interpreter or visit this [link](https://altlinux.github.io/py3dephell/).
0 commit comments