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
Copy file name to clipboardExpand all lines: README.md
+27
Original file line number
Diff line number
Diff line change
@@ -155,6 +155,33 @@ But it is possible to ignore all deps, that are hidden inside contexts:
155
155
%
156
156
```
157
157
158
+
#### Matching dependencies with environment
159
+
Imagine you write your big project, all your dependencies (including building and testing dependencies) are installed to your virtual (or real) environment. So you need to detect your runnning dependencies and match them to packages, installed to your environment, and get **requirements.txt** file, which you can include in your package. For such cases there is **--inspect_env** option:
160
+
161
+
```shell
162
+
% py3req --inspect_env --verbose src
163
+
% cat requirements.txt
164
+
numpy==2.2.1
165
+
```
166
+
167
+
As you can see, **py3req** saves matched dependencies to **requirements.txt** file.
168
+
169
+
Now we can get your testing dependencies:
170
+
```shell
171
+
% py3req --inspect_env --verbose tests
172
+
py3prov:INFO: bad name for provides from path:config-3.12-x86_64-linux-gnu
173
+
py3prov:INFO: bad name for provides from path:numpy.libs
174
+
py3req:/tmp/project/tests/test1.py: "unittest" lines:[1] is possibly a self-providing dependency, skip it
175
+
The following deps:pytest was satisfied by package:pytest==8.3.4
176
+
% cat requirements.txt
177
+
pytest==8.3.4
178
+
```
179
+
180
+
The difference between running **py3req** with option **--inspect_env** and **pip3 freeze** is that the last command lists all packages installed to your environment (including their dependencies). But **py3req** just finds all dependencies of given sources and can match it to the installed packages.
181
+
182
+
Also there is an extra option for **--inspect_env** which is called **--env_path**. This options lets you to specify path to your environment (where your packages are installed). It is usefull for **CI** or something like that, but by default **py3req** checks your [purelib](https://docs.python.org/3/library/sysconfig.html#installation-paths) and [platlib](https://docs.python.org/3/library/sysconfig.html#installation-paths), so you can skip this option.
183
+
184
+
158
185
Other options are little bit specific, but there is clear **--help** option output. Please, check it.
0 commit comments