Another `module_mapping` issue. I'm trying to use ...
# general
l
Another
module_mapping
issue. I'm trying to use the
pytest-json-report
package which has a nonstandard import format, but even
module_mapping
seems insufficient to infer deps. I have to explicitly include the dep as a dependency.
Repro:
Copy code
diff --git BUILD.pants BUILD.pants
new file mode 100644
index 0000000..a2852cd
--- /dev/null
+++ BUILD.pants
@@ -0,0 +1,14 @@
+python_requirements(
+    name="root",
+    module_mapping={
+        "pytest_jsonreport.plugin": ["pytest-json-reportj"],
+	"pytest_jsonreport": ["pytest-json-report"],
+    },
+)
+
+python_tests(
+    name="tests0",
+    dependencies=[
+      ":root#pytest-json-report",
+    ]
+)
diff --git pants.toml pants.toml
new file mode 100644
index 0000000..3abf178
--- /dev/null
+++ pants.toml
@@ -0,0 +1,11 @@
+[GLOBAL]
+pants_version = "2.16.0"
+backend_packages = [
+  "pants.backend.python",
+]
+build_patterns = [
+  "BUILD.pants"
+]
+
+[tailor]
+build_file_name = "BUILD.pants"
diff --git requirements.txt requirements.txt
new file mode 100644
index 0000000..88e9af0
--- /dev/null
+++ requirements.txt
@@ -0,0 +1,2 @@
+pytest
+pytest-json-report
diff --git tests.py tests.py
new file mode 100644
index 0000000..85a78bc
--- /dev/null
+++ tests.py
@@ -0,0 +1,6 @@
+import pytest
+from pytest_jsonreport.plugin import JSONReport
+
+if __name__ == '__main__':
+    plugin = JSONReport()
+    pytest.main(plugins=[plugin])
Without the
dependencies
argument, it'll fail to lookup the module
b
I think the
module_mapping
field goes the other way: it maps from PyPI name to the name used for imports, e.g.
"pytest-json-report": ["pytest_jsonreport"]
👀 1
👍 1