Skip to content

Commit fa1c3ec

Browse files
committed
fix wheels to correctly build and publish wheels to pypi and add pyproject toml to fix wheel metadata and remove the need of version.py and replace with txt. Update scripts along with the change from .py to .txt
1 parent 212f8a6 commit fa1c3ec

File tree

9 files changed

+60
-66
lines changed

9 files changed

+60
-66
lines changed

.github/workflows/wheels.yml

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ jobs:
2020

2121
# Need to grab the SDK version for the wheel name
2222
- name: Extract SDK Version
23-
run: echo "SDK_VERSION=$(python -c 'import version; print(version.SDK_VERSION)')" >> $GITHUB_ENV
23+
run: echo "SDK_VERSION=$(cat version.txt)" >> "$GITHUB_ENV"
24+
shell: bash
2425

2526
- name: Install cibuildwheel
2627
run: |
@@ -34,7 +35,6 @@ jobs:
3435
CIBW_ARCHS: "native"
3536
CIBW_TEST_REQUIRES: "pydantic pytest pytest-asyncio"
3637
CIBW_TEST_COMMAND: "python -m pytest {project}/src/onepassword/test_client.py"
37-
MACOSX_DEPLOYMENT_TARGET: 11.0 # Required for building on macOS
3838
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TEST_SERVICE_ACCOUNT_TOKEN }}
3939
CIBW_ENVIRONMENT_PASS_LINUX: OP_SERVICE_ACCOUNT_TOKEN # to pass in the SA token, for some reason Linux doesn't read the env variables correctly
4040
run: |
@@ -50,23 +50,24 @@ jobs:
5050
runs-on: ubuntu-latest
5151
if: github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/')
5252
steps:
53+
- uses: actions/checkout@v4
5354
# Need to grab the SDK version for the wheel name
5455
- name: Extract SDK Version
55-
run: echo "SDK_VERSION=$(python -c 'import version; print(version.SDK_VERSION)')" >> $GITHUB_ENV
56-
57-
- uses: actions/checkout@v4
56+
run: echo "SDK_VERSION=$(cat version.txt)" >> "$GITHUB_ENV"
57+
shell: bash
58+
5859
- name: Install dependencies
59-
run: pip install build pydantic pytest pytest-asyncio
60+
run: pip3 install build pydantic pytest pytest-asyncio
6061

6162
- name: Build source distribution
62-
run: python -m build --sdist
63+
run: python3 -m build --sdist
6364

6465
- name: Test Source Distribution
6566
env:
6667
OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.TEST_SERVICE_ACCOUNT_TOKEN }}
6768
run: |
68-
python -m pip install dist/*.tar.gz
69-
python -m pytest src/onepassword/test_client.py
69+
python3 -m pip install dist/*.tar.gz
70+
python3 -m pytest src/onepassword/test_client.py
7071
7172
- uses: actions/upload-artifact@v4
7273
with:
@@ -78,18 +79,16 @@ jobs:
7879
runs-on: ubuntu-latest
7980
if: github.event.pull_request.merged == true && contains(github.event.pull_request.head.ref, 'sdk-core/')
8081
environment:
81-
name: testpypi
82-
url: https://pypi.org/p/<your-pypi-project-name>
82+
name: pypi
83+
url: https://pypi.org/project/onepassword-sdk/
8384
permissions:
84-
id-token: write # IMPORTANT: this permission is mandatory for trusted publishing
85+
id-token: write # Required for PyPi trusted publishing
8586
needs: [build_wheels, build-sdist]
8687
steps:
87-
- uses: actions/download-artifact@v2
88-
with:
89-
name: python-sdk-release
90-
path: dist
91-
92-
- name: Publish package distributions to TestPyPI
93-
uses: pypa/gh-action-pypi-publish@release/v1
88+
- uses: actions/download-artifact@v4
9489
with:
95-
repository-url: https://test.pypi.org/legacy/
90+
pattern: onepassword-sdk-*
91+
path: ./dist
92+
merge-multiple: true
93+
- name: Publish package distributions to PyPI
94+
uses: pypa/gh-action-pypi-publish@release/v1.12

pyproject.toml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
[build-system]
2+
requires = ["setuptools>=66", "wheel"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "onepassword-sdk"
7+
dynamic = ["version"]
8+
description = "The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python."
9+
authors = [{ name = "1Password" }]
10+
license = { file = "LICENSE" }
11+
readme = "README.md"
12+
requires-python = ">=3.9"
13+
classifiers = [
14+
"Development Status :: 5 - Production/Stable",
15+
"Operating System :: MacOS",
16+
"Operating System :: POSIX :: Linux",
17+
"Operating System :: Microsoft :: Windows",
18+
"Programming Language :: Python :: 3.9",
19+
"Programming Language :: Python :: 3.10",
20+
"Programming Language :: Python :: 3.11",
21+
"Programming Language :: Python :: 3.12",
22+
"Programming Language :: Python :: 3.13",
23+
"License :: OSI Approved :: MIT License",
24+
]
25+
dependencies = [
26+
"pydantic>=2.5",
27+
]
28+
29+
[project.urls]
30+
Homepage = "https://github.com/1Password/onepassword-sdk-python"
31+
32+
[tool.setuptools.dynamic]
33+
version = {file = "./version.txt"}

setup.py

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
from pathlib import Path
21
from setuptools import setup, find_packages, Distribution
32
from sysconfig import get_platform
4-
from version import SDK_VERSION
53
import platform
64
import os
75

@@ -49,36 +47,11 @@ def get_shared_library_data_to_include():
4947

5048

5149
setup(
52-
name="onepassword-sdk",
53-
version=SDK_VERSION,
54-
author="1Password",
55-
long_description=(Path(__file__).parent / "README.md").read_text(),
56-
long_description_content_type="text/markdown",
57-
description="The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python.",
58-
url="https://github.com/1Password/onepassword-sdk-python",
5950
packages=find_packages(
6051
where="src",
6152
),
6253
distclass=BinaryDistribution,
63-
license="MIT",
64-
license_files="LICENSE",
6554
package_dir={"": "src"},
66-
python_requires=">=3.9",
67-
classifiers=[
68-
"Development Status :: 5 - Production/Stable",
69-
"Operating System :: MacOS",
70-
"Operating System :: POSIX :: Linux",
71-
"Operating System :: Microsoft :: Windows",
72-
"Programming Language :: Python :: 3.9",
73-
"Programming Language :: Python :: 3.10",
74-
"Programming Language :: Python :: 3.11",
75-
"Programming Language :: Python :: 3.12",
76-
"Programming Language :: Python :: 3.13",
77-
"License :: OSI Approved :: MIT License",
78-
],
7955
cmdclass={"bdist_wheel": bdist_wheel},
8056
package_data={"": get_shared_library_data_to_include()},
81-
install_requires=[
82-
"pydantic>=2.5", # Minimum Pydantic version to run the Python SDK
83-
],
8457
)

src/release/scripts/build-wheels.sh

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
# Helper script to build the required wheels for the Python SDK
44

5-
output_version_file="version.py"
6-
75
# The list of python verisons the SDKs release for
86
python_versions=("$@")
97

@@ -15,7 +13,7 @@ macOS_version_x86_64=10.9
1513
macOS_version_arm64=11.0
1614

1715
# Extracts the current verison number for cleanup function
18-
current_version=$(awk -F "['\"]" '/SDK_VERSION =/{print $2}' "$output_version_file")
16+
current_version=$(cat version.txt)
1917

2018
# Function to execute upon exit
2119
cleanup() {

src/release/scripts/prep-release.sh

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,20 @@
22

33
# Helper script to prepare a release for the Python SDK.
44

5-
output_version_file="version.py"
5+
output_version_file="version.txt"
66
output_build_file="src/onepassword/build_number.py"
7-
version_template_file="src/release/templates/version.tpl.py"
87
build_number_template_file="src/release/templates/build_number.tpl.py"
98

109

1110
# Extracts the current build/version number for comparison and backup
12-
current_version=$(awk -F "['\"]" '/SDK_VERSION =/{print $2}' "$output_version_file")
11+
current_version=$(cat "$output_version_file")
1312
current_build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "$output_build_file")
1413

1514
# Function to execute upon exit
1615
cleanup() {
1716
echo "Performing cleanup tasks..."
1817
# Revert changes to file if any
19-
sed -e "s/{{ version }}/$current_version/" "$version_template_file" > "$output_version_file"
18+
echo -n "$current_version" > "$output_version_file"
2019
sed -e "s/{{ build }}/$current_build/" "$build_number_template_file" > "$output_build_file"
2120
exit 1
2221
}
@@ -86,8 +85,8 @@ update_and_validate_version
8685
# Update and validate the build number
8786
update_and_validate_build
8887

89-
# Update version & build number in version.py and build_number.py respectively
90-
sed -e "s/{{ version }}/$version/" "$version_template_file" > "$output_version_file"
88+
# Update version & build number in version.txt and build_number.py respectively
89+
echo -n "$version" > "$output_version_file"
9190
sed -e "s/{{ build }}/$build/" "$build_number_template_file" > "$output_build_file"
9291

9392

src/release/scripts/release.sh

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
set -e
66

77
# Read the contents of the files into variables
8-
version=$(awk -F "['\"]" '/SDK_VERSION =/{print $2}' "version.py")
8+
version=$(cat "version.txt")
99
build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "src/onepassword/build_number.py")
1010
release_notes=$(< src/release/RELEASE-NOTES)
1111

@@ -27,10 +27,3 @@ git tag -a -s "v${version}" -m "${version}"
2727
git push origin tag "v${version}"
2828

2929
gh release create "v${version}" --title "Release ${version}" --notes "${release_notes}" --repo github.com/1Password/onepassword-sdk-python
30-
31-
# Release on PyPi
32-
python3 -m twine upload dist/*
33-
34-
# Delete the dist folder after published
35-
rm -r dist src/*.egg-info
36-

src/release/templates/version.tpl.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

version.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.2.0

0 commit comments

Comments
 (0)