Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Commit

Permalink
Fix PyPI publishing by modernizing package configuration
Browse files Browse the repository at this point in the history
This commit updates our package configuration to use modern Python packaging tools:
- Moves build configuration to pyproject.toml using hatchling as the build backend
- Updates metadata version to properly handle license-file
- Converts setup.py to a custom build hook for dynamic dependency handling
- Maintains existing functionality while using modern packaging standards

Fixes #596
  • Loading branch information
mentatai[bot] committed Jan 7, 2025
1 parent 3a01f0a commit a4ce249
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
33 changes: 32 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[project]
name = "mentat"
dynamic = ["version"]
description = "AI coding assistant on your command line"
readme = "README.md"
license = { file = "LICENSE" }
requires-python = ">=3.10"
authors = [
{ name = "Abante AI", email = "[email protected]" },
]
dependencies = [
# We'll dynamically read these from requirements.txt in the [tool.hatch.build.targets.wheel] section
]

[tool.hatch.version]
path = "mentat/VERSION"

[tool.hatch.build.targets.wheel]
packages = ["mentat", "benchmarks"]

[tool.hatch.build.targets.wheel.hooks.custom]
path = "setup.py"

[project.scripts]
mentat = "mentat.terminal.client:run_cli"
mentat-server = "mentat.server.mentat_server:main"
mentat-daemon = "mentat.daemon:main"

[tool.ruff]
line-length = 120

[tool.pytest.ini_options]
addopts = "--ignore=vscode/bundled --ignore=benchmarks/benchmark_repos --ignore=testbed/exercism-python"

48 changes: 11 additions & 37 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,18 @@
from pathlib import Path

import pkg_resources
from setuptools import find_packages, setup

readme_path = os.path.join(Path(__file__).parent, "README.md")
with open(readme_path, "r", encoding="utf-8") as f:
long_description = f.read()

def read_requirements(filename):
"""Read requirements from a file and return as a list of strings."""
with open(os.path.join(os.path.dirname(__file__), filename)) as f:
return [str(r) for r in pkg_resources.parse_requirements(f)]

version_path = os.path.join(Path(__file__).parent, "mentat/VERSION")
with open(version_path, "r", encoding="utf-8") as f:
VERSION = f.read().strip()

setup(
name="mentat",
version=VERSION,
python_requires=">=3.10",
packages=find_packages(include=["mentat", "mentat.*", "benchmarks", "benchmarks.*"]),
install_requires=[
str(r)
for r in pkg_resources.parse_requirements(open(os.path.join(os.path.dirname(__file__), "requirements.txt")))
],
entry_points={
"console_scripts": [
"mentat=mentat.terminal.client:run_cli",
"mentat-server=mentat.server.mentat_server:main",
"mentat-daemon=mentat.daemon:main",
],
},
description="AI coding assistant on your command line",
long_description=long_description,
long_description_content_type="text/markdown",
license="Apache-2.0",
include_package_data=True,
extras_require={
"dev": [
str(r)
for r in pkg_resources.parse_requirements(
open(os.path.join(os.path.dirname(__file__), "dev-requirements.txt"))
)
],
},
)
def hook(version, build_data):
"""Custom build hook for hatchling to set dynamic dependencies."""
build_data["dependencies"] = read_requirements("requirements.txt")
build_data["optional-dependencies"] = {
"dev": read_requirements("dev-requirements.txt")
}
return build_data

0 comments on commit a4ce249

Please sign in to comment.