jac-python-interop

Integrates Python and Jac code bidirectionally using imports, inline blocks, and library mode.

Updated Jul 26, 2026
One-click install
npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-python-interop-nihalnihalani
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: jac-python-interop
Source: https://github.com/nihalnihalani/jachacks-sf-2026/tree/main/plugins/jac-codex/skills/jac-python-interop
Command: npx skills add https://github.com/nihalnihalani/jachacks-sf-2026 --skill jac-python-interop-nihalnihalani

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Mixing Jac and Python code raises practical questions: how to import PyPI packages from Jac, how to handle untyped Python values crossing into Jac's strict type system, how to subclass metaclass-driven Python types, and how to call Jac modules from plain Python scripts. This Skill provides the patterns and pitfalls for both directions of the bridge. ## Core Features & Use Cases - PyPI imports from Jac: Import numpy, pandas, sklearn, or local .py files with standard import syntax, including stub installation for typed packages via PEP 561. - Inline Python and class archetypes: Embed legacy Python verbatim in ::py:: blocks, or use the class archetype with static has to subclass metaclass-driven Python types like Pygments lexers. - Jac from Python scripts: Import .jac modules directly via the auto-registered import hook and use jaclang.lib primitives (Node, Walker, spawn, root, connect), or convert with jac2py. - Use Case: A team migrating a Python codebase to Jac keeps a tested validation function in a ::py:: block, imports sklearn for a regression model, and exposes the resulting graph walkers to a Python-only analytics script through jaclang.lib. ## Quick Start Ask the assistant to show how to import a PyPI package like numpy into a Jac file and call it from a with entry block.

Frequently Asked Questions about jac-python-interop

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I import Python packages like numpy or pandas in Jac?▼

Use plain import syntax in Jac, such as import numpy as np or import from sklearn.linear_model { LinearRegression }. Jac compiles to Python bytecode, so any installed PyPI package works without wrappers or FFI.

How do I call Jac code from a Python script?▼

A .pth file installed with jaclang registers an import hook, so .jac modules import directly in Python. Use jaclang.lib for graph primitives like Node, Walker, spawn, connect, and root(), noting root is a function in library mode.

Why does Jac report untyped Python values as errors?▼

Untyped Python returns arrive as any, and Jac's strict typing blocks any from flowing into typed destinations with error E1001. Fix it by adding a .pyi stub, narrowing with isinstance, or casting with value as Type.

When should I use the class archetype instead of obj in Jac?▼

Use class when subclassing a Python type whose metaclass consumes class attributes, such as Pygments RegexLexer or ORM base classes. In a class, static has becomes a real class attribute the metaclass can read, unlike obj's instance fields.

Why do relative imports fail in my Jac entry script?▼

A file run directly with jac run is a top-level script, so import from ..lib fails with no known parent package. Use relative imports only between package modules and absolute imports from the entry script.