Skip to content

[python] Restructure python/ to src layout for PyPI packaging#180

Merged
forfudan merged 1 commit intoclifrom
update
Mar 2, 2026
Merged

[python] Restructure python/ to src layout for PyPI packaging#180
forfudan merged 1 commit intoclifrom
update

Conversation

@forfudan
Copy link
Copy Markdown
Owner

@forfudan forfudan commented Mar 2, 2026

Restructures the python/ directory to a standard src layout and adds PyPI
packaging scaffolding (reserving the decimo package name).

Changes

PyPI packaging (python/pyproject.toml, python/README.md)

  • Add pyproject.toml with hatchling build backend and src layout.
  • Add python/README.md as the PyPI landing page.
  • Add python/src/decimo/py.typed (PEP 561 marker for type checkers).
  • Placeholder wheel 0.1.0.dev0 published to PyPI — name decimo is now reserved.
  • pixi run wheel task builds the wheel; python-build and twine added to pixi dependencies.

src layout restructure

  • python/decimo.pypython/src/decimo/__init__.py
  • python/_decimo.pyipython/src/decimo/_decimo.pyi
  • python/tests/test_decimo.py — updated sys.path for new layout.
  • pixi run buildpy — output path updated to python/src/decimo/_decimo.so.
  • .vscode/settings.jsonextraPaths updated to ["python/src"].

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates the Python bindings under python/ to a standard src/ layout and introduces initial PyPI packaging scaffolding for the decimo package, aligning the repo with common Python packaging conventions while keeping the native Mojo extension workflow.

Changes:

  • Restructures the Python package into python/src/decimo/ (including __init__.py, _decimo.pyi, and py.typed).
  • Adds python/pyproject.toml and python/README.md to support wheel builds / PyPI metadata (placeholder wheel).
  • Updates pixi tasks and ignores to reflect the new extension output path and wheel build artifacts.

Reviewed changes

Copilot reviewed 6 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
python/tests/test_decimo.py Updates test import path to the new python/src layout.
python/src/decimo/py.typed Adds PEP 561 marker for typed package support.
python/src/decimo/_decimo.pyi Adds type stubs for the native _decimo extension module.
python/src/decimo/init.py Implements package entrypoint and wraps native _decimo import with a user-facing error.
python/pyproject.toml Adds Hatchling-based PyPI build configuration and metadata.
python/README.md Adds PyPI landing-page documentation and build-from-source instructions.
pixi.toml Updates buildpy output path and adds a wheel build task + dependencies.
pixi.lock Locks new dependencies (python-build, twine, transitive deps).
docs/plans/mojo4py.md Updates parts of the plan doc for the new packaging/layout.
.gitignore Ignores python/dist/ wheel output directory.
Comments suppressed due to low confidence (2)

python/src/decimo/init.py:12

  • __version__ is hardcoded here while the package version is also declared in python/pyproject.toml. This is likely to drift and produce incorrect runtime version reporting; consider deriving the version from package metadata (e.g., importlib.metadata.version("decimo")) or using a single source of truth.
    python/src/decimo/init.py:24
  • The broad except ImportError re-raises a new ImportError message, which can obscure the underlying loader error when _decimo exists but fails to load (e.g., missing shared library / ABI mismatch). Consider including the original exception text in the message (or only wrapping the specific “module not found” case) so users can diagnose the real failure.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread python/README.md
Comment on lines +1 to +4
# decimo

**Arbitrary-precision decimal and integer arithmetic for Python, powered by Mojo.**

Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The README tagline claims “decimal and integer arithmetic for Python”, but this Python package currently only exposes BigDecimal bindings (with BigInt/Decimal128 listed as planned later). Consider tightening the wording to avoid misleading PyPI readers about current functionality.

Copilot uses AI. Check for mistakes.
Comment thread python/pyproject.toml
[project]
name = "decimo"
version = "0.1.0.dev0"
description = "Arbitrary-precision decimal and integer arithmetic for Python, powered by Mojo"
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

description mentions “decimal and integer arithmetic for Python”, but the current Python bindings exposed in this package are for BigDecimal only. Consider adjusting the metadata description to reflect the current surface area to avoid confusing PyPI consumers.

Suggested change
description = "Arbitrary-precision decimal and integer arithmetic for Python, powered by Mojo"
description = "Arbitrary-precision decimal arithmetic for Python (BigDecimal bindings), powered by Mojo"

Copilot uses AI. Check for mistakes.
Comment thread docs/plans/mojo4py.md
Comment on lines 116 to +127

```txt
python/
├── decimo_module.mojo ← Mojo binding source (builds to _decimo.so)
├── _decimo.so ← compiled extension (gitignored)
├── decimo.py ← Python wrapper: Decimal class + BigDecimal alias
├── pyproject.toml ← PyPI package config (hatchling, src layout)
├── README.md ← PyPI landing page
├── decimo_module.mojo ← Mojo binding source (builds to src/decimo/_decimo.so)
├── src/
│ └── decimo/
│ ├── __init__.py ← Python wrapper: Decimal class + BigDecimal alias
│ ├── _decimo.pyi ← Type stub for Pylance/mypy
│ ├── _decimo.so ← compiled extension (gitignored)
│ └── py.typed ← PEP 561 marker
Copy link

Copilot AI Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The updated file-structure section conflicts with later parts of this document that still describe the old layout (decimo.py, python/_decimo.so, and pixi run pybuild/pytest). To keep the plan consistent, update the remaining sections to reflect the new python/src/decimo/ wrapper + buildpy/testpy task names and the new _decimo.so location.

Copilot uses AI. Check for mistakes.
@forfudan forfudan merged commit 7f19aa2 into cli Mar 2, 2026
13 checks passed
@forfudan forfudan deleted the update branch March 2, 2026 20:37
forfudan added a commit that referenced this pull request Mar 23, 2026
Restructures the `python/` directory to a standard `src` layout and adds
PyPI
packaging scaffolding (reserving the `decimo` package name).

## Changes

### PyPI packaging (`python/pyproject.toml`, `python/README.md`)
- Add `pyproject.toml` with `hatchling` build backend and `src` layout.
- Add `python/README.md` as the PyPI landing page.
- Add `python/src/decimo/py.typed` (PEP 561 marker for type checkers).
- Placeholder wheel `0.1.0.dev0` published to PyPI — name `decimo` is
now reserved.
- `pixi run wheel` task builds the wheel; `python-build` and `twine`
added to pixi dependencies.

### `src` layout restructure
- `python/decimo.py` → `python/src/decimo/__init__.py`
- `python/_decimo.pyi` → `python/src/decimo/_decimo.pyi`
- `python/tests/test_decimo.py` — updated `sys.path` for new layout.
- `pixi run buildpy` — output path updated to
`python/src/decimo/_decimo.so`.
- `.vscode/settings.json` — `extraPaths` updated to `["python/src"]`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants