Metadata-Version: 2.4
Name: regwright-kernel
Version: 0.1.0
Summary: Jupyter kernel for Stata syntax, powered by the Regwright engine (no Stata required)
Author: ALGD LTD
License-Expression: MIT
License-File: LICENSE
Keywords: jupyter,kernel,stata,do-file,econometrics,statistics
Classifier: Framework :: Jupyter
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Information Analysis
Project-URL: Homepage, https://regwright.com
Requires-Python: >=3.9
Requires-Dist: ipykernel>=6.0
Requires-Dist: jupyter_client>=7.0
Description-Content-Type: text/markdown

# regwright-kernel

A Jupyter kernel that runs Stata syntax in notebooks (JupyterLab, Notebook, VS Code and nbconvert)
using the [Regwright](https://regwright.com) engine. You don't need Stata.

```stata
sysuse wages, clear
regress wage educ exper
scatter wage educ
```

## Install

1. Install the `regwright` command-line tool from [regwright.com](https://regwright.com), and
   check that `regwright --version` works.
2. Install the kernel:

   ```sh
   pip install regwright-kernel
   ```

   The wheel installs the kernelspec into the environment (`share/jupyter/kernels/regwright`). If
   Jupyter runs from a different environment, register the kernel there yourself:

   ```sh
   python -m regwright_kernel install --user        # or --sys-prefix, or --prefix PATH
   ```

3. Choose **Regwright (Stata syntax)** as the notebook kernel.

## What it does

- Each kernel keeps one `regwright serve` session, so data, macros and estimates carry over from
  cell to cell, as they do in a Stata session.
- Output goes to stdout. Error messages go to stderr, and a failed cell has status `error` with the
  Stata return code as its name (for example `r(111)`). A notebook run with `nbconvert --execute`
  therefore stops at the first error, just as a do-file does.
- Graphs (`scatter`, `twoway`, `histogram`, `graph bar`…) appear under the cell as SVG.
- <kbd>Tab</kbd> completes command names at the start of a statement and variable names elsewhere.
  <kbd>Shift</kbd>+<kbd>Tab</kbd> shows a variable's type, format and label, or a one-line summary
  of a command.

## Settings (environment variables)

| Variable | Meaning |
|---|---|
| `REGWRIGHT_PATH` | Path to the `regwright` binary, if it isn't on `PATH` |
| `REGWRIGHT_DATA` | Extra folders for `sysuse`/`use`, separated by `:` (`;` on Windows) |
| `REGWRIGHT_KERNEL_ECHO=1` | Echo each command (`. regress …`) before its output, as in a log |
| `REGWRIGHT_LICENSE` | Licence key. You can also install it with `regwright licence install KEY` |

**Regwright Free** handles datasets of up to 1,000 observations. Licences that remove the limit
are listed at [regwright.com/pricing](https://regwright.com/pricing).

## Building from source

The package has its own small build backend (`_backend/`), so it builds with no build dependencies:

```sh
python -m pip wheel --no-deps --no-build-isolation kernel/ -w dist
```

To run the tests you need a `regwright` binary plus ipykernel, jupyter_client, nbclient and nbformat:

```sh
REGWRIGHT_BIN=/path/to/regwright REGWRIGHT_TEST_DATA=/path/with/wages.dta python kernel/tests/test_kernel.py
```

"Stata" is a trademark of StataCorp LLC. Regwright is an independent product and is not
affiliated with StataCorp. The kernel is MIT-licensed. The Regwright engine is commercial
software with a free tier.
