diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..db4245ac --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,21 @@ +[build-system] +requires = ["setuptools>=66", "wheel"] +build-backend = "setuptools.build_meta" + +[project] +name = "onepassword-sdk" +dynamic = ["version"] +description = "The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python." +authors = [{ name = "1Password" }] +license = { file = "LICENSE" } +readme = "README.md" +requires-python = ">=3.9" +dependencies = [ + "pydantic>=2.5", +] + +[project.urls] +Homepage = "https://github.com/1Password/onepassword-sdk-python" + +[tool.setuptools.dynamic] +version = {file = "./version.txt"} \ No newline at end of file diff --git a/setup.py b/setup.py index d53a9c6d..da45642b 100644 --- a/setup.py +++ b/setup.py @@ -1,7 +1,5 @@ -from pathlib import Path -from setuptools import Distribution, setup, find_packages +from setuptools import setup, find_packages, Distribution from sysconfig import get_platform -from version import SDK_VERSION import platform import os @@ -22,7 +20,7 @@ def finalize_options(self): class BinaryDistribution(Distribution): def has_ext_modules(self): return True - + def get_shared_library_data_to_include(): # Return the correct uniffi C shared library extension for the given platform include_path = "lib" @@ -49,35 +47,11 @@ def get_shared_library_data_to_include(): setup( - name="onepassword-sdk", - version=SDK_VERSION, - author="1Password", - long_description=(Path(__file__).parent / "README.md").read_text(), - long_description_content_type="text/markdown", - description="The 1Password Python SDK offers programmatic read access to your secrets in 1Password in an interface native to Python.", - url="https://github.com/1Password/onepassword-sdk-python", packages=find_packages( where="src", ), - license="MIT", - license_files="LICENSE", distclass=BinaryDistribution, package_dir={"": "src"}, - python_requires=">=3.9", - classifiers=[ - "Development Status :: 5 - Production/Stable", - "Operating System :: MacOS", - "Operating System :: POSIX :: Linux", - "Operating System :: Microsoft :: Windows", - "Programming Language :: Python :: 3.10", - "Programming Language :: Python :: 3.11", - "Programming Language :: Python :: 3.12", - "Programming Language :: Python :: 3.13", - "License :: OSI Approved :: MIT License", - ], cmdclass={"bdist_wheel": bdist_wheel}, package_data={"": get_shared_library_data_to_include()}, - install_requires=[ - "pydantic>=2.5", # Minimum Pydantic version to run the Python SDK - ], ) diff --git a/src/release/scripts/prep-release.sh b/src/release/scripts/prep-release.sh index 88e709d2..686f7c9c 100755 --- a/src/release/scripts/prep-release.sh +++ b/src/release/scripts/prep-release.sh @@ -2,21 +2,20 @@ # Helper script to prepare a release for the Python SDK. -output_version_file="version.py" +output_version_file="version.txt" output_build_file="src/onepassword/build_number.py" -version_template_file="src/release/templates/version.tpl.py" build_number_template_file="src/release/templates/build_number.tpl.py" # Extracts the current build/version number for comparison and backup -current_version=$(awk -F "['\"]" '/SDK_VERSION =/{print $2}' "$output_version_file") +current_version=$(cat "$output_version_file" 2>/dev/null || echo "") current_build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "$output_build_file") # Function to execute upon exit cleanup() { echo "Performing cleanup tasks..." # Revert changes to file if any - sed -e "s/{{ version }}/$current_version/" "$version_template_file" > "$output_version_file" + echo -n "$current_version" > "$output_version_file" sed -e "s/{{ build }}/$current_build/" "$build_number_template_file" > "$output_build_file" exit 1 } @@ -86,8 +85,8 @@ update_and_validate_version # Update and validate the build number update_and_validate_build -# Update version & build number in version.py and build_number.py respectively -sed -e "s/{{ version }}/$version/" "$version_template_file" > "$output_version_file" +# Update version & build number in version.txt and build_number.py respectively +echo -n "$version" > "$output_version_file" sed -e "s/{{ build }}/$build/" "$build_number_template_file" > "$output_build_file" diff --git a/src/release/scripts/release.sh b/src/release/scripts/release.sh index 050c1489..83b0c143 100755 --- a/src/release/scripts/release.sh +++ b/src/release/scripts/release.sh @@ -5,7 +5,7 @@ set -e # Read the contents of the files into variables -version=$(awk -F "['\"]" '/SDK_VERSION =/{print $2}' "version.py") +version=$(cat "version.txt") build=$(awk -F "['\"]" '/SDK_BUILD_NUMBER =/{print $2}' "src/onepassword/build_number.py") release_notes=$(< src/release/RELEASE-NOTES) diff --git a/src/release/templates/version.tpl.py b/src/release/templates/version.tpl.py deleted file mode 100644 index 9c787be2..00000000 --- a/src/release/templates/version.tpl.py +++ /dev/null @@ -1 +0,0 @@ -SDK_VERSION = "{{ version }}" diff --git a/version.py b/version.py deleted file mode 100644 index f5ebd34f..00000000 --- a/version.py +++ /dev/null @@ -1 +0,0 @@ -SDK_VERSION = "0.2.0" diff --git a/version.txt b/version.txt new file mode 100644 index 00000000..341cf11f --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ +0.2.0 \ No newline at end of file