Skip to content

Commit bdaf4d9

Browse files
committed
Merge branch 'tim/python' into 'master'
maint: Build ABI3 wheel with PyPA build + setuptools, not poetry See merge request TankerHQ/sdk-python!282
2 parents 01440ea + 58d9541 commit bdaf4d9

9 files changed

Lines changed: 52 additions & 43 deletions

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ __pycache__
44
*.so
55
build/
66
dist/
7-
setup.py
87
.venv/
98
.mypy_cache
109
htmlcov/

.gitlab-ci.yml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ check/deployed-native/linux:
9494
- .rules/deployed-native
9595
script:
9696
- poetry run python run-ci.py --isolate-conan-user-home prepare --use-tanker=deployed --profile linux-x86_64 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
97-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile linux-x86_64 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
97+
- poetry run python run-ci.py build --test
9898
tags: !reference [.tags/linux, tags]
9999

100100
check/deployed-native/macos/x86_64:
@@ -104,7 +104,7 @@ check/deployed-native/macos/x86_64:
104104
- .rules/deployed-native
105105
script:
106106
- poetry run python run-ci.py --isolate-conan-user-home prepare --use-tanker=deployed --profile macos-x86_64 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
107-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile macos-x86_64 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
107+
- poetry run python run-ci.py build --test
108108
tags: !reference [.tags/macos/x86_64, tags]
109109

110110
check/deployed-native/macos/arm:
@@ -114,7 +114,7 @@ check/deployed-native/macos/arm:
114114
- .rules/deployed-native
115115
script:
116116
- poetry run python run-ci.py --isolate-conan-user-home prepare --use-tanker=deployed --profile macos-armv8 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
117-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile macos-armv8 --remote $CONAN_REMOTE --tanker-ref=$SDK_NATIVE_CONAN_REFERENCE
117+
- poetry run python run-ci.py build --test
118118
tags: !reference [.tags/macos/arm, tags]
119119

120120
## native from sources
@@ -126,7 +126,7 @@ check/native-from-sources/linux:
126126
- .rules/native-from-sources
127127
script:
128128
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=same-as-branch --profile linux-x86_64
129-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile linux-x86_64
129+
- poetry run python run-ci.py build --test
130130
tags: !reference [.tags/compilation-linux, tags]
131131

132132
check/native-from-sources/macos/x86_64:
@@ -136,7 +136,7 @@ check/native-from-sources/macos/x86_64:
136136
- .rules/native-from-sources
137137
script:
138138
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=same-as-branch --profile macos-x86_64
139-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile macos-x86_64
139+
- poetry run python run-ci.py build --test
140140
tags: !reference [.tags/macos/x86_64, tags]
141141

142142
check/native-from-sources/macos/arm:
@@ -146,7 +146,7 @@ check/native-from-sources/macos/arm:
146146
- .rules/native-from-sources
147147
script:
148148
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=same-as-branch --profile macos-armv8
149-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile macos-armv8
149+
- poetry run python run-ci.py build --test
150150
tags: !reference [.tags/macos/arm, tags]
151151

152152
## downstream
@@ -158,7 +158,7 @@ check/downstream/linux:
158158
- .rules/check/downstream/linux
159159
script:
160160
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=upstream --profile linux-x86_64
161-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile linux-x86_64
161+
- poetry run python run-ci.py build --test
162162
tags: !reference [.tags/linux, tags]
163163

164164
check/downstream/macos/x86_64:
@@ -169,7 +169,7 @@ check/downstream/macos/x86_64:
169169
dependencies: []
170170
script:
171171
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=upstream --profile macos-x86_64
172-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile macos-x86_64
172+
- poetry run python run-ci.py build --test
173173
tags: !reference [.tags/macos/x86_64, tags]
174174

175175
check/downstream/macos/arm:
@@ -180,7 +180,7 @@ check/downstream/macos/arm:
180180
dependencies: []
181181
script:
182182
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=upstream --profile macos-armv8
183-
- poetry run python run-ci.py --isolate-conan-user-home build --test --profile macos-armv8
183+
- poetry run python run-ci.py build --test
184184
tags: !reference [.tags/macos/arm, tags]
185185

186186
.safety:
@@ -223,7 +223,7 @@ safety/manual:
223223
- .rules/build-wheel
224224
script:
225225
- poetry run python run-ci.py --isolate-conan-user-home prepare --remote $CONAN_REMOTE --use-tanker=deployed --tanker-ref $SDK_NATIVE_CONAN_REFERENCE --profile $CONAN_PROFILE
226-
- poetry run python run-ci.py --isolate-conan-user-home build --profile $CONAN_PROFILE --release $SDK_PYTHON_RELEASE_VERSION --remote $CONAN_REMOTE --tanker-ref $SDK_NATIVE_CONAN_REFERENCE
226+
- poetry run python run-ci.py --isolate-conan-user-home build --release $SDK_PYTHON_RELEASE_VERSION
227227
artifacts:
228228
paths:
229229
- dist

MANIFEST.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
include build_tanker.py
2+
include cffi_src.c
3+
include cffi_defs.h
4+
include exported_symbols.*
5+
graft conan

build.py

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

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

poetry_do_not_build.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
raise Exception(
2+
"Don't use `poetry build`, it can't build abi stable wheels. "
3+
"Use `poetry run python -m build -w` instead."
4+
)

pyproject.toml

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1+
[project]
2+
name = "tankersdk"
3+
version = "0.0.0"
4+
description = "Python client fo Tanker"
5+
authors = [{ name = "Tanker team" }]
6+
17
[tool.poetry]
28
name = "tankersdk"
39
version = "0.0.0"
410
description = "Python client fo Tanker"
511
authors = ["Tanker team"]
612

7-
include = [
8-
"build_tanker.py",
9-
"build.py",
10-
"cffi_defs.h",
11-
"cffi_src.c",
12-
]
13-
14-
15-
1613
[tool.poetry.dependencies]
1714
python = "^3.11"
1815
cffi = "^1.13.2"
@@ -45,14 +42,19 @@ tankeradminsdk = { version = "^3.0.0", source = "gitlab" }
4542
tankersdk-identity = "3.3.0"
4643

4744
[tool.poetry.build]
48-
generate-setup-file = true
49-
script = "build.py"
45+
script = "poetry_do_not_build.py"
5046

5147
[[tool.poetry.source]]
5248
name = "gitlab"
5349
url = "https://gitlab.com/api/v4/projects/20917546/packages/pypi/simple"
5450
secondary = true
5551

52+
[tool.setuptools]
53+
packages = ["tankersdk"]
54+
55+
[tool.distutils.bdist_wheel]
56+
py-limited-api = "cp39"
57+
5658
[build-system]
57-
requires = ["poetry-core>=1.0.0", "setuptools", "wheel", "cffi >= 1.12", "path"]
58-
build-backend = "poetry.core.masonry.api"
59+
requires = ["poetry-core>=1.0.0", "path", "setuptools>=61", "cffi >= 1.12", "build >= 0.10.0"]
60+
build-backend = "setuptools.build_meta"

run-ci.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def prepare(
5252
)
5353

5454

55-
def build_wheel(profile: Profile, version: str, tanker_ref: str) -> None:
55+
def build_wheel(version: str) -> None:
5656
src_path = Path.cwd()
5757
tankerci.bump.bump_files(version)
5858
dist_path = src_path / "dist"
@@ -69,7 +69,7 @@ def build_wheel(profile: Profile, version: str, tanker_ref: str) -> None:
6969
# so that they can be found even when the working directory
7070
# changes, and we make sure *all* paths used in build_tanker.py
7171
# are absolute
72-
tankerci.run("poetry", "build", env=env)
72+
tankerci.run("poetry", "run", "python", "-m", "build", "--wheel", env=env)
7373
wheels = list(dist_path.glob("tankersdk-*.whl"))
7474
if len(wheels) != 1:
7575
raise Exception("multiple wheels found: {}".format(wheels))
@@ -98,12 +98,14 @@ def run_test() -> None:
9898
shutil.copytree(coverage_dir, dest_dir)
9999

100100

101-
def build(
102-
profile: Profile, release_version: Optional[str], tanker_ref: str, test: bool
103-
) -> None:
101+
def build(release_version: Optional[str], test: bool) -> None:
102+
# Installs the dependencies (and the pure-python part of the package, without the C extension)
104103
tankerci.run("poetry", "install", cwd=Path.cwd())
104+
# Builds a local version of the package (a wheel) and installs it inside the poetry virtualenv
105+
tankerci.run("poetry", "run", "pip", "install", ".", cwd=Path.cwd())
106+
105107
if release_version:
106-
build_wheel(profile, release_version, tanker_ref)
108+
build_wheel(release_version)
107109
if test:
108110
run_test()
109111

@@ -139,11 +141,8 @@ def main() -> None:
139141
subparsers = parser.add_subparsers(title="subcommands", dest="command")
140142

141143
build_parser = subparsers.add_parser("build")
142-
build_parser.add_argument("--profile", default="default", nargs="+")
143-
build_parser.add_argument("--tanker-ref")
144144
build_parser.add_argument("--test", action="store_true")
145145
build_parser.add_argument("--release")
146-
build_parser.add_argument("--remote", default="artifactory")
147146

148147
prepare_parser = subparsers.add_parser("prepare")
149148
prepare_parser.add_argument(
@@ -183,8 +182,7 @@ def main() -> None:
183182
tankerci.conan.run("remove", "tanker/*", "--force")
184183

185184
if command == "build":
186-
with tankerci.conan.ConanContextManager([args.remote], conan_home=user_home):
187-
build(Profile(args.profile), args.release, args.tanker_ref, args.test)
185+
build(args.release, args.test)
188186
elif command == "prepare":
189187
with tankerci.conan.ConanContextManager([args.remote], conan_home=user_home):
190188
prepare(

setup.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from setuptools import setup
2+
3+
setup(
4+
cffi_modules="build_tanker.py:tanker_ext",
5+
)

0 commit comments

Comments
 (0)