Skip to content

Commit

Permalink
Remove dependence on pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
bennybp committed Oct 25, 2023
1 parent 941a751 commit 03c602d
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test-pip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ jobs:
# most of the dependencies
- name: Install dependencies with PIP
run: |
pip install numpy networkx six pytest pytest-cov ase
pip install packaging numpy networkx six pytest pytest-cov ase
# rdkit: PyPi only supplies it for 3.7 and above
# rdkit: PyPi only supplies it for 3.7-3.11
- name: Install rdkit
if: matrix.python-version != '3.12'
run: |
Expand Down
1 change: 1 addition & 0 deletions devtools/conda-envs/latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies:
# geomeTRIC base depends
- numpy
- networkx
- packaging

# Testing
- pytest
Expand Down
3 changes: 3 additions & 0 deletions geometric/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Path to this configuration directory
import os
config_dir = os.path.dirname(os.path.abspath(__file__))
4 changes: 1 addition & 3 deletions geometric/molecule.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from __future__ import division
from __future__ import print_function

import copy
import itertools
import os
import re
Expand All @@ -12,12 +11,11 @@
from collections import OrderedDict, namedtuple, Counter
from ctypes import *
from datetime import date
from warnings import warn

import numpy as np
from numpy import sin, cos, arccos
from numpy.linalg import multi_dot
from pkg_resources import parse_version
from packaging.version import parse as parse_version

# For Python 3 compatibility
try:
Expand Down
5 changes: 2 additions & 3 deletions geometric/neb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import numpy as np
from copy import deepcopy
from datetime import datetime
import pkg_resources
from .info import print_logo, print_citation
from .prepare import get_molecule_engine
from .optimize import Optimize
Expand All @@ -17,6 +16,7 @@
from .nifty import flat, row, col, createWorkQueue, getWorkQueue, wq_wait, ang2bohr, bohr2ang, kcal2au, au2kcal, au2evang, logger
from .molecule import EqualSpacing
from .errors import NEBStructureError, NEBChainShapeError, NEBChainRespaceError, NEBBandTangentError, NEBBandGradientError
from .config import config_dir

def print_forces(chain, avgg, maxg):
"""Check average and maximum chain forces and return color coded string"""
Expand Down Expand Up @@ -1648,8 +1648,7 @@ def main():
params = NEBParams(**args)

if args.get('logIni') is None:
import geometric.neb
logIni = pkg_resources.resource_filename(geometric.neb.__name__, r'config/log.ini')
logIni = os.path.join(config_dir, 'logJson.ini')
else:
logIni = args.get('logIni')

Expand Down
6 changes: 3 additions & 3 deletions geometric/normal_modes.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,9 +836,9 @@ def wigner_sample(coords, mass, elem, freqs_wavenumber, normal_modes, temperatur
print("Wigner distribution sample generation: %s samples %s" % (commadash(ovr_idx), 'overwritten' if overwrite else 'skipped'))

def main(): # pragma: no cover
import logging.config, pkg_resources
import geometric.optimize
logIni = pkg_resources.resource_filename(geometric.optimize.__name__, 'config/logTest.ini')
from geometric.config import config_dir
import logging.config
logIni = os.path.join(config_dir, 'logTest.ini')
logging.config.fileConfig(logIni,disable_existing_loggers=False)
M = Molecule("start.xyz")
coords = M.xyzs[0] / bohr2ang
Expand Down
6 changes: 2 additions & 4 deletions geometric/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@
import sys
import time
import traceback
import pkg_resources
from copy import deepcopy
from datetime import datetime

import numpy as np
from numpy.linalg import multi_dot

import geometric
from .info import print_logo, print_citation
from .internal import CartesianCoordinates, PrimitiveInternalCoordinates, DelocalizedInternalCoordinates
from .ic_tools import check_internal_grad, check_internal_hess, write_displacements
Expand All @@ -56,6 +54,7 @@
from .params import OptParams, parse_optimizer_args
from .nifty import row, col, flat, bohr2ang, ang2bohr, logger, bak, createWorkQueue, destroyWorkQueue, printcool_dictionary
from .errors import InputError, HessianExit, EngineError, GeomOptNotConvergedError, GeomOptStructureError, LinearTorsionError
from .config import config_dir

class Optimizer(object):
def __init__(self, coords, molecule, IC, engine, dirname, params, print_info=True):
Expand Down Expand Up @@ -829,8 +828,7 @@ def run_optimizer(**kwargs):
# This behavior may be changed by editing the log.ini file.
# Output will only be written to log files after the 'logConfig' line is called!
if kwargs.get('logIni') is None:
import geometric.optimize
logIni = pkg_resources.resource_filename(geometric.optimize.__name__, r'config/log.ini')
logIni = os.path.join(config_dir, 'logJson.ini')
else:
logIni = kwargs.get('logIni')
logfilename = kwargs.get('prefix')
Expand Down
6 changes: 3 additions & 3 deletions geometric/run_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@

#!/usr/bin/env python

import os
import copy
import geometric
import json
import traceback
import pkg_resources
import tempfile
import numpy as np

Expand All @@ -48,8 +48,8 @@
except ImportError:
from io import StringIO

import logging
from .nifty import logger, RawStreamHandler, commadash
from geometric.config import config_dir


def parse_input_json_dict(in_json_dict):
Expand Down Expand Up @@ -191,7 +191,7 @@ def geometric_run_json(in_json_dict):
""" Take an input dictionary loaded from json, and return an output dictionary for json """

# Default logger configuration (prevents extra newline from being printed)
logIni = pkg_resources.resource_filename(geometric.optimize.__name__, 'config/logJson.ini')
logIni = os.path.join(config_dir, 'logJson.ini')
import logging.config
logging.config.fileConfig(logIni,disable_existing_loggers=False)

Expand Down
2 changes: 0 additions & 2 deletions geometric/tests/addons.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import geometric
import pytest
import os
import logging.config
import pkg_resources


def _plugin_import(plug):
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
'networkx',
'six',
'scipy',
'packaging',
],
tests_require=[
'pytest',
Expand Down

0 comments on commit 03c602d

Please sign in to comment.