Skip to content
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

Convert to using hatch for build and release tooling #100

Draft
wants to merge 1 commit into
base: devel
Choose a base branch
from
Draft
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
85 changes: 77 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,78 @@
[project]
name = "cdpy"
description = "A Pythonic client wrapper for Cloudera CDP CLI"
license = "Apache-2.0"
authors = [
{ name = "Cloudera, Inc.", email = "[email protected]" }
]
keywords = [
"cloudera",
"cdp",
"ansible-navigator",
]
classifiers = [
"Development Status :: 4 - Beta",
"Programming Language :: Python"
]
readme = "README.rst"
requires-python = ">=3.8"
dependencies = [
"importlib-metadata",
"cdpcli-beta>=0.9.101"
]
dynamic = ["version"]

[project.urls]
Documentation = "https://github.com/cloudera-labs/cdpy/"
"Source Code" = "https://github.com/cloudera-labs/cdpy/"

[tool.hatch.version]
path = "src/cdpy/__version__.py"

[tool.hatch.build.targets.sdist]
include = [
"/src",
"/tests",
]

[tool.hatch.envs.default]
dependencies = [
"coverage[toml]",
"pytest",
"pytest-cov",
"wheel",
"flake8",
"pre-commit"
]

[tool.hatch.envs.default.scripts]
test = 'pytest --cov-report=term-missing --cov-config=pyproject.toml --cov=cdpy --cov=tests'

[flake8]
# Some sane defaults for the code style checker flake8
exclude = [
"build",
"dist",
".eggs",
"docs/conf.py",
]

[tool.hatch.envs.docs]
dependencies = [
"sphinx"
]

[tool.hatch.envs.docs.scripts]

[tool.hatch.envs.test]
dependencies = [
"pytest",
"pytest-sugar"
]

[[tool.hatch.envs.test.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12"]

[build-system]
# AVOID CHANGING REQUIRES: IT WILL BE UPDATED BY PYSCAFFOLD!
requires = ["setuptools>=46.1.0", "setuptools_scm[toml]>=5"]
build-backend = "setuptools.build_meta"

[tool.setuptools_scm]
# For smarter version schemes and other configuration options,
# check out https://github.com/pypa/setuptools_scm
version_scheme = "no-guess-dev"
requires = ["hatchling"]
build-backend = "hatchling.build"
15 changes: 15 additions & 0 deletions src/cdpy/__version__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

VERSION="1.3.0"
7 changes: 4 additions & 3 deletions src/cdpy/common.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-

from datetime import datetime
import pkg_resources
from time import time, sleep
import html
import io
Expand Down Expand Up @@ -29,6 +28,8 @@
from cdpcli.retryhandler import create_retry_handler
from cdpcli.translate import build_retry_config

from cdpy.__version__ import VERSION


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

def _make_user_agent_header(self):
cdpy_version = pkg_resources.get_distribution('cdpy').version
cdpy_version = VERSION
return '%s CDPY/%s CDPCLI/%s Python/%s %s/%s' % (
self.agent_header,
cdpy_version,
Expand Down Expand Up @@ -630,7 +631,7 @@ def _handle_std_call(self, client, call_function, payload):
full_response = raw_response
return full_response

def call(self, svc: str, func: str, ret_field: str = None, squelch: ['Squelch'] = None, ret_error: bool = False,
def call(self, svc: str, func: str, ret_field: str = None, squelch: list['Squelch'] = None, ret_error: bool = False,
redirect_headers: dict = None, **kwargs: Union[dict, bool, str, list]) -> Union[list, dict, 'CdpError']:
"""
Wraps the call to an underlying CDP CLI Service, handles common errors, and parses output
Expand Down
14 changes: 14 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Copyright 2024 Cloudera, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.