I am attempting to deploy a django web-app to an Azure web server. According to the documentation, for dependencies, it automatically looks for either a requirements.txt
or a setup.py
. (https://learn.microsoft.com/en-us/azure/app-service/configure-language-python#could-not-find-setuppy-or-requirementstxt).
Due to a bug in one of the sub dependencies of one of the packages, I cannot use a requirements.txt
(See the 3rd comment of the answer of the following: AttributeError: type object 'Callable' has no attribute '_abc_registry').
And instead, I must use a Pipfile.lock
file instead. Just wondering how to actually use this in the install step. I am presuming I have to use the only other option which is a setup.py
file, but I’m not sure what this file would look like. All the documentation I have seen online doesn’t involve running a Pipfile in the setup.py script.
Any help is appreciated~
2
Answers
To deploy a Django web app to Azure using a Pipfile.lock instead of a requirements.txt, modify the setup.py file to read the Pipfile.lock and extract the dependencies, then use the extracted dependencies in the install_requires argument of the setup() function. This allows Azure to install the specified dependencies during deployment.
In my Django app, I generated piplock file by using the method below:-
My Pipfile.lock:-
Now create a setup.py file like below and run it:-
setup.py file:-
And install the setup.py file by running the command below:-