Skip to content

Commit

Permalink
fix(build): migrate setup.py to pyproject.toml
Browse files Browse the repository at this point in the history
This commit migrates the project from the setup.py
style of publishing to using pyproject.toml instead.

Signed-off-by: Phil Adams <phil_adams@us.ibm.com>
  • Loading branch information
padamstx committed Aug 6, 2024
1 parent f5667ad commit 621181f
Show file tree
Hide file tree
Showing 14 changed files with 101 additions and 114 deletions.
6 changes: 3 additions & 3 deletions .bumpversion.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ search = "__version__ = '{current_version}'"
replace = "__version__ = '{new_version}'"

[[tool.bumpversion.files]]
filename = "setup.py"
search = "__version__ = '{current_version}'"
replace = "__version__ = '{new_version}'"
filename = "pyproject.toml"
search = "version = \"{current_version}\""
replace = "version = \"{new_version}\""

[[tool.bumpversion.files]]
filename = "README.md"
Expand Down
16 changes: 5 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ stages:
if: (tag IS present) AND (fork = false)

# Default "install" and "script" steps.
install:
- pip install setuptools=="60.8.2"
install: true
script:
- make ci

Expand Down Expand Up @@ -44,12 +43,7 @@ jobs:
- stage: Publish-Release
python: "3.8"
name: Publish-To-PyPi
before_deploy:
- pip install bump-my-version
deploy:
- provider: pypi
setuptools_version: "60.8.2"
user: $PYPI_USER
password: $PYPI_TOKEN
repository: https://upload.pypi.org/legacy
skip_cleanup: true
script:
- make ci
- make publish-deps
- make publish-release
2 changes: 0 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
include requirements.txt
include requirements-dev.txt
include LICENSE
33 changes: 23 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,45 @@
# example: "make setup"

PYTHON=python3
LINT=black
LINT_DIRS=ibm_cloud_sdk_core test test_integration

setup: deps dev_deps install_project
setup: deps dev-deps install-project

all: upgrade_pip setup test-unit lint
all: upgrade-pip setup test-unit lint

ci: setup test-unit lint
ci: all

upgrade_pip:
publish-release: build-dist publish-dist

upgrade-pip:
${PYTHON} -m pip install --upgrade pip

deps:
${PYTHON} -m pip install -r requirements.txt
${PYTHON} -m pip install .

dev-deps:
${PYTHON} -m pip install .[dev]

dev_deps:
${PYTHON} -m pip install -r requirements-dev.txt
publish-deps:
${PYTHON} -m pip install .[publish]

install_project:
install-project:
${PYTHON} -m pip install -e .

test-unit:
${PYTHON} -m pytest --cov=ibm_cloud_sdk_core test

lint:
${PYTHON} -m pylint ${LINT_DIRS}
black --check ${LINT_DIRS}
${LINT} --check ${LINT_DIRS}

lint-fix:
black ${LINT_DIRS}
${LINT} ${LINT_DIRS}

build-dist:
rm -fr dist
${PYTHON} -m build

publish-dist:
TWINE_USERNAME=__token__ ${PYTHON} -m twine upload --non-interactive --verbose -r testpypi dist/*
2 changes: 1 addition & 1 deletion ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
disable_ssl_verification: bool = False,
headers: Optional[Dict[str, str]] = None,
proxies: Optional[Dict[str, str]] = None,
verify: Optional[str] = None
verify: Optional[str] = None,
) -> None:
# Check the type of `disable_ssl_verification`. Must be a bool.
if not isinstance(disable_ssl_verification, bool):
Expand Down
2 changes: 1 addition & 1 deletion ibm_cloud_sdk_core/authenticators/iam_authenticator.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(
disable_ssl_verification: bool = False,
headers: Optional[Dict[str, str]] = None,
proxies: Optional[Dict[str, str]] = None,
scope: Optional[str] = None
scope: Optional[str] = None,
) -> None:
# Check the type of `disable_ssl_verification`. Must be a bool.
if not isinstance(disable_ssl_verification, bool):
Expand Down
4 changes: 2 additions & 2 deletions ibm_cloud_sdk_core/base_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def __init__(
service_url: str = None,
authenticator: Authenticator = None,
disable_ssl_verification: bool = False,
enable_gzip_compression: bool = False
enable_gzip_compression: bool = False,
) -> None:
self.set_service_url(service_url)
self.http_client = requests.Session()
Expand Down Expand Up @@ -364,7 +364,7 @@ def prepare_request(
params: Optional[dict] = None,
data: Optional[Union[str, dict]] = None,
files: Optional[Union[Dict[str, Tuple[str]], List[Tuple[str, Tuple[str, ...]]]]] = None,
**kwargs
**kwargs,
) -> dict:
"""Build a dict that represents an HTTP service request.
Expand Down
2 changes: 1 addition & 1 deletion ibm_cloud_sdk_core/detailed_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(
*,
response: Optional[Union[dict, requests.Response]] = None,
headers: Optional[Dict[str, str]] = None,
status_code: Optional[int] = None
status_code: Optional[int] = None,
) -> None:
self.result = response
self.headers = headers
Expand Down
2 changes: 1 addition & 1 deletion ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def __init__(
disable_ssl_verification: bool = False,
headers: Optional[Dict[str, str]] = None,
proxies: Optional[Dict[str, str]] = None,
verify: Optional[str] = None
verify: Optional[str] = None,
) -> None:
self.username = username
self.password = password
Expand Down
2 changes: 1 addition & 1 deletion ibm_cloud_sdk_core/token_managers/iam_token_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
disable_ssl_verification: bool = False,
headers: Optional[Dict[str, str]] = None,
proxies: Optional[Dict[str, str]] = None,
scope: Optional[str] = None
scope: Optional[str] = None,
) -> None:
super().__init__(
url=url,
Expand Down
63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
[project]
name = "ibm-cloud-sdk-core"
version = "3.20.4"
authors = [
{ name="IBM", email="devxsdk@us.ibm.com" }
]
description = "Core library used by SDKs for IBM Cloud Services"
readme = "README.md"
requires-python = ">=3.8"
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Development Status :: 5 - Production/Stable",
"Environment :: Console",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Libraries :: Application Frameworks",
]
keywords=["ibm", "cloud", "ibm cloud services"]
dependencies = [
"requests>=2.31.0,<3.0.0",
"urllib3>=2.1.0,<3.0.0",
"python_dateutil>=2.8.2,<3.0.0",
"PyJWT>=2.8.0,<3.0.0",
]

[project.urls]
Repository = "https://github.com/IBM/python-sdk-core"
Documentation = "https://github.com/IBM/python-sdk-core/blob/main/README.md"
Issues = "https://github.com/IBM/python-sdk-core/issues"
Changelog = "https://github.com/IBM/python-sdk-core/blob/main/CHANGELOG.md"
Contributing = "https://github.com/IBM/python-sdk-core/blob/main/CONTRIBUTING.md"
License = "https://github.com/IBM/python-sdk-core/blob/main/LICENSE"

[project.optional-dependencies]
dev = [
"coverage>=7.3.2,<8.0.0",
"pylint>=3.0.0,<4.0.0",
"pytest>=7.4.2,<8.0.0",
"pytest-cov>=4.1.0,<5.0.0",
"responses>=0.23.3,<1.0.0",
"black>=24.0.0,<25.0.0",
]
publish = [
"build",
"twine"
]

[build-system]
requires = ["setuptools>=67.7.2"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["ibm_cloud_sdk_core"]

[tool.black]
line-length = 120
skip-string-normalization = true
6 changes: 0 additions & 6 deletions requirements-dev.txt

This file was deleted.

4 changes: 0 additions & 4 deletions requirements.txt

This file was deleted.

71 changes: 0 additions & 71 deletions setup.py

This file was deleted.

0 comments on commit 621181f

Please sign in to comment.