Merge "Convert pkg_resources usage to importlib"
This commit is contained in:
commit
3ebe0cdc96
@ -11,9 +11,9 @@
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import logging
|
||||
|
||||
from pkg_resources import resource_string
|
||||
import importlib.resources
|
||||
import logging
|
||||
|
||||
from zuul.lib.logutil import get_annotated_logger
|
||||
|
||||
@ -40,8 +40,9 @@ class GraphQLClient:
|
||||
'canmerge-legacy',
|
||||
]
|
||||
for query_name in query_names:
|
||||
self.queries[query_name] = resource_string(
|
||||
__name__, '%s.graphql' % query_name).decode('utf-8')
|
||||
f = importlib.resources.files('zuul').joinpath(
|
||||
'driver/github/graphql/%s.graphql' % query_name)
|
||||
self.queries[query_name] = f.read_bytes().decode()
|
||||
|
||||
@staticmethod
|
||||
def _prepare_query(query, variables):
|
||||
|
@ -18,15 +18,14 @@
|
||||
import json
|
||||
|
||||
from importlib import metadata as importlib_metadata
|
||||
import pkg_resources
|
||||
|
||||
release_string = importlib_metadata.distribution('zuul').version
|
||||
zuul_distribution = importlib_metadata.distribution('zuul')
|
||||
release_string = zuul_distribution.version
|
||||
|
||||
is_release = None
|
||||
git_version = None
|
||||
try:
|
||||
_metadata = json.loads(
|
||||
pkg_resources.get_distribution('zuul').get_metadata('pbr.json'))
|
||||
_metadata = json.loads(zuul_distribution.read_text('pbr.json'))
|
||||
if _metadata:
|
||||
is_release = _metadata['is_release']
|
||||
git_version = _metadata['git_version']
|
||||
|
Loading…
Reference in New Issue
Block a user