1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
From 734056593b485a38420ffa62dc02649dffb71070 Mon Sep 17 00:00:00 2001
From: Tieqiong Zhang <tz2600@columbia.edu>
Date: Thu, 17 Jul 2025 17:53:24 -0400
Subject: [PATCH] Update build script to remove pkg_resources
--- a/src/pyobjcryst/tests/__init__.py
+++ b/src/pyobjcryst/tests/__init__.py
@@ -37,9 +37,9 @@
import re
from os.path import dirname
from itertools import chain
- from pkg_resources import resource_filename
+ from importlib.resources import files
loader = unittest.defaultTestLoader
- thisdir = resource_filename(__name__, '')
+ thisdir = files(__name__)
depth = __name__.count('.') + 1
topdir = thisdir
for i in range(depth):
--- a/src/pyobjcryst/tests/pyobjcrysttestutils.py
+++ b/src/pyobjcryst/tests/pyobjcrysttestutils.py
@@ -149,8 +149,8 @@
def datafile(filename):
- from pkg_resources import resource_filename
- rv = resource_filename(__name__, "testdata/" + filename)
+ from importlib.resources import files
+ rv = str(files(__name__).joinpath("testdata", filename))
return rv
--- a/src/pyobjcryst/tests/testmolecule.py
+++ b/src/pyobjcryst/tests/testmolecule.py
@@ -17,7 +17,7 @@
import io
import unittest
-from pkg_resources import resource_filename
+from importlib.resources import files
from pyobjcryst import ObjCrystException
from pyobjcryst.crystal import Crystal
from pyobjcryst.molecule import (
@@ -446,7 +446,7 @@
def testZMatrix(self):
"""Test creating a Molecule from a z-matrix"""
- fname = resource_filename(__name__, "testdata/cime.fhz")
+ fname = str(files(__name__).joinpath("testdata", "cime.fhz"))
c= Crystal()
m = ImportFenskeHallZMatrix(c, fname)
assert m.GetNbAtoms() == 17
--- a/src/pyobjcryst/version.py
+++ b/src/pyobjcryst/version.py
@@ -28,12 +28,12 @@
import os.path
-from pkg_resources import resource_filename
-
+from importlib.metadata import distribution
# obtain version information from the version.cfg file
cp = dict(version='', date='', commit='', timestamp='0')
-fcfg = resource_filename(__name__, 'version.cfg')
+#fcfg = distribution('pyobjcryst').locate_file('version.cfg')
+fcfg = '/usr/lib/python3/dist-packages/pyobjcryst/version.cfg'
if not os.path.isfile(fcfg): # pragma: no cover
from warnings import warn
warn('Package metadata not found, execute "./setup.py egg_info".')
|