10 examples of 'how to generate requirements.txt python' in Python

Every line of 'how to generate requirements.txt python' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.

All examples are scanned by Snyk Code

By copying the Snyk Code Snippets you agree to
this disclaimer
425def write_setup_requirements(cmd, basename, filename):
426 data = StringIO()
427 _write_requirements(data, cmd.distribution.setup_requires)
428 cmd.write_or_delete_file("setup-requirements", filename, data.getvalue())

Use secure code every time

Secure your code as it's written. Use Snyk Code to scan source code in minutes – no build needed – and fix issues immediately. Enable Snyk Code

656def write_setup_requirements(cmd, basename, filename):
657 data = io.StringIO()
658 _write_requirements(data, cmd.distribution.setup_requires)
659 cmd.write_or_delete_file("setup-requirements", filename, data.getvalue())
32def _requirements():
33 with open('requirements.txt', 'r') as fd:
34 return [name.strip() for name in fd.readlines()]
39def install_requirements() -> [str]:
40 return read_requirements_file("requirements.txt")
8def get_requirements():
9 """Return the components defined in requirements.txt."""
10 with open('requirements.txt') as fin:
11 return [l.split()[0].split('#', 1)[0].strip() for l in fin
12 if l and not l.startswith('git')]
96def install_requirements():
97 # TODO: Detect when requirements.txt changes instead of checking for a file
98 if os.path.exists(requirements_installed_path):
99 return
101 print 'Installing requirements...'
103 shell(pip_path, 'install', '-r', 'requirements.txt')
104 shell(pip_path, 'install', os.path.join(vendor_path, 'nose-1.1.2.tar.gz'))
105 shell(pip_path, 'install', '-e', '.')
107 open(requirements_installed_path, 'w').close()
31def extract_requirements(filename):
32 with open(filename, 'r') as requirements_file:
33 return [x[:-1] for x in requirements_file.readlines()]
36def requirements(fname):
37 """
38 Create a list of requirements from the output of the pip freeze command
39 saved in a text file.
40 """
41 packages = Setup.read(fname, fail_silently=True).split('\n')
42 packages = (p.strip() for p in packages)
43 packages = (p for p in packages if p and not p.startswith('#'))
44 packages = (p for p in packages if p and not p.startswith('https://'))
45 return list(packages)
17def get_requirements():
18 """Loads contents from requirements.txt."""
19 requirements = []
20 with open('requirements.txt') as f:
21 data = f.read().splitlines()
22 if any(data):
23 data = data[1:]
24 requirements = [item.split(";")[0].split(" ")[0] for item in data]
25 return requirements
53def install_requirements():
54 prep_apt_get()
55 install_system_requirements()
56 install_virtualenv()
57 install_nginx()

Related snippets