Skip to content

Commit

Permalink
substitute deprecated pkg_resources import
Browse files Browse the repository at this point in the history
  • Loading branch information
mschwoer committed Sep 4, 2024
1 parent 1e3123c commit 33e71bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
13 changes: 10 additions & 3 deletions alphastats/loader/BaseLoader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
import os
import numpy as np
from alphastats.utils import find_duplicates_in_list
import pkg_resources
from typing import Union

import sys

if sys.version_info >= (3, 9):
import importlib.resources as importlib_resources
else:
# TODO drop this together with support for python 3.8
import importlib_resources


class BaseLoader:
"""Parent class of Loaders"""
Expand Down Expand Up @@ -74,8 +81,8 @@ def _check_if_file_exists(self, file):

def _add_contamination_column(self):
#  load df with potential contamination from fasta file
contaminations_path = pkg_resources.resource_filename(
__name__, "../data/contaminations.txt"
contaminations_path = (
importlib_resources.files(__name__) / "../data/contaminations.txt"
)
contaminations = pd.read_csv(contaminations_path, sep="\t")
contaminations_ids = contaminations["Uniprot ID"].to_list()
Expand Down
1 change: 0 additions & 1 deletion release/pyinstaller/alphastats.spec
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import os
import sys
from PyInstaller.building.build_main import Analysis, PYZ, EXE, COLLECT, BUNDLE, TOC
import PyInstaller.utils.hooks
import pkg_resources
import importlib.metadata
import alphastats
from PyInstaller.utils.hooks import collect_submodules
Expand Down

0 comments on commit 33e71bb

Please sign in to comment.