Hi, Although, after add package into requirments.t...
# general
c
Hi, Although, after add package into requirments.txt and create lockfile and package, file sill cannot see the package. Where do I put more code? I am using example-django version 1. requirement.txt
Copy code
django-ninja>=0.19.1
2. lockfile
Copy code
// --- BEGIN PANTS LOCKFILE METADATA: DO NOT EDIT OR REMOVE ---
// {
//   "version": 2,
//   "valid_for_interpreter_constraints": [
//     "CPython>=3.7"
//   ],
//   "generated_with_requirements": [
//     "ansicolors>=1.0.2",
//     "django-ninja>=0.19.1",
//     "django-stubs>=1.10.0",
//     "django<4,>=3.2.13",
//     "gunicorn>=20.1.0",
//     "protobuf>=3.11.3",
//     "pytest>=6.0.1",
//     "requests>=2.25.1",
//     "setuptools>=42.0.0",
//     "translate>=3.2.1",
//     "types-requests>=2.25.1"
//   ]
// }
3. BUILD
Copy code
# Copyright 2021 Pants project contributors.
# Licensed under the Apache License, Version 2.0 (see LICENSE).

python_sources(
    name="lib",
    dependencies=[
        "helloworld/person/migrations",
    ]
)

python_tests(
    name="tests",
    dependencies=[
        "helloworld",  # For settings.py.
    ],
)

python_test_utils(
    name="test_utils",
)
4. api.py
Copy code
from ninja import NinjaAPI

api = NinjaAPI()

@api.get("/add")
def add(request, a:int, b:int):
    return {"result": a + b}
1
e
Pants is almost like magic, but sometimes you need to teach it things. Notice how the import statement does not match the dependency project name? You need a module mapping to tell pants that django-ninja supplies ninja: https://www.pantsbuild.org/docs/python-third-party-dependencies#requirements-with-undeclared-dependencies
c
Hi, @enough-analyst-54434 Thanks for the help! I will give a try!
Copy code
python_requirements(
    name="requirements",
    module_mapping={"django-ninja": ["ninja"]}
)
That works! Thanks a lot. @enough-analyst-54434