Skip to content
Merged
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.venv
*.egg-info/
__pycache__
/build
/dist
Expand Down
9 changes: 4 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "temporalio"
version = "1.26.0"
version = "1.26.0.post0"
description = "Temporal.io Python SDK"
authors = [{ name = "Temporal Technologies Inc", email = "sdk@temporal.io" }]
requires-python = ">=3.10"
Expand All @@ -16,7 +16,6 @@ dependencies = [
"typing-extensions>=4.2.0,<5",
]
classifiers = [
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
Expand Down Expand Up @@ -44,10 +43,10 @@ aioboto3 = [
]

[project.urls]
Homepage = "https://github.com/temporalio/sdk-python"
Repository = "https://github.com/temporalio/sdk-python"
Homepage = "https://github.com/lyft/sdk-python"
Repository = "https://github.com/lyft/sdk-python"
Documentation = "https://docs.temporal.io/docs/python"
"Bug Tracker" = "https://github.com/temporalio/sdk-python/issues"
"Bug Tracker" = "https://github.com/lyft/sdk-python/issues"

[dependency-groups]
dev = [
Expand Down
16 changes: 16 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[metadata]
name = temporalio
version = 1.26.0.post0
description = Temporal.io Python SDK
long_description = file: README.md
long_description_content_type = text/markdown
license_files = LICENSE
url = https://github.com/lyft/sdk-python
project_urls =
Homepage = https://github.com/lyft/sdk-python
Documentation = https://docs.temporal.io/docs/python
Repository = https://github.com/lyft/sdk-python
Bug Tracker = https://github.com/lyft/sdk-python/issues

[options]
python_requires = >=3.10
112 changes: 112 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
"""Setuptools entry points for environments that invoke ``setup.py`` directly.

The canonical build definition remains ``pyproject.toml`` / ``maturin``. This
module delegates ``sdist`` and ``bdist_wheel`` to ``python -m maturin`` so
legacy ``python setup.py sdist`` / ``bdist_wheel`` workflows produce the same
artifacts as a PEP 517 build.

Bootstrap tradeoff: if ``maturin`` is not importable as a module, this script
installs ``maturin`` into the *current* interpreter with ``pip`` (requires
network on cold builders). Builders that pre-install ``maturin`` avoid that
step. Alternatives such as ``setup_requires`` are avoided because they interact
poorly with modern pip and isolated metadata resolution.

``maturin sdist`` / ``maturin build`` still invoke Cargo metadata and require a
Rust toolchain (``cargo`` on ``PATH``), same as a normal PEP 517 build.
"""

from __future__ import annotations

import shutil
import subprocess
import sys
from pathlib import Path

from setuptools import setup
from setuptools.command.bdist_wheel import bdist_wheel as _bdist_wheel
from setuptools.command.sdist import sdist as _sdist

ROOT = Path(__file__).resolve().parent
DIST_DIR = "dist"
MATURIN_REQ = "maturin>=1.0,<2.0"


def _output_dir(cmd: object) -> str:
"""Directory for artifacts; honors setuptools ``--dist-dir`` / ``-d`` when set."""
dist_dir = getattr(cmd, "dist_dir", None)
if dist_dir:
return str(dist_dir)
return DIST_DIR


def _have_maturin() -> bool:
exe = shutil.which("maturin")
if exe:
return True
try:
subprocess.run(
[sys.executable, "-m", "maturin", "--version"],
check=True,
capture_output=True,
cwd=ROOT,
)
return True
except (subprocess.CalledProcessError, OSError):
return False


def _ensure_maturin() -> None:
if _have_maturin():
return
subprocess.check_call(
[
sys.executable,
"-m",
"pip",
"install",
MATURIN_REQ,
],
cwd=ROOT,
)


def _maturin_cmd() -> list[str]:
_ensure_maturin()
if shutil.which("maturin"):
return ["maturin"]
return [sys.executable, "-m", "maturin"]


def _run_maturin(args: list[str]) -> None:
cmd = _maturin_cmd() + args
sys.stderr.write("Running: " + " ".join(cmd) + "\n")
subprocess.check_call(cmd, cwd=ROOT)


class sdist(_sdist):
def run(self) -> None:
out = _output_dir(self)
self.mkpath(out)
_run_maturin(["sdist", "-o", out])


class bdist_wheel(_bdist_wheel):
def run(self) -> None:
out = _output_dir(self)
self.mkpath(out)
_run_maturin(
[
"build",
"--release",
"-o",
out,
]
)


setup(
cmdclass={
"sdist": sdist,
"bdist_wheel": bdist_wheel,
},
)