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
19 changes: 16 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4
Expand All @@ -21,12 +22,12 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
python-version: ${{ matrix.python-version }}

- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: '1.21'
go-version: '1.25'

- name: Install uv
uses: astral-sh/setup-uv@v7
Expand Down Expand Up @@ -58,10 +59,22 @@ jobs:
- name: Build package
run: uv run python -m build

- name: Repair wheels (Linux)
if: runner.os == 'Linux'
run: |
uv pip install auditwheel
# Repair wheels and output to a temporary directory
uv run auditwheel repair dist/*.whl -w dist_fixed
# Remove original non-compliant wheels
rm dist/*.whl
# Move repaired wheels back to dist
mv dist_fixed/*.whl dist/
rmdir dist_fixed

- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions-${{ matrix.os }}
name: python-package-distributions-${{ matrix.os }}-${{ matrix.python-version }}
path: dist/

publish-to-pypi:
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ graft third_party/spdlog-1.14.1
graft third_party/croaring
graft third_party/rapidjson
recursive-include third_party/agfs/agfs-server *.go go.mod go.sum Makefile
recursive-include third_party/agfs/agfs-sdk/go *.go go.mod
include third_party/agfs/bin/agfs-server
include LICENSE
include README.md
Expand Down
2 changes: 1 addition & 1 deletion openviking/utils/config/open_viking_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class OpenVikingConfig(BaseModel):
)

log_level: str = Field(
default="INFO", description="Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL"
default="WARNING", description="Logging level: DEBUG, INFO, WARNING, ERROR, CRITICAL"
)

log_format: str = Field(
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ build-backend = "setuptools.build_meta"

[project]
name = "openviking"
version = "0.1.2"
version = "0.1.5"
description = "An Agent-native context database: Data in, Context out"
readme = "README.md"
authors = [
{name = "ByteDance", email = "noreply@bytedance.com"}
]
license = "Apache-2.0"
license = { text = "Apache-2.0" }
requires-python = ">=3.9"
classifiers = [
"Development Status :: 3 - Alpha",
Expand Down
95 changes: 51 additions & 44 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,70 +21,77 @@
for ext in self.extensions:
self.build_extension(ext)

def _copy_binary(self, src, dst):
"""Helper to copy binary and set permissions."""
print(f"Copying AGFS binary from {src} to {dst}")
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(str(src), str(dst))
if sys.platform != "win32":
os.chmod(str(dst), 0o755)

Check failure

Code scanning / CodeQL

Overly permissive file permissions High

Overly permissive mask in chmod sets file to world readable.

Copilot Autofix

AI 10 months ago

To fix the problem, the permissions set by os.chmod should be restricted so that only the file’s owner has access, in line with the recommendation. For an executable binary that the owner must be able to run, a typical secure mask is 0o700 (read/write/execute for owner, no permissions for group or others). This keeps functionality for the owner intact while preventing other users from reading or executing the binary.

Concretely, in setup.py, in the _copy_binary method of CMakeBuildExtension, change the os.chmod(str(dst), 0o755) call on line 30 to use 0o700 instead. No additional imports or helper methods are required; we simply adjust the permission bits. All other logic in _copy_binary and the rest of the file remains unchanged.

Suggested changeset 1
setup.py

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -27,7 +27,7 @@
         dst.parent.mkdir(parents=True, exist_ok=True)
         shutil.copy2(str(src), str(dst))
         if sys.platform != "win32":
-            os.chmod(str(dst), 0o755)
+            os.chmod(str(dst), 0o700)
 
     def build_agfs(self):
         """Build AGFS server, fallback to prebuilt binary if build fails."""
EOF
@@ -27,7 +27,7 @@
dst.parent.mkdir(parents=True, exist_ok=True)
shutil.copy2(str(src), str(dst))
if sys.platform != "win32":
os.chmod(str(dst), 0o755)
os.chmod(str(dst), 0o700)

def build_agfs(self):
"""Build AGFS server, fallback to prebuilt binary if build fails."""
Copilot is powered by AI and may make mistakes. Always verify output.

def build_agfs(self):
"""Build AGFS server, fallback to prebuilt binary if build fails."""
agfs_server_dir = Path("third_party/agfs/agfs-server").resolve()
# Paths
binary_name = "agfs-server.exe" if sys.platform == "win32" else "agfs-server"
agfs_server_dir = Path("third_party/agfs/agfs-server").resolve()
agfs_prebuilt_binary = Path(f"third_party/agfs/bin/{binary_name}").resolve()

# Target in source tree (for development/install)
agfs_bin_dir = Path("openviking/bin").resolve()
agfs_target_binary = agfs_bin_dir / binary_name

agfs_bin_dir.mkdir(parents=True, exist_ok=True)

# 1. Try to build from source
build_success = False
if agfs_server_dir.exists():
go_executable = shutil.which("go")
if go_executable:
print("Building AGFS server from source...")
import subprocess
try:
if sys.platform == "win32":
# Now that we fixed the code compatibility, we can use go build directly on Windows
build_cmd = ["go", "build", "-o", f"build/{binary_name}", "cmd/server/main.go"]
else:
build_cmd = ["make", "build"]

subprocess.run(
build_cmd,
cwd=str(agfs_server_dir),
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

agfs_built_binary = agfs_server_dir / "build" / binary_name
if agfs_built_binary.exists():
shutil.copy2(str(agfs_built_binary), str(agfs_target_binary))
if sys.platform != "win32":
os.chmod(str(agfs_target_binary), 0o755)
print(f"[OK] AGFS server built successfully from source")
build_success = True
except subprocess.CalledProcessError as e:
print(f"Warning: Failed to build AGFS from source: {e}")
if e.stdout:
print(f"Build stdout:\n{e.stdout.decode('utf-8', errors='replace')}")
if e.stderr:
print(f"Build stderr:\n{e.stderr.decode('utf-8', errors='replace')}")
except Exception as e:
print(f"Warning: Failed to build AGFS from source: {e}")
else:
print("Warning: Go compiler not found, will use prebuilt binary")
if agfs_server_dir.exists() and shutil.which("go"):
print("Building AGFS server from source...")
import subprocess
try:
build_args = ["go", "build", "-o", f"build/{binary_name}", "cmd/server/main.go"] if sys.platform == "win32" else ["make", "build"]

subprocess.run(
build_args,
cwd=str(agfs_server_dir),
check=True,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)

agfs_built_binary = agfs_server_dir / "build" / binary_name
if agfs_built_binary.exists():
self._copy_binary(agfs_built_binary, agfs_target_binary)
print(f"[OK] AGFS server built successfully from source")
build_success = True
except (subprocess.CalledProcessError, Exception) as e:
print(f"Warning: Failed to build AGFS from source: {e}")
if isinstance(e, subprocess.CalledProcessError):
if e.stdout: print(f"Build stdout:\n{e.stdout.decode('utf-8', errors='replace')}")
if e.stderr: print(f"Build stderr:\n{e.stderr.decode('utf-8', errors='replace')}")
else:
if not agfs_server_dir.exists():
print("Warning: AGFS source directory not found")
else:
print("Warning: Go compiler not found, will use prebuilt binary")

# 2. Fallback to prebuilt binary if build failed
if not build_success:
if agfs_prebuilt_binary.exists():
print(f"Using prebuilt AGFS binary from {agfs_prebuilt_binary}")
shutil.copy2(str(agfs_prebuilt_binary), str(agfs_target_binary))
if sys.platform != "win32":
os.chmod(str(agfs_target_binary), 0o755)
self._copy_binary(agfs_prebuilt_binary, agfs_target_binary)
print(f"[OK] AGFS server copied from prebuilt binary")
else:
print("Error: No AGFS binary available (build failed and no prebuilt binary found)")
raise FileNotFoundError(
f"AGFS binary not available. Please either:\n"
f" 1. Install Go and build from source, or\n"
f" 2. Ensure prebuilt binary exists at third_party/agfs/bin/{binary_name}"
)

# 3. Ensure AGFS binary is copied to the build directory (where wheel is packaged from)
if self.build_lib:
agfs_bin_dir_build = Path(self.build_lib) / "openviking/bin"
dst = agfs_bin_dir_build / binary_name
if agfs_target_binary.exists():
self._copy_binary(agfs_target_binary, dst)

def build_extension(self, ext):
"""Build a single C++ extension module using CMake."""
ext_fullpath = Path(self.get_ext_fullpath(ext.name))
Expand Down
Loading