pkg_resources -> importlib.resources

This commit is contained in:
Benoît Sierro
2023-08-08 15:00:14 +02:00
parent 3842d761ce
commit a650169443
3 changed files with 3 additions and 3 deletions

1
.gitignore vendored
View File

@@ -1,6 +1,5 @@
.DS_store
.idea
**/*.npy
.conda-env
/play.py

Binary file not shown.

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
import datetime
import importlib
import json
import os
from dataclasses import dataclass
@@ -9,12 +10,12 @@ from typing import BinaryIO, Protocol, Sequence
from zipfile import ZipFile
import numpy as np
import pkg_resources
def data_file(path: str) -> Path:
"""returns a `Path` object pointing to the desired data file included in `scgenerator`"""
return Path(pkg_resources.resource_filename("scgenerator", path))
file = importlib.resources.files("scgenerator") / "data" / path
return importlib.resources.as_file(file)
class CustomEncoder(json.JSONEncoder):