mirror of
https://github.com/wassname/cookiecutter-data-science.git
synced 2026-06-27 18:42:27 +08:00
66 lines
1.5 KiB
Python
66 lines
1.5 KiB
Python
import os
|
|
|
|
packages = [
|
|
'flake8',
|
|
'pathlib2',
|
|
'pip',
|
|
'setuptools',
|
|
'wheel',
|
|
]
|
|
|
|
pip_only_packages = [
|
|
'awscli',
|
|
'python-dotenv',
|
|
]
|
|
|
|
{% if cookiecutter.data_storage.s3 %}
|
|
packages += ['awscli']
|
|
{% endif %}
|
|
|
|
dependencies = '{{ cookiecutter.dependency_file }}'
|
|
|
|
def write_dependencies():
|
|
if dependencies == 'requirements.txt':
|
|
with open(dependencies, 'w') as f:
|
|
lines = sorted(packages + pip_only_packages)
|
|
|
|
lines += [
|
|
""
|
|
"-e ."
|
|
]
|
|
|
|
f.write("\n".join(lines))
|
|
|
|
elif dependencies == 'environment.yml':
|
|
with open(dependencies, 'w') as f:
|
|
lines = ["name: {{ cookiecutter.repo_name }}",
|
|
"dependencies:"]
|
|
|
|
lines += [f" - {p}" for p in packages]
|
|
|
|
lines += [" - pip:"] + [f" - {p}" for p in pip_only_packages]
|
|
|
|
lines += [' - -e .']
|
|
|
|
lines += [" - python={{ cookiecutter.python_version_number }}"]
|
|
|
|
f.write("\n".join(lines))
|
|
|
|
|
|
elif dependencies == 'Pipfile':
|
|
with open(dependencies, 'w') as f:
|
|
lines = ["[packages]"]
|
|
lines += [f'{p} = "*"' for p in sorted(packages + pip_only_packages)]
|
|
|
|
lines += ['"{{ cookiecutter.module_name }}" = {editable = true, path = "."}']
|
|
|
|
lines += [
|
|
"",
|
|
"[requires]",
|
|
'python_version = "{{ cookiecutter.python_version_number }}"'
|
|
]
|
|
|
|
f.write("\n".join(lines))
|
|
|
|
|
|
write_dependencies() |