Skip to content

Commit 03c8a6d

Browse files
authored
fix(build): migrate setup.py to pyproject.toml (#205) (#206)
This commit migrates the project from the setup.py style of publishing to using pyproject.toml instead. Signed-off-by: Phil Adams <[email protected]>
1 parent f5667ad commit 03c8a6d

16 files changed

+103
-117
lines changed

.bumpversion.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ search = "__version__ = '{current_version}'"
88
replace = "__version__ = '{new_version}'"
99

1010
[[tool.bumpversion.files]]
11-
filename = "setup.py"
12-
search = "__version__ = '{current_version}'"
13-
replace = "__version__ = '{new_version}'"
11+
filename = "pyproject.toml"
12+
search = "version = \"{current_version}\""
13+
replace = "version = \"{new_version}\""
1414

1515
[[tool.bumpversion.files]]
1616
filename = "README.md"

.releaserc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
[
99
"@semantic-release/exec",
1010
{
11-
"prepareCmd": "bump-my-version bump --allow-dirty --current-version ${lastRelease.version} --new-version ${nextRelease.version}"
11+
"prepareCmd": "bump-my-version bump --allow-dirty --verbose --current-version ${lastRelease.version} --new-version ${nextRelease.version}"
1212
}
1313
],
1414
[

.travis.yml

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ stages:
1010
if: (tag IS present) AND (fork = false)
1111

1212
# Default "install" and "script" steps.
13-
install:
14-
- pip install setuptools=="60.8.2"
13+
install: true
1514
script:
1615
- make ci
1716

@@ -44,12 +43,7 @@ jobs:
4443
- stage: Publish-Release
4544
python: "3.8"
4645
name: Publish-To-PyPi
47-
before_deploy:
48-
- pip install bump-my-version
49-
deploy:
50-
- provider: pypi
51-
setuptools_version: "60.8.2"
52-
user: $PYPI_USER
53-
password: $PYPI_TOKEN
54-
repository: https://upload.pypi.org/legacy
55-
skip_cleanup: true
46+
script:
47+
- make ci
48+
- make publish-deps
49+
- make publish-release

MANIFEST.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1 @@
1-
include requirements.txt
2-
include requirements-dev.txt
31
include LICENSE

Makefile

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,46 @@
33
# example: "make setup"
44

55
PYTHON=python3
6+
LINT=black
67
LINT_DIRS=ibm_cloud_sdk_core test test_integration
78

8-
setup: deps dev_deps install_project
9+
setup: deps dev-deps install-project
910

10-
all: upgrade_pip setup test-unit lint
11+
all: upgrade-pip setup test-unit lint
1112

12-
ci: setup test-unit lint
13+
ci: all
1314

14-
upgrade_pip:
15+
publish-release: build-dist publish-dist
16+
17+
upgrade-pip:
1518
${PYTHON} -m pip install --upgrade pip
1619

1720
deps:
18-
${PYTHON} -m pip install -r requirements.txt
21+
${PYTHON} -m pip install .
22+
23+
dev-deps:
24+
${PYTHON} -m pip install .[dev]
1925

20-
dev_deps:
21-
${PYTHON} -m pip install -r requirements-dev.txt
26+
publish-deps:
27+
${PYTHON} -m pip install .[publish]
2228

23-
install_project:
29+
install-project:
2430
${PYTHON} -m pip install -e .
2531

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

2935
lint:
3036
${PYTHON} -m pylint ${LINT_DIRS}
31-
black --check ${LINT_DIRS}
37+
${LINT} --check ${LINT_DIRS}
3238

3339
lint-fix:
34-
black ${LINT_DIRS}
40+
${LINT} ${LINT_DIRS}
41+
42+
build-dist:
43+
rm -fr dist
44+
${PYTHON} -m build -s
45+
46+
# This target requires the TWINE_PASSWORD env variable to be set to the user's pypi.org API token.
47+
publish-dist:
48+
TWINE_USERNAME=__token__ ${PYTHON} -m twine upload --non-interactive --verbose dist/*.tar.gz

ibm_cloud_sdk_core/authenticators/cp4d_authenticator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
disable_ssl_verification: bool = False,
6363
headers: Optional[Dict[str, str]] = None,
6464
proxies: Optional[Dict[str, str]] = None,
65-
verify: Optional[str] = None
65+
verify: Optional[str] = None,
6666
) -> None:
6767
# Check the type of `disable_ssl_verification`. Must be a bool.
6868
if not isinstance(disable_ssl_verification, bool):

ibm_cloud_sdk_core/authenticators/iam_authenticator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def __init__(
6666
disable_ssl_verification: bool = False,
6767
headers: Optional[Dict[str, str]] = None,
6868
proxies: Optional[Dict[str, str]] = None,
69-
scope: Optional[str] = None
69+
scope: Optional[str] = None,
7070
) -> None:
7171
# Check the type of `disable_ssl_verification`. Must be a bool.
7272
if not isinstance(disable_ssl_verification, bool):

ibm_cloud_sdk_core/base_service.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__(
9494
service_url: str = None,
9595
authenticator: Authenticator = None,
9696
disable_ssl_verification: bool = False,
97-
enable_gzip_compression: bool = False
97+
enable_gzip_compression: bool = False,
9898
) -> None:
9999
self.set_service_url(service_url)
100100
self.http_client = requests.Session()
@@ -364,7 +364,7 @@ def prepare_request(
364364
params: Optional[dict] = None,
365365
data: Optional[Union[str, dict]] = None,
366366
files: Optional[Union[Dict[str, Tuple[str]], List[Tuple[str, Tuple[str, ...]]]]] = None,
367-
**kwargs
367+
**kwargs,
368368
) -> dict:
369369
"""Build a dict that represents an HTTP service request.
370370

ibm_cloud_sdk_core/detailed_response.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def __init__(
4040
*,
4141
response: Optional[Union[dict, requests.Response]] = None,
4242
headers: Optional[Dict[str, str]] = None,
43-
status_code: Optional[int] = None
43+
status_code: Optional[int] = None,
4444
) -> None:
4545
self.result = response
4646
self.headers = headers

ibm_cloud_sdk_core/token_managers/cp4d_token_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def __init__(
6363
disable_ssl_verification: bool = False,
6464
headers: Optional[Dict[str, str]] = None,
6565
proxies: Optional[Dict[str, str]] = None,
66-
verify: Optional[str] = None
66+
verify: Optional[str] = None,
6767
) -> None:
6868
self.username = username
6969
self.password = password

ibm_cloud_sdk_core/token_managers/iam_token_manager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ def __init__(
7171
disable_ssl_verification: bool = False,
7272
headers: Optional[Dict[str, str]] = None,
7373
proxies: Optional[Dict[str, str]] = None,
74-
scope: Optional[str] = None
74+
scope: Optional[str] = None,
7575
) -> None:
7676
super().__init__(
7777
url=url,

pylint.sh

Lines changed: 0 additions & 2 deletions
This file was deleted.

pyproject.toml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
1+
[project]
2+
name = "ibm-cloud-sdk-core"
3+
version = "3.20.4"
4+
authors = [
5+
{ name="IBM", email="[email protected]" }
6+
]
7+
description = "Core library used by SDKs for IBM Cloud Services"
8+
readme = "README.md"
9+
requires-python = ">=3.8"
10+
classifiers = [
11+
"Programming Language :: Python",
12+
"Programming Language :: Python :: 3",
13+
"Programming Language :: Python :: 3.8",
14+
"Programming Language :: Python :: 3.9",
15+
"Programming Language :: Python :: 3.10",
16+
"Programming Language :: Python :: 3.11",
17+
"Programming Language :: Python :: 3.12",
18+
"Development Status :: 5 - Production/Stable",
19+
"Environment :: Console",
20+
"Intended Audience :: Developers",
21+
"License :: OSI Approved :: Apache Software License",
22+
"Operating System :: OS Independent",
23+
"Topic :: Software Development :: Libraries",
24+
"Topic :: Software Development :: Libraries :: Python Modules",
25+
"Topic :: Software Development :: Libraries :: Application Frameworks",
26+
]
27+
keywords=["ibm", "cloud", "ibm cloud services"]
28+
dependencies = [
29+
"requests>=2.31.0,<3.0.0",
30+
"urllib3>=2.1.0,<3.0.0",
31+
"python_dateutil>=2.8.2,<3.0.0",
32+
"PyJWT>=2.8.0,<3.0.0",
33+
]
34+
35+
[project.urls]
36+
Repository = "https://github.com/IBM/python-sdk-core"
37+
Documentation = "https://github.com/IBM/python-sdk-core/blob/main/README.md"
38+
Issues = "https://github.com/IBM/python-sdk-core/issues"
39+
Changelog = "https://github.com/IBM/python-sdk-core/blob/main/CHANGELOG.md"
40+
Contributing = "https://github.com/IBM/python-sdk-core/blob/main/CONTRIBUTING.md"
41+
License = "https://github.com/IBM/python-sdk-core/blob/main/LICENSE"
42+
43+
[project.optional-dependencies]
44+
dev = [
45+
"coverage>=7.3.2,<8.0.0",
46+
"pylint>=3.0.0,<4.0.0",
47+
"pytest>=7.4.2,<8.0.0",
48+
"pytest-cov>=4.1.0,<5.0.0",
49+
"responses>=0.23.3,<1.0.0",
50+
"black>=24.0.0,<25.0.0",
51+
]
52+
publish = [
53+
"build",
54+
"twine"
55+
]
56+
57+
[build-system]
58+
requires = ["setuptools>=67.7.2"]
59+
build-backend = "setuptools.build_meta"
60+
61+
[tool.setuptools]
62+
packages = ["ibm_cloud_sdk_core"]
63+
164
[tool.black]
265
line-length = 120
366
skip-string-normalization = true

requirements-dev.txt

Lines changed: 0 additions & 6 deletions
This file was deleted.

requirements.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

setup.py

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)