Skip to content

Commit

Permalink
pkg_resources is deprecated as an API
Browse files Browse the repository at this point in the history
  • Loading branch information
lemieuxl committed Mar 8, 2024
1 parent ab10308 commit a1e9cee
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 36 deletions.
28 changes: 15 additions & 13 deletions pyplink/tests/test_pyplink.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# THE SOFTWARE.


import atexit
import os
import platform
import random
Expand All @@ -32,6 +33,7 @@
import sys
import unittest
import zipfile
from contextlib import ExitStack
from io import UnsupportedOperation
from itertools import zip_longest
from shutil import which
Expand All @@ -40,9 +42,9 @@
from unittest import mock
from urllib.request import urlretrieve

import importlib_resources
import numpy as np
import pandas as pd
from pkg_resources import resource_filename

from .. import pyplink

Expand Down Expand Up @@ -123,19 +125,19 @@ def setUpClass(cls):
# Creating a temporary directory
cls.tmp_dir = mkdtemp(prefix="pyplink_test_")

file_manager = ExitStack()
atexit.register(file_manager.close)

# Getting the BED/BIM/FAM files
cls.bed = resource_filename(
__name__,
os.path.join("data", "test_data.bed"),
)
cls.bim = resource_filename(
__name__,
os.path.join("data", "test_data.bim"),
)
cls.fam = resource_filename(
__name__,
os.path.join("data", "test_data.fam"),
)
cls.bed = file_manager.enter_context(importlib_resources.as_file(
importlib_resources.files(__name__) / "data" / "test_data.bed"
)).as_posix()
cls.bim = file_manager.enter_context(importlib_resources.as_file(
importlib_resources.files(__name__) / "data" / "test_data.bim"
)).as_posix()
cls.fam = file_manager.enter_context(importlib_resources.as_file(
importlib_resources.files(__name__) / "data" / "test_data.fam"
)).as_posix()

# Getting the prefix of the files
cls.prefix = os.path.splitext(cls.bed)[0]
Expand Down
34 changes: 11 additions & 23 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@


import os
import sys
from setuptools import setup


MAJOR = 1
MINOR = 3
MICRO = 7
VERSION = "{}.{}.{}".format(MAJOR, MINOR, MICRO)
MICRO = 8
VERSION = f"{MAJOR}.{MINOR}.{MICRO}b1"


def write_version_file(fn=None):
"""Write the version file."""
if fn is None:
fn = os.path.join(
os.path.dirname(os.path.abspath(__file__)),
Expand All @@ -31,30 +31,16 @@ def write_version_file(fn=None):
'pyplink_version = "{version}"\n'
)

a = open(fn, "w")
try:
a.write(content.format(version=VERSION))
finally:
a.close()


def get_requirements():
# Initial requirements
requirements = ["numpy >= 1.8.2", "pandas >= 0.17.1"]

# Checking if python 2 (requires mock)
if sys.version_info[0] == 2:
requirements.append(["mock >= 2.0.0"])

return requirements
with open(fn, "w") as f:
f.write(content.format(version=VERSION))


def setup_package():
"""Setup the package."""
# Saving the version into a file
write_version_file()

setup(
zip_safe=False,
name="pyplink",
version=VERSION,
description="Python module to read binary Plink files.",
Expand All @@ -65,7 +51,11 @@ def setup_package():
packages=["pyplink", "pyplink.tests"],
package_data={"pyplink.tests": ["data/*"], },
test_suite="pyplink.tests.test_suite",
install_requires=get_requirements(),
install_requires=[
"numpy >= 1.8.2",
"pandas >= 0.17.1",
"importlib_resources >= 5.12.0",
],
classifiers=["Operating System :: POSIX :: Linux",
"Operating System :: MacOS :: MacOS X",
"Operating System :: Microsoft",
Expand All @@ -82,8 +72,6 @@ def setup_package():
keywords="bioinformatics format Plink binary",
)

return


if __name__ == "__main__":
setup_package()

0 comments on commit a1e9cee

Please sign in to comment.