Skip to content

Commit

Permalink
Avoid adding problematic lines to requirements.txt
Browse files Browse the repository at this point in the history
kedro is preinstalled in the behave environment,
so this should not be needed.
In exchange, requirements.txt files can always be read
by setuptools automatic parsing.

See McK-Private/private-kedro#352 (comment)
for motivation of the original logic.

Signed-off-by: Juan Luis Cano Rodríguez <juan_luis_cano@mckinsey.com>
  • Loading branch information
astrojuanlu committed Jul 11, 2023
1 parent 77a784c commit 8ba3dc5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
1 change: 0 additions & 1 deletion features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def _setup_context_with_venv(context, venv_dir):
context.pip = str(bin_dir / "pip")
context.python = str(bin_dir / "python")
context.kedro = str(bin_dir / "kedro")
context.requirements_path = Path("dependency/requirements.txt").resolve()

# clone the environment, remove any condas and venvs and insert our venv
context.env = os.environ.copy()
Expand Down
8 changes: 3 additions & 5 deletions features/steps/cli_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -407,18 +407,16 @@ def update_pyproject_toml(context: behave.runner.Context, new_source_dir):

@given("I have updated kedro requirements")
def update_kedro_req(context: behave.runner.Context):
"""Replace kedro as a standalone requirement with a line
that includes all of kedro's dependencies (-r kedro/requirements.txt)
"""
"""Remove kedro as a standalone requirement."""
reqs_path = context.root_project_dir / "src" / "requirements.txt"
kedro_reqs = f"-r {context.requirements_path.as_posix()}"

if reqs_path.is_file():
old_reqs = reqs_path.read_text().splitlines()
new_reqs = []
for req in old_reqs:
if req.startswith("kedro"):
new_reqs.append(kedro_reqs)
# Do not include kedro as it's preinstalled in the environment
pass
else:
new_reqs.append(req)
new_reqs = "\n".join(new_reqs)
Expand Down

0 comments on commit 8ba3dc5

Please sign in to comment.