Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/cosmos/azure-cosmos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target/
/azure/cosmos/_rust*.so
212 changes: 212 additions & 0 deletions sdk/cosmos/azure-cosmos/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions sdk/cosmos/azure-cosmos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[workspace]
members = ["azure_cosmos_rust"]
resolver = "2"

[workspace.package]
authors = ["Microsoft <azpysdkhelp@microsoft.com>"]
edition = "2021"
license = "MIT"
repository = "https://github.com/Azure/azure-sdk-for-python"
rust-version = "1.97"

[workspace.lints.rust]
unsafe_code = "forbid"

[workspace.dependencies]
pyo3 = "0.22"
19 changes: 19 additions & 0 deletions sdk/cosmos/azure-cosmos/azure_cosmos_rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "azure_cosmos_rust"
version = "0.1.0"
description = "Compiled extension for the Azure Cosmos DB Python SDK."
authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
rust-version.workspace = true
publish = false

[lints]
workspace = true

[lib]
crate-type = ["cdylib"]

[dependencies]
pyo3 = { workspace = true, features = ["extension-module", "abi3-py310", "generate-import-lib"] }
9 changes: 9 additions & 0 deletions sdk/cosmos/azure-cosmos/azure_cosmos_rust/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

use pyo3::prelude::*;

#[pymodule]
fn _rust(_module: &Bound<'_, PyModule>) -> PyResult<()> {
Ok(())
}
84 changes: 84 additions & 0 deletions sdk/cosmos/azure-cosmos/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,87 @@
[build-system]
requires = ["maturin==1.15.0"]
build-backend = "maturin"

[project]
name = "azure-cosmos"
version = "4.17.2"
description = "Microsoft Azure Cosmos Client Library for Python"
readme = "README.md"
# Target Python 3.10 now because the V5 Python code being migrated in later PRs
# uses the dataclass options kw_only and slots, both introduced in Python 3.10.
requires-python = ">=3.10"
license = { text = "MIT License" }
authors = [{ name = "Microsoft Corporation", email = "askdocdb@microsoft.com" }]
maintainers = [{ name = "Microsoft", email = "askdocdb@microsoft.com" }]
keywords = ["azure", "azure sdk"]
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Natural Language :: English",
"Programming Language :: Python",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3",
"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",
]
dependencies = ["azure-core>=1.30.0", "typing-extensions>=4.6.0"]

[project.optional-dependencies]
aio = ["azure-core[aio]>=1.30.0"]

[project.urls]
Homepage = "https://github.com/Azure/azure-sdk-for-python"

[tool.maturin]
manifest-path = "azure_cosmos_rust/Cargo.toml"
module-name = "azure.cosmos._rust"
python-source = "."
locked = true
include = [
{ path = "LICENSE", format = "sdist" },
{ path = "rust-toolchain.toml", format = "sdist" },
{ path = "scripts/*.sh", format = "sdist" },
{ path = "samples/**/*", format = "sdist" },
{ path = "tests/**/*", format = "sdist" },
{ path = "doc/**/*.rst", format = "sdist" },
{ path = "*.md", format = "sdist" },
]
exclude = [
{ path = "azure/__init__.py", format = "wheel" },
"**/__pycache__/**",
"**/*.py[co]",
]

[tool.cibuildwheel]
build = ["cp310-*"]
skip = ["*-musllinux*"]
test-command = "python -I -c \"from azure.cosmos import CosmosClient, _rust; from importlib.machinery import EXTENSION_SUFFIXES; assert _rust.__file__.endswith(tuple(EXTENSION_SUFFIXES))\""

[tool.cibuildwheel.windows]
archs = ["AMD64"]

[tool.cibuildwheel.macos]
archs = ["arm64"]
environment = { PATH = "$HOME/.msrustup/multiplexers/bin:$PATH" }

[tool.cibuildwheel.linux]
archs = ["x86_64"]
manylinux-x86_64-image = "manylinux_2_28"
environment-pass = [
"PIP_INDEX_URL",
"MSRUSTUP_ACCESS_TOKEN",
"MSRUSTUP_PAT",
"MSRUSTUP_FEED_URL",
"CARGO_REGISTRIES_AZURE_SDK_FOR_RUST_PUBLIC_INDEX",
"CARGO_REGISTRIES_AZURE_SDK_FOR_RUST_PUBLIC_TOKEN",
"CARGO_REGISTRIES_AZURE_SDK_FOR_RUST_PUBLIC_CREDENTIAL_PROVIDER",
]
environment = { MSRUSTUP_HOME = "/msrustup", CARGO_HOME = "/cargo", PATH = "/msrustup/multiplexers/bin:$PATH" }
before-all = "dnf install -y jq && mkdir -p $MSRUSTUP_HOME/bootstrap && cd $MSRUSTUP_HOME/bootstrap && sh /project/scripts/install-msrustup.sh && cd /project && $MSRUSTUP_HOME/bootstrap/msrustup toolchain install && sh /project/scripts/configure-cargo-feed.sh"

[tool.azure-sdk-build]
mypy = true
pyright = false
Expand Down
4 changes: 4 additions & 0 deletions sdk/cosmos/azure-cosmos/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Microsoft toolchains require msrustup rather than public rustup.
[toolchain]
channel = "ms-prod-1.97"
profile = "minimal"
31 changes: 31 additions & 0 deletions sdk/cosmos/azure-cosmos/scripts/configure-cargo-feed.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/bin/sh
# Point cargo inside the manylinux container at the authenticated pipeline feed.
set -eu

REGISTRY_NAME=azure-sdk-for-rust-public
INDEX="${CARGO_REGISTRIES_AZURE_SDK_FOR_RUST_PUBLIC_INDEX:-}"

if [ -z "$INDEX" ]; then
echo "No cargo registry index forwarded, leaving crates.io source unchanged."
exit 0
fi

if [ -z "${CARGO_REGISTRIES_AZURE_SDK_FOR_RUST_PUBLIC_TOKEN:-}" ]; then
echo "Cargo registry index is set but its token is missing; the feed requires authentication." >&2
exit 1
fi

CARGO_CONFIG_HOME="${CARGO_HOME:-$HOME/.cargo}"
mkdir -p "$CARGO_CONFIG_HOME"

# Cargo reads the registry index and credentials from the environment, but
# crates.io source replacement must be specified in a configuration file.
cat > "$CARGO_CONFIG_HOME/config.toml" <<EOF
[source.crates-io]
replace-with = "$REGISTRY_NAME"

[net]
git-fetch-with-cli = true
EOF

echo "Replaced the crates-io source with '$REGISTRY_NAME' in $CARGO_CONFIG_HOME/config.toml"
Loading
Loading