Skip to content
Open
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 doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import pkg_resources
import importlib.metadata
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Python <3.10, this will need to be something like:

try:
    import importlib.metadata as importlib_metadata
except ImportError:
    import importlib_metadata


# -- General configuration -----------------------------------------------------

Expand Down Expand Up @@ -38,7 +38,7 @@
# built documents.
#
# The short X.Y version.
release = pkg_resources.get_distribution('gnocchi').version
release = importlib.metadata.version('gnocchi')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release = importlib_metadata.version('gnocchi')


# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
Expand Down
6 changes: 3 additions & 3 deletions gnocchi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import pkg_resources
import importlib.metadata
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For Python <3.10, this will need to be something like:

try:
    import importlib.metadata as importlib_metadata
except ImportError:
    import importlib_metadata


try:
__version__ = pkg_resources.get_distribution(__name__).version
except pkg_resources.DistributionNotFound:
__version__ = importlib.metadata.version('gnocchi')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    __version__ = importlib_metadata.version('gnocchi')

except importlib.metadata.PackageNotFoundError:
# package is not installed
pass
21 changes: 14 additions & 7 deletions gnocchi/opts.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import copy
import itertools
import operator
import pkg_resources
import sys
import uuid

from oslo_config import cfg
Expand All @@ -29,6 +29,11 @@
import gnocchi.storage.s3
import gnocchi.storage.swift

if sys.version_info < (3, 10, 0):
import importlib_metadata
else:
from importlib import metadata as importlib_metadata


# NOTE(sileht): The oslo.config interpolation is buggy when the value
# is None, this replaces it by the expected empty string.
Expand Down Expand Up @@ -182,12 +187,14 @@ def list_opts():
cfg.StrOpt('paste_config',
default="api-paste.ini",
help='Path to API Paste configuration.'),
cfg.StrOpt('auth_mode',
default="basic",
choices=list(map(operator.attrgetter("name"),
pkg_resources.iter_entry_points(
"gnocchi.rest.auth_helper"))),
help='Authentication mode to use.'),
cfg.StrOpt(
'auth_mode',
default="basic",
choices=list(map(
operator.attrgetter("name"),
importlib_metadata.entry_points(
group='gnocchi.rest.auth_helper'))),
help='Authentication mode to use.'),
cfg.IntOpt('max_limit',
default=1000,
required=True,
Expand Down
5 changes: 2 additions & 3 deletions gnocchi/rest/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
# License for the specific language governing permissions and limitations
# under the License.
import os
import pkg_resources
import threading
import uuid

Expand Down Expand Up @@ -166,8 +165,8 @@ def load_app(conf, not_implemented_middleware=True):

if cfg_path is None or not os.path.exists(cfg_path):
LOG.debug("No api-paste configuration file found! Using default.")
cfg_path = os.path.abspath(pkg_resources.resource_filename(
__name__, "api-paste.ini"))
cfg_path = os.path.join(os.path.dirname(os.path.abspath(__file__)),
'api-paste.ini')

config = dict(conf=conf,
not_implemented_middleware=not_implemented_middleware)
Expand Down
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ install_requires =
pytimeparse
pecan>=0.9
jsonpatch
cotyledon>=1.5.0
cotyledon>=1.5.0,<2.2.0
stevedore
ujson
voluptuous>=0.8.10
Expand All @@ -52,6 +52,7 @@ install_requires =
lz4>=0.9.0
tooz>=1.38
cachetools
importlib_metadata>=3.6; python_version<"3.10"

[options.extras_require]
keystone =
Expand Down
Loading