Skip to content

Commit 8b53f42

Browse files
committed
Convert to using hatch for build and release tooling
Signed-off-by: Webster Mudge <[email protected]>
1 parent cefd4ab commit 8b53f42

File tree

4 files changed

+110
-11
lines changed

4 files changed

+110
-11
lines changed

pyproject.toml

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,78 @@
1+
[project]
2+
name = "cdpy"
3+
description = "A Pythonic client wrapper for Cloudera CDP CLI"
4+
license = "Apache-2.0"
5+
authors = [
6+
{ name = "Cloudera, Inc.", email = "[email protected]" }
7+
]
8+
keywords = [
9+
"cloudera",
10+
"cdp",
11+
"ansible-navigator",
12+
]
13+
classifiers = [
14+
"Development Status :: 4 - Beta",
15+
"Programming Language :: Python"
16+
]
17+
readme = "README.rst"
18+
requires-python = ">=3.8"
19+
dependencies = [
20+
"importlib-metadata",
21+
"cdpcli-beta>=0.9.101"
22+
]
23+
dynamic = ["version"]
24+
25+
[project.urls]
26+
Documentation = "https://github.com/cloudera-labs/cdpy/"
27+
"Source Code" = "https://github.com/cloudera-labs/cdpy/"
28+
29+
[tool.hatch.version]
30+
path = "src/cdpy/__version__.py"
31+
32+
[tool.hatch.build.targets.sdist]
33+
include = [
34+
"/src",
35+
"/tests",
36+
]
37+
38+
[tool.hatch.envs.default]
39+
dependencies = [
40+
"coverage[toml]",
41+
"pytest",
42+
"pytest-cov",
43+
"wheel",
44+
"flake8",
45+
"pre-commit"
46+
]
47+
48+
[tool.hatch.envs.default.scripts]
49+
test = 'pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=cdpy --cov=tests'
50+
51+
[flake8]
52+
# Some sane defaults for the code style checker flake8
53+
exclude = [
54+
"build",
55+
"dist",
56+
".eggs",
57+
"docs/conf.py",
58+
]
59+
60+
[tool.hatch.envs.docs]
61+
dependencies = [
62+
"sphinx"
63+
]
64+
65+
[tool.hatch.envs.docs.scripts]
66+
67+
[tool.hatch.envs.test]
68+
dependencies = [
69+
"pytest",
70+
"pytest-sugar"
71+
]
72+
73+
[[tool.hatch.envs.test.matrix]]
74+
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]
75+
176
[build-system]
2-
# AVOID CHANGING REQUIRES: IT WILL BE UPDATED BY PYSCAFFOLD!
3-
requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5"]
4-
build-backend = "setuptools.build_meta"
5-
6-
[tool.setuptools_scm]
7-
# For smarter version schemes and other configuration options,
8-
# check out https://github.com/pypa/setuptools_scm
9-
version_scheme = "no-guess-dev"
77+
requires = ["hatchling"]
78+
build-backend = "hatchling.build"

src/cdpy/__version__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 Cloudera, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
VERSION="1.3.0"

src/cdpy/common.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# -*- coding: utf-8 -*-
22

33
from datetime import datetime
4-
import pkg_resources
54
from time import time, sleep
65
import html
76
import io
@@ -29,6 +28,8 @@
2928
from cdpcli.retryhandler import create_retry_handler
3029
from cdpcli.translate import build_retry_config
3130

31+
from cdpy.__version__ import VERSION
32+
3233

3334
class CdpWarning(UserWarning):
3435
"""Class for deriving custom warnings from UserWarning"""
@@ -291,7 +292,7 @@ def _warning_format(message, category, filename, lineno, line=None):
291292
}
292293

293294
def _make_user_agent_header(self):
294-
cdpy_version = pkg_resources.get_distribution('cdpy').version
295+
cdpy_version = VERSION
295296
return '%s CDPY/%s CDPCLI/%s Python/%s %s/%s' % (
296297
self.agent_header,
297298
cdpy_version,
@@ -630,7 +631,7 @@ def _handle_std_call(self, client, call_function, payload):
630631
full_response = raw_response
631632
return full_response
632633

633-
def call(self, svc: str, func: str, ret_field: str = None, squelch: ['Squelch'] = None, ret_error: bool = False,
634+
def call(self, svc: str, func: str, ret_field: str = None, squelch: list['Squelch'] = None, ret_error: bool = False,
634635
redirect_headers: dict = None, **kwargs: Union[dict, bool, str, list]) -> Union[list, dict, 'CdpError']:
635636
"""
636637
Wraps the call to an underlying CDP CLI Service, handles common errors, and parses output

tests/__init__.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Copyright 2024 Cloudera, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+

0 commit comments

Comments
 (0)