Skip to content

Commit

Permalink
chore: simplify grpc-web package renaming script
Browse files Browse the repository at this point in the history
  • Loading branch information
jselig-rigetti committed Mar 21, 2024
1 parent 1d1b7a7 commit f6119a1
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 43 deletions.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ pyo3 = { version = "0.20.0", features = ["extension-module"] }
pyo3-asyncio = { version = "0.20", features = ["tokio-runtime"] }
pyo3-build-config = "0.20.0"
rigetti-pyo3 = { version = "0.3.1", default-features = false, features = ["complex"] }
ring = "0.17.7"

# The primary intent of these options is to reduce the binary size for Python wheels
# since PyPi has limits on how much storage a project can use.
Expand Down
40 changes: 40 additions & 0 deletions crates/python/scripts/patch_grpc_web.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Appends grpc-web to the project name of both Cargo.toml and pyproject.toml,
and patches the `hyper-proxy` dependency.
This is used in CI to update the package metadata before publishing the alternate
package with the grpc-web feature enabled.
"""

from io import TextIOWrapper
from os.path import dirname, realpath, relpath, join
import toml

pycrate_path = dirname(dirname(realpath(__file__)))
workspace_path = dirname(dirname(pycrate_path))


def write(f: TextIOWrapper, data):
f.seek(0)
f.write(toml.dumps(data))
f.truncate()


# Update the package metadata

with open(join(pycrate_path, "pyproject.toml"), "r+") as f:
data = toml.load(f)
data["project"]["name"] = "qcs-sdk-python-grpc-web"
write(f, data)

with open(join(pycrate_path, "Cargo.toml"), "r+") as f:
data = toml.load(f)
data["package"]["name"] = "qcs-sdk-python-grpc-web"
write(f, data)

# Patch the `hyper-proxy` dependency

with open(join(workspace_path, "Cargo.toml"), "r+") as f:
data = toml.load(f)
data["patch"] = {"crates-io": {"hyper-proxy": {"git": "https://github.com/rigetti/hyper-proxy"}}}
write(f, data)
20 changes: 0 additions & 20 deletions crates/python/scripts/patch_hyper_proxy.py

This file was deleted.

21 changes: 0 additions & 21 deletions crates/python/scripts/patch_package_name.py

This file was deleted.

2 changes: 1 addition & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ unknown-registry = "deny"
# Lint level for what to happen when a crate from a git repository that is not
# in the allow list is encountered
unknown-git = "deny"
allow-git = ["https://github.com/rigetti/quil-rs", "https://github.com/rigetti/qcs-api-client-rust"]
allow-git = ["https://github.com/rigetti/quil-rs"]
# List of URLs for allowed crate registries. Defaults to the crates.io index
# if not specified. If it is specified but empty, no registries are allowed.
allow-registry = ["https://github.com/rust-lang/crates.io-index"]

0 comments on commit f6119a1

Please sign in to comment.