1
0
mirror of https://github.com/facebook/proxygen.git synced 2025-08-07 07:02:53 +03:00

Use getdeps.py to drive build of OSS CinderX

Summary: Add a "manifest" for CinderX allowing it and its dependencies to be built and tested with `getdeps.py`. There was no pre-existing "builder" that was appropriate for building a Python extension from source, but rather than adding one that's specific to Cinderx I've tried to write a general builder that uses `setup.py` to install the build into the Python install.

Reviewed By: alexmalyshev

Differential Revision: D79287319

fbshipit-source-id: d302bea10c6a79cdedc08cd93b0362259dea522b
This commit is contained in:
Jacob Bower
2025-08-01 01:53:45 -07:00
committed by Facebook GitHub Bot
parent 8c1e7cfbc2
commit 573aa3b6a1
3 changed files with 78 additions and 0 deletions

View File

@@ -1368,6 +1368,46 @@ class NopBuilder(BuilderBase):
simple_copytree(self.src_dir, self.inst_dir)
class SetupPyBuilder(BuilderBase):
def _build(self, reconfigure) -> None:
env = self._compute_env()
setup_py_path = os.path.join(self.src_dir, "setup.py")
if not os.path.exists(setup_py_path):
raise RuntimeError(f"setup.py script not found at {setup_py_path}")
self._check_cmd(
[path_search(env, "python3"), setup_py_path, "install"],
cwd=self.src_dir,
env=env,
)
# Create the installation directory if it doesn't exist
os.makedirs(self.inst_dir, exist_ok=True)
# Mark the project as built
with open(os.path.join(self.inst_dir, ".built-by-getdeps"), "w") as f:
f.write("built")
def run_tests(self, schedule_type, owner, test_filter, retry, no_testpilot) -> None:
# setup.py actually no longer has a standard command for running tests.
# Instead we let manifest files specify an arbitrary Python file to run
# as a test.
# Get the test command from the manifest
python_script = self.manifest.get(
"setup-py.test", "python_script", ctx=self.ctx
)
if not python_script:
print(f"No test script specified for {self.manifest.name}")
return
# Run the command
env = self._compute_env()
self._check_cmd(["python3", python_script], cwd=self.src_dir, env=env)
class SqliteBuilder(BuilderBase):
def __init__(
self,

View File

@@ -21,6 +21,7 @@ from .builder import (
NinjaBootstrap,
NopBuilder,
OpenSSLBuilder,
SetupPyBuilder,
SqliteBuilder,
SystemdBuilder,
)
@@ -114,6 +115,7 @@ SCHEMA = {
"subprojects": {"optional_section": True},
# fb-only
"sandcastle": {"optional_section": True, "fields": {"run_tests": OPTIONAL}},
"setup-py.test": {"optional_section": True, "fields": {"python_script": REQUIRED}},
}
# These sections are allowed to vary for different platforms
@@ -684,6 +686,18 @@ class ManifestParser(object):
inst_dir,
)
if builder == "setup-py":
return SetupPyBuilder(
loader,
dep_manifests,
build_options,
ctx,
self,
src_dir,
build_dir,
inst_dir,
)
if builder == "cargo":
return self.create_cargo_builder(
loader,

View File

@@ -0,0 +1,24 @@
[manifest]
name = cinderx-3.12mp
fbsource_path = fbcode/cinderx
shipit_project = facebookincubator/cinderx
[git]
repo_url = https://github.com/facebookincubator/cinderx.git
[build.os=linux]
builder = setup-py
[build.not(os=linux)]
builder = nop
[dependencies]
python-setuptools
meta-python-3.12
[shipit.pathmap]
fbcode/cinderx = cinderx
fbcode/cinderx/oss_toplevel = .
[setup-py.test]
python_script = cinderx/PythonLib/test_cinderx/test_oss_quick.py