From 2a670ba872d8ce6570765c3b89bc14788fdd982e Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 1 Oct 2024 17:11:48 -0500 Subject: [PATCH] Use importlib metadata instead of pkg resources (#133) --- src/packse/fetch.py | 7 +++--- tests/__snapshots__/test_fetch.ambr | 36 ----------------------------- 2 files changed, 3 insertions(+), 40 deletions(-) diff --git a/src/packse/fetch.py b/src/packse/fetch.py index 6ee4764c..12b38fda 100644 --- a/src/packse/fetch.py +++ b/src/packse/fetch.py @@ -1,3 +1,4 @@ +import importlib.metadata import logging import shutil import subprocess @@ -5,8 +6,6 @@ import time from pathlib import Path -import pkg_resources - from packse.error import DestinationAlreadyExists logger = logging.getLogger(__name__) @@ -26,7 +25,7 @@ def fetch( raise DestinationAlreadyExists(dest) if not ref: - ref = pkg_resources.get_distribution("packse").version + ref = importlib.metadata.version("packse") if ref == "0.0.0": ref = "HEAD" @@ -71,7 +70,7 @@ def fetch( file_count = 0 for file in sorted(src.iterdir()): file_count += 1 - logger.info("Found %s", file.name) + logger.debug("Found %s", file.name) logger.info("Copying files into '%s'", dest) shutil.copytree(src, dest, dirs_exist_ok=True) diff --git a/tests/__snapshots__/test_fetch.ambr b/tests/__snapshots__/test_fetch.ambr index 15d55091..28f66a04 100644 --- a/tests/__snapshots__/test_fetch.ambr +++ b/tests/__snapshots__/test_fetch.ambr @@ -32,15 +32,6 @@ 'stderr': ''' Cloning repository https://github.com/astral-sh/packse Checking out directory 'scenarios' at ref df20b898fdf1fd242cc19acc2a3148d72aa4d89f - Found does-not-exist.json - Found example.json - Found excluded.json - Found extras.json - Found incompatible-versions.json - Found prereleases.json - Found requires-python.json - Found wheels.json - Found yanked.json Copying files into '[PWD]/scenarios' Fetched 9 files in [TIME] @@ -81,15 +72,6 @@ 'stderr': ''' Cloning repository https://github.com/astral-sh/packse Checking out directory 'scenarios' at ref df20b898fdf1fd242cc19acc2a3148d72aa4d89f - Found does-not-exist.json - Found example.json - Found excluded.json - Found extras.json - Found incompatible-versions.json - Found prereleases.json - Found requires-python.json - Found wheels.json - Found yanked.json Copying files into 'foo' Fetched 9 files in [TIME] @@ -149,15 +131,6 @@ 'stderr': ''' Cloning repository https://github.com/astral-sh/packse Checking out directory 'scenarios' at ref df20b898fdf1fd242cc19acc2a3148d72aa4d89f - Found does-not-exist.json - Found example.json - Found excluded.json - Found extras.json - Found incompatible-versions.json - Found prereleases.json - Found requires-python.json - Found wheels.json - Found yanked.json Copying files into 'foo' Fetched 9 files in [TIME] @@ -198,15 +171,6 @@ 'stderr': ''' Cloning repository https://github.com/astral-sh/packse Checking out directory 'scenarios' at ref 0.1.0 - Found does-not-exist.json - Found example.json - Found excluded.json - Found extras.json - Found incompatible-versions.json - Found prereleases.json - Found requires-python.json - Found wheels.json - Found yanked.json Copying files into '[PWD]/scenarios' Fetched 9 files in [TIME]