8 examples of 'generate requirements.txt python' in Python

Every line of '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())
Important

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())
39def install_requirements() -> [str]:
40 return read_requirements_file("requirements.txt")
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
100
101 print 'Installing requirements...'
102
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', '.')
106
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()]
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')]
35@staticmethod
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)
10@contextmanager
11def _generate_requirements_file(ctx):
12 requirements_path = os.path.join(ctx['env_path'], 'requirements.txt')
13 tmp_requirement_path = os.path.join(ctx['env_path'], 'tmp_requirements.txt')
14 requirements = [_req for _req in parse_requirements(requirements_path)]
15 with open(tmp_requirement_path, 'w+') as file:
16 file.writelines('\n'.join(requirements))
17 yield
18 ctx.run('rm {env_path}/tmp_requirements.txt'.format(**ctx))

Related snippets