Skip to content

Commit

Permalink
Use importlib metadata instead of pkg resources (#133)
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb authored Oct 1, 2024
1 parent 4b2ee8d commit 2a670ba
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 40 deletions.
7 changes: 3 additions & 4 deletions src/packse/fetch.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import importlib.metadata
import logging
import shutil
import subprocess
import tempfile
import time
from pathlib import Path

import pkg_resources

from packse.error import DestinationAlreadyExists

logger = logging.getLogger(__name__)
Expand All @@ -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"

Expand Down Expand Up @@ -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)
Expand Down
36 changes: 0 additions & 36 deletions tests/__snapshots__/test_fetch.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down Expand Up @@ -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]

Expand Down

0 comments on commit 2a670ba

Please sign in to comment.