It seems that Pipfile/Pipfile.lock are intended to be replacements for requirements.txt, in the context of Python packaging. There isn't much documentation out there on how these actually work, however. I found an evolving description of pipfile on the PyPi section of the Python website here but it's pretty messy and doesn't explain the semantics of the different sections of the file.
Any pointers on how to understand these files?
The concept behind these files is simple and analogue to other already existing tools, if you have some familiarity with Ruby's Bundler or Node's Npm. A package management tool
Pipenv
is using the Pipfile and Pipfile.lock standard.Pipenv is handling the virtual environment for you in one default standard way (no more activate and deactivate required). Below, some basics to get you started, see more at pipenv website.
Getting Started
Start using pipenv is easy, in your project folder type...
... and if it already have a
requirements.txt
file, it will generate aPipfile
file with the requirements and a virtual environment folder, otherwise, it will generate an emptyPipfile
file. If you dislike or changed your mind about something that you have installed, just type...... and you're good to go. To activate the virtual environment that pipenv already generated, go with...
... and your virtual environment will be activated. To leave the environment...
... and you will be back to your original bash/powershell session.
Pipfile
The Pipfile file is intended to specify packages requirements for your Python application or library, both to development and execution. You can install a package by simply using...
... and it will be added as a dependency for deployment and execution or by using ...
... and it will be used as a depencency for development time. The file syntax is pretty straight forward, as follows.
Pipfile.lock
The Pipfile.lock is intended to specify, based on the packages present in Pipfile, which specific version of those should be used, avoiding the risks of automatically upgrading packages that depend upon each other and breaking your project dependency tree.
You can lock your currently installed packages using...
... and the tool will lookup your virtual environment folder to generate the lock file for you automatically, based on the currently installed versions. The file syntax is not as obvious as is for Pipfile , so for the sake of conciseness, it will not be displayed here.
Still have any doubts? Let me know, so I can improve the answer, for others to learn from it. I have already migrated my projects to it and I am using it on daily basis at my job, it is worth it ;)