Skip to content

Commit

Permalink
Migrate default project template to static project metadata
Browse files Browse the repository at this point in the history
Uses `requirements.txt` for dev requirements in project template.

Fix gh-2280.
Fix gh-2519.

Signed-off-by: Juan Luis Cano Rodríguez <juan_luis_cano@mckinsey.com>
  • Loading branch information
astrojuanlu committed May 26, 2023
1 parent ced5ba9 commit 3a447b1
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 59 deletions.
4 changes: 2 additions & 2 deletions features/environment.py
Expand Up @@ -117,12 +117,12 @@ def _setup_minimal_env(context):
def _install_project_requirements(context):
install_reqs = (
Path(
"kedro/templates/project/{{ cookiecutter.repo_name }}/src/requirements.txt"
"kedro/templates/project/{{ cookiecutter.repo_name }}/requirements.txt"
)
.read_text(encoding="utf-8")
.splitlines()
)
install_reqs = [req for req in install_reqs if "{" not in req]
install_reqs = [req for req in install_reqs if ("{" not in req) and (not req.startswith("-e"))]
install_reqs.append(".[pandas.CSVDataSet]")
call([context.pip, "install", *install_reqs], env=context.env)
return context
12 changes: 0 additions & 12 deletions kedro/templates/project/{{ cookiecutter.repo_name }}/README.md
Expand Up @@ -64,25 +64,13 @@ After this, if you'd like to update your project requirements, please update `re
> Jupyter, JupyterLab, and IPython are already included in the project requirements by default, so once you have run `pip install -r requirements.txt` you will not need to take any extra steps before you use them.
### Jupyter
To use Jupyter notebooks in your Kedro project, you need to install Jupyter:

```
pip install jupyter
```

After installing Jupyter, you can start a local notebook server:

```
kedro jupyter notebook
```

### JupyterLab
To use JupyterLab, you need to install it:

```
pip install jupyterlab
```

You can also start JupyterLab:

```
Expand Down
@@ -1,3 +1,52 @@
[build-system]
requires = ["setuptools"]
build-backend = "setuptools.build_meta"

[project]
name = "{{ cookiecutter.python_package }}"
dependencies = [
"kedro~={{ cookiecutter.kedro_version }}",
]
dynamic = ["version"]

[project.scripts]
{{ cookiecutter.repo_name }} = "{{ cookiecutter.python_package }}.__main__:main"

[project.optional-dependencies]
docs = [
"docutils<0.18.0",
"sphinx~=3.4.3",
"sphinx_rtd_theme==0.5.1",
"nbsphinx==0.8.1",
"nbstripout~=0.4",
"sphinx-autodoc-typehints==1.11.1",
"sphinx_copybutton==0.3.1",
"ipykernel>=5.3, <7.0",
"Jinja2<3.1.0",
"myst-parser~=0.17.2",
]
dev = [
"black~=22.0",
"flake8>=3.7.9, <5.0",
"ipython>=7.31.1, <8.0; python_version < '3.8'",
"ipython~=8.10; python_version >= '3.8'",
"isort~=5.0",
"jupyter~=1.0",
"jupyterlab_server>=2.11.1, <2.16.0",
"jupyterlab~=3.0, <3.6.0",
"nbstripout~=0.4",
"pytest-cov~=3.0",
"pytest-mock>=1.7.1, <2.0",
"pytest~=7.2",
]

[tool.setuptools.dynamic]
version = {attr = "{{ cookiecutter.python_package }}.__version__"}

[tool.setuptools.packages.find]
where = ["src"]
namespaces = false

[tool.kedro]
package_name = "{{ cookiecutter.python_package }}"
project_name = "{{ cookiecutter.project_name }}"
Expand Down
@@ -1,3 +1,7 @@
# Install library code
-e file:.

# Development dependencies
black~=22.0
flake8>=3.7.9, <5.0
ipython>=7.31.1, <8.0; python_version < '3.8'
Expand All @@ -6,8 +10,6 @@ isort~=5.0
jupyter~=1.0
jupyterlab_server>=2.11.1, <2.16.0
jupyterlab~=3.0, <3.6.0
kedro~={{ cookiecutter.kedro_version }}
kedro-telemetry~=0.2.0
nbstripout~=0.4
pytest-cov~=3.0
pytest-mock>=1.7.1, <2.0
Expand Down
39 changes: 0 additions & 39 deletions kedro/templates/project/{{ cookiecutter.repo_name }}/setup.py

This file was deleted.

6 changes: 2 additions & 4 deletions tests/framework/cli/test_starters.py
Expand Up @@ -17,7 +17,7 @@
KedroStarterSpec,
)

FILES_IN_TEMPLATE = 31
FILES_IN_TEMPLATE = 29


@pytest.fixture
Expand Down Expand Up @@ -70,9 +70,7 @@ def _assert_template_ok(
assert (full_path / ".gitignore").is_file()
assert project_name in (full_path / "README.md").read_text(encoding="utf-8")
assert "KEDRO" in (full_path / ".gitignore").read_text(encoding="utf-8")
assert kedro_version in (full_path / "src" / "requirements.txt").read_text(
encoding="utf-8"
)
assert kedro_version in (full_path / "pyproject.toml").read_text(encoding="utf-8")
assert (full_path / "src" / python_package / "__init__.py").is_file()


Expand Down

0 comments on commit 3a447b1

Please sign in to comment.