@@ -83,10 +83,10 @@ no matter where this virtualenv may be located.
83
83
### Identity mapping
84
84
85
85
When unable to find an installed package that corresponds to a declared
86
- dependency either via a user-provided mapping or local Python environments,
87
- FawltyDeps will fall back to one of two strategies. "Identity mapping", which we
88
- present in this section is the default fallback strategy. We discuss the other
89
- strategy in the next subsection.
86
+ dependency either via a [ user-defined mapping] ( #user-defined-mapping ) or local
87
+ Python environments, FawltyDeps will fall back to one of two strategies.
88
+ "Identity mapping", which we present in this section is the default fallback
89
+ strategy. We discuss the other strategy in the next subsection.
90
90
91
91
Identity mapping relies on the simplistic assumption that the dependency provides
92
92
a single import of the same name, i.e. it will expect that when you depend on
@@ -135,16 +135,28 @@ In this case, FawltyDeps will throw an error and abort.
135
135
136
136
### User-defined mapping
137
137
138
+ Sometimes Python dependencies are imported using a different name than the package
139
+ name used in the ` import ` statement. Some Python packages might have hyphens in
140
+ their dependency names used by package managers, but underscores in their import
141
+ names, for example.
142
+
138
143
We provide a custom mapping functionality to users wishing to take control
139
144
over the way FawltyDeps resolves dependencies. You may define your own mapping
140
145
of dependency names to import names, by providing a TOML file like this:
141
146
142
147
``` toml
148
+ langchain-core = [" langchain_core" ]
149
+ multiple-modules = [" module1" , " module2" ]
143
150
my-package = [" mpkg" ]
151
+ python-dotenv = [" dotenv" ]
144
152
scikit-learn = [" sklearn" ]
145
- multiple-modules = [" module1" , " module2" ]
146
153
```
147
154
155
+ The package name of the dependency is on the left-hand side of the ` = ` , and the
156
+ import name(s) are on the right-hand side. You can provide multiple import names
157
+ for a single dependency.
158
+
159
+
148
160
To use your mapping, run:
149
161
150
162
``` sh
@@ -159,9 +171,11 @@ project, inside a `[tool.fawltydeps.custom_mapping]` section, like this:
159
171
160
172
``` toml
161
173
[tool .fawltydeps .custom_mapping ]
174
+ langchain-core = [" langchain_core" ]
175
+ multiple-modules = [" module1" , " module2" ]
162
176
my-package = [" mpkg" ]
177
+ python-dotenv = [" dotenv" ]
163
178
scikit-learn = [" sklearn" ]
164
- multiple-modules = [" module1" , " module2" ]
165
179
```
166
180
167
181
The provided mapping can be complete or partial. When a dependency is not
0 commit comments