From e2cf9808b62a3ab452f1e4dde204321c78cb9ced Mon Sep 17 00:00:00 2001 From: Florian Gaudin-Delrieu <9217921+FlorianGD@users.noreply.github.com> Date: Fri, 30 Sep 2022 15:01:04 +0200 Subject: [PATCH] Fix micro package pull from PyPI (#1848) Signed-off-by: Florian Gaudin-Delrieu --- RELEASE.md | 7 +++++-- kedro/framework/cli/micropkg.py | 13 ++++++------- tests/framework/cli/micropkg/test_micropkg_pull.py | 7 +++++-- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/RELEASE.md b/RELEASE.md index 2dad086227..b66aae9b76 100644 --- a/RELEASE.md +++ b/RELEASE.md @@ -13,11 +13,14 @@ ## Major features and improvements ## Bug fixes and other changes +* Fixed `kedro micropkg pull` for packages on PyPI. +* Fixed `format` in `save_args` for `SparkHiveDataSet`, previously it didn't allow you to save it as delta format. -## Upcoming deprecations for Kedro 0.19.0 +## Minor breaking changes to the API +## Upcoming deprecations for Kedro 0.19.0 * `kedro test` and `kedro lint` will be deprecated. -* Fixed `format` in `save_args` for `SparkHiveDataSet`, previously it didn't allow you to save it as delta format. + # Release 0.18.3 diff --git a/kedro/framework/cli/micropkg.py b/kedro/framework/cli/micropkg.py index fa6557fa09..3242e18e81 100644 --- a/kedro/framework/cli/micropkg.py +++ b/kedro/framework/cli/micropkg.py @@ -141,18 +141,17 @@ def _pull_package( ): with tempfile.TemporaryDirectory() as temp_dir: temp_dir_path = Path(temp_dir).resolve() - _unpack_sdist(package_path, temp_dir_path, fs_args) - sdist_file_name = Path(package_path).name.rstrip(".tar.gz") - egg_info_file = list((temp_dir_path / sdist_file_name).glob("*.egg-info")) - if len(egg_info_file) != 1: + egg_info_files = list((temp_dir_path).rglob("*.egg-info")) + if len(egg_info_files) != 1: raise KedroCliError( f"More than 1 or no egg-info files found from {package_path}. " f"There has to be exactly one egg-info directory." ) - package_name = egg_info_file[0].stem - package_requirements = temp_dir_path / sdist_file_name / "setup.py" + egg_info_file = egg_info_files[0] + package_name = egg_info_file.stem + package_requirements = egg_info_file.parent / "setup.py" # Finds a string representation of 'install_requires' list from setup.py reqs_list_pattern = r"install_requires\=(.*?)\,\n" @@ -172,7 +171,7 @@ def _pull_package( _install_files( metadata, package_name, - temp_dir_path / sdist_file_name, + egg_info_file.parent, env, alias, destination, diff --git a/tests/framework/cli/micropkg/test_micropkg_pull.py b/tests/framework/cli/micropkg/test_micropkg_pull.py index f557e40d08..1893fd580b 100644 --- a/tests/framework/cli/micropkg/test_micropkg_pull.py +++ b/tests/framework/cli/micropkg/test_micropkg_pull.py @@ -627,9 +627,12 @@ def test_pull_from_pypi( options = ["-e", env] if env else [] options += ["--alias", alias] if alias else [] + + package_name = "my-pipeline" + result = CliRunner().invoke( fake_project_cli, - ["micropkg", "pull", f"{PIPELINE_NAME}-{version}", *options], + ["micropkg", "pull", package_name, *options], obj=fake_metadata, ) assert result.exit_code == 0 @@ -642,7 +645,7 @@ def test_pull_from_pypi( "--no-deps", "--dest", str(tmp_path), - f"{PIPELINE_NAME}-{version}", + package_name, ], )