
上QQ阅读APP看书,第一时间看更新
How to do it...
Manually create requirements.txt by typing in the packages to include in the project. The following is an example from https://pip.pypa.io/en/latest/reference/pip_install/#requirements-file-format:
- Alternatively, run pip freeze > requirements.txt. This automatically directs the currently installed packages to a properly formatted requirements file.
- To implement hash-checking mode, simply include the digest with the package name in the requirements file, demonstrated below:
FooProject == 1.2 --hash=sha256:<hash_digest>
Note: Supported hash algorithms include: md5, sha1, sha224, sha384, sha256, and sha512.
- If there are module conflicts, or special versioning is needed, provide the first module required:
m1
- Indicate the second module, but ensure the version installed pre-dates the known bad version:
m2<1.7
- Provide the third module, ensuring it is at least equal to the minimum version required, but no greater than the maximum version that can be used:
m3>=1.5, <=2.0
While the preceding screenshot shows some version specifier requirements, here is an example showing some of the different ways to specify module versions in requirements.txt:
flask
flask-pretty == 0.2.0
flask-security <= 3.0
flask-oauthlib >= 0.9.0, <= 0.9.4