mirror of
https://github.com/wassname/cookiecutter-data-science.git
synced 2026-07-20 12:20:46 +08:00
92 lines
2.0 KiB
Python
92 lines
2.0 KiB
Python
import os
|
|
from urllib.request import urlretrieve
|
|
|
|
|
|
packages = [
|
|
'flake8',
|
|
'pathlib2',
|
|
'pip',
|
|
'setuptools',
|
|
'wheel',
|
|
]
|
|
|
|
pip_only_packages = [
|
|
'awscli',
|
|
'python-dotenv',
|
|
]
|
|
|
|
{% if cookiecutter.dataset_storage.s3 %}
|
|
packages += ['awscli']
|
|
{% endif %}
|
|
|
|
{% if cookiecutter.pydata_packages == "basic" %}
|
|
packages += [
|
|
'ipython',
|
|
'jupyter',
|
|
'matplotlib',
|
|
'numpy',
|
|
'pandas',
|
|
'scikit-learn',
|
|
]
|
|
{% endif %}
|
|
|
|
{% if cookiecutter.nbautoexport == "yes" %}
|
|
packages += ['nbautoexport']
|
|
{% 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))
|
|
f.write("\n")
|
|
|
|
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()
|
|
|
|
{% if cookiecutter.ethics_checklist == "yes" %}
|
|
urlretrieve(
|
|
"https://raw.githubusercontent.com/drivendataorg/deon/master/examples/ethics.md",
|
|
"ethics.md"
|
|
)
|
|
{% endif %}
|