Skip to content

Fix pkg_resources Deprecated Warning needed #10

@hwprinz

Description

@hwprinz

can you please update __init__.py
as follows:

# Try to use the new importlib.resources, fall back to pkg_resources
try:
    from importlib import resources
    
    def get_resource_filename(package_name, resource_name):
        try:
            # For Python 3.9+
            return str(resources.files(package_name) / resource_name)
        except AttributeError:
            # For Python 3.7-3.8
            with resources.path(package_name, resource_name) as path:
                return str(path)
except ImportError:
    import warnings
    warnings.filterwarnings("ignore", category=UserWarning, message="pkg_resources is deprecated")
    from pkg_resources import resource_filename
    
    def get_resource_filename(package_name, resource_name):
        return resource_filename(package_name, resource_name)

PREPACKAGED_MODELS_DIR = get_resource_filename(__name__, "pretrained")

from .perth_net_implicit.perth_watermarker import PerthImplicitWatermarker```

Thanks a lot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions