Skip to content

[cocopp] Remove pkg_resources dependency #2247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions code-postprocessing/cocopp/bestalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import warnings
import numpy as np
import tarfile
import pkg_resources
from six import advance_iterator

from . import readalign, pproc
Expand Down Expand Up @@ -548,6 +547,7 @@ def custom_generate(args=algs2009, algId='bestCustomAlg', suite=None):


def create_data_files(output_dir, result, suite):
from ._version import __version__ as coco_version

if not suite:
suite = result[list(result.keys())[0]].suite_name
Expand Down Expand Up @@ -626,7 +626,7 @@ def create_data_files(output_dir, result, suite):
comment = 'Combination of ' + ', '.join(algorithms_used)
else:
comment = value.comment
comment += '; coco_version: ' + pkg_resources.require('cocopp')[0].version
comment += '; coco_version: ' + coco_version

info_lines.insert(1, "%% %s; instance_numbers: %s" % (comment, instances_list))

Expand Down
12 changes: 6 additions & 6 deletions code-postprocessing/cocopp/toolsdivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@
"""Various tools.

"""
from __future__ import absolute_import, print_function

import os, time, warnings
import tempfile, shutil
from collections import OrderedDict as _OrderedDict
import re as _re
import numpy as np
from matplotlib import pyplot as plt
from subprocess import CalledProcessError, STDOUT
import pkg_resources

from . import genericsettings, testbedsettings

Expand Down Expand Up @@ -586,7 +583,7 @@ def get_version_label(algorithmID=None):
the string. If more than one reference value is present in the data,
the string displays also a warning.
"""
coco_version = pkg_resources.require('cocopp')[0].version
from ._version import __version__ as coco_version
reference_values = testbedsettings.get_reference_values(algorithmID)

if reference_values and type(reference_values) is set:
Expand All @@ -600,7 +597,10 @@ def get_version_label(algorithmID=None):


def path_in_package(sub_path=""):
from importlib import resources as res
"""return the absolute path prepended to `subpath` in this module.
"""
egg_info = pkg_resources.require('cocopp')[0]
return os.path.join(egg_info.location, egg_info.project_name, sub_path)

package_root_directory = res.files("cocopp")
path = package_root_directory / sub_path
return str(path)
1 change: 0 additions & 1 deletion code-postprocessing/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ classifiers = [
dependencies = [
"matplotlib >=3.5.0",
"numpy >=1.21.0",
"setuptools >=61.0", # For pkg_resources
"platformdirs >=3.8.1",
]
dynamic = ["version"]
Expand Down
2 changes: 1 addition & 1 deletion env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ dependencies:
- matplotlib >=3.6.3
- numpy >=1.24.0
- pip >=22.3.0
- python >=3.10.8
- python >=3.10,<3.11
- scipy >=1.10.0
- toml
- tqdm