From 6385d48bc31d18171cda505f806aff75486abf11 Mon Sep 17 00:00:00 2001 From: David Irvine Date: Sat, 30 Nov 2024 18:57:12 +0000 Subject: [PATCH] zzz --- .github/workflows/python-publish.yml | 28 +++++++++++++++---- Cargo.toml | 1 + pyproject.toml | 1 + src/python.rs => python/bindings/mod.rs | 0 .../self_encryption}/__init__.py | 0 .../self_encryption}/cli.py | 0 {tests => python/tests}/test_bindings.py | 2 -- {tests => python/tests}/test_cli.py | 1 - src/lib.rs | 4 ++- 9 files changed, 27 insertions(+), 10 deletions(-) rename src/python.rs => python/bindings/mod.rs (100%) rename {self_encryption => python/self_encryption}/__init__.py (100%) rename {self_encryption => python/self_encryption}/cli.py (100%) rename {tests => python/tests}/test_bindings.py (98%) rename {tests => python/tests}/test_cli.py (99%) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 5ba02ce0d..49e646904 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -274,16 +274,32 @@ jobs: id-token: write contents: read steps: - # Download all wheels - - name: Download all wheels + - name: Create dist directory + run: mkdir -p dist + + # Download all artifacts at once + - name: Download all artifacts uses: actions/download-artifact@v4 with: - pattern: wheels-* - merge-multiple: true path: dist - - name: Display structure of downloaded files - run: ls -R dist + - name: Prepare dist directory + run: | + find dist -type f -name "*.whl" -exec mv {} dist/ \; + find dist -type f -name "*.tar.gz" -exec mv {} dist/ \; + rm -rf dist/*/ + echo "Final dist directory contents:" + ls -la dist/ + + - name: Check if version exists + run: | + VERSION="${{ github.ref_name }}" + VERSION="${VERSION#v}" # Remove 'v' prefix if present + if pip index versions self_encryption | grep -q "${VERSION}"; then + echo "Version ${VERSION} already exists on PyPI" + exit 1 + fi + - name: Publish to PyPI uses: pypa/gh-action-pypi-publish@release/v1 with: diff --git a/Cargo.toml b/Cargo.toml index 5411670d8..30d66f583 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -78,3 +78,4 @@ harness = false [lib] name = "self_encryption" crate-type = ["cdylib", "rlib"] +path = "src/lib.rs" diff --git a/pyproject.toml b/pyproject.toml index fabe531d4..cbb5588cf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,4 +22,5 @@ self-encryption = "self_encryption.cli:cli" features = ["python"] module-name = "self_encryption._self_encryption" bindings = "pyo3" +python-source = "python" diff --git a/src/python.rs b/python/bindings/mod.rs similarity index 100% rename from src/python.rs rename to python/bindings/mod.rs diff --git a/self_encryption/__init__.py b/python/self_encryption/__init__.py similarity index 100% rename from self_encryption/__init__.py rename to python/self_encryption/__init__.py diff --git a/self_encryption/cli.py b/python/self_encryption/cli.py similarity index 100% rename from self_encryption/cli.py rename to python/self_encryption/cli.py diff --git a/tests/test_bindings.py b/python/tests/test_bindings.py similarity index 98% rename from tests/test_bindings.py rename to python/tests/test_bindings.py index c51927cd4..4a795176f 100644 --- a/tests/test_bindings.py +++ b/python/tests/test_bindings.py @@ -4,8 +4,6 @@ from typing import List import pytest from self_encryption import ( - DataMap, - XorName, encrypt_from_file, decrypt_from_storage, streaming_decrypt_from_storage, diff --git a/tests/test_cli.py b/python/tests/test_cli.py similarity index 99% rename from tests/test_cli.py rename to python/tests/test_cli.py index 4ba4df0bf..baadc3350 100644 --- a/tests/test_cli.py +++ b/python/tests/test_cli.py @@ -2,7 +2,6 @@ from click.testing import CliRunner from self_encryption.cli import cli import tempfile -import os from pathlib import Path @pytest.fixture diff --git a/src/lib.rs b/src/lib.rs index f2bb9436c..5123c2257 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -94,7 +94,9 @@ mod encrypt; mod encryption; mod error; #[cfg(feature = "python")] -mod python; +mod bindings { + include!("../python/bindings/mod.rs"); +} pub mod test_helpers; mod utils;