Add dependencies
  • 23 Aug 2024
  • 1 Minute to read
  • Dark
    Light
  • PDF

Add dependencies

  • Dark
    Light
  • PDF

Article summary

Adding dependencies to your module

In the following steps, we are use the example of using qrcode to build this module.

Edit the setup.py file, adding qrcode to install_requires as shown here.

setup(
    name="cb_django_qr",
    version="0.1",
    packages=["qr"],
    install_requires=["qrcode"],
    cmdclass={"build": BuildCommand},
)

Test your work by installing the module in the demo app and confirming that the library was installed.

cb add django-qr
cd demo/backend
pipenv install
pipenv graph | grep qrcode -B 1 -A 2

You should see the following output:

Loading .env environment variables...
cb-django-qr==0.1
└── qrcode [required: Any, installed: 7.4.2]
    ├── pypng [required: Any, installed: 0.20220715.0]
    └── typing-extensions [required: Any, installed: 4.9.0]

You can add other dependencies as well. For example:

  • Depend on specific versions of the package.

  • Enforce a minimum python version.

Refer to the Requirement Specifiers section of the pip.pypa.io documentation to learn about the syntax possibilities.


Was this article helpful?