Skip to content

Commit 2df7a57

Browse files
committed
wip: improve dev experience
1 parent 68453a3 commit 2df7a57

File tree

7 files changed

+842
-14
lines changed

7 files changed

+842
-14
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@
1515
[wiki]: https://github.com/agoose77/literary/wiki
1616

1717
## TL;DR
18+
> [!Info]
19+
> To get started, see [the wiki]
20+
1821
Literary is a Python tool to make Jupyter (IPython) notebooks behave like pure-Python packages. This allows pure-Python packages to be generated from notebooks, and notebooks to be imported at runtime. Literary now [bootstraps itself](https://en.wikipedia.org/wiki/Bootstrapping); it is developed with Literary 🤯.
1922

2023
This package is an exploration of the [literate programming](http://www.literateprogramming.com) idea [pioneered by
@@ -37,3 +40,5 @@ notebooks
3740
be generated from the notebooks, and it must use the conventional import model. For
3841
this reason, `literary` should only exist as a development dependency of
3942
the package.
43+
44+
[the wiki]: https://github.com/agoose77/literary/wiki

flake.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# code-owner: @agoose77
2+
# This flake sets up an FSH dev-shell that installs all the required
3+
# packages for running deployer, and then installs the tool in the virtual environment
4+
# It is not best-practice for the nix-way of distributing this code,
5+
# but its purpose is to get an environment up and running.
6+
{
7+
inputs = {
8+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
9+
flake-utils.url = "github:numtide/flake-utils";
10+
};
11+
outputs = {
12+
self,
13+
nixpkgs,
14+
flake-utils,
15+
}:
16+
flake-utils.lib.eachDefaultSystem (system: let
17+
pkgs = nixpkgs.legacyPackages.${system};
18+
inherit (pkgs) lib;
19+
20+
python = pkgs.python313;
21+
packages =
22+
[
23+
python
24+
]
25+
++ (with pkgs; [
26+
cmake
27+
ninja
28+
gcc
29+
pre-commit
30+
# Infra packages
31+
nodejs
32+
]);
33+
shellHook = ''
34+
# Unset leaky PYTHONPATH
35+
unset PYTHONPATH
36+
37+
__hash=$(echo ${python.interpreter} | sha256sum)
38+
39+
# Setup if not defined ####
40+
if [[ ! -f ".venv/$__hash" ]]; then
41+
__setup_env() {
42+
# Remove existing venv
43+
if [[ -d .venv ]]; then
44+
rm -r .venv
45+
fi
46+
47+
# Stand up new venv
48+
${python.interpreter} -m venv .venv
49+
50+
".venv/bin/python" -m pip install --group develop
51+
52+
# Add a marker that marks this venv as "ready"
53+
touch ".venv/$__hash"
54+
}
55+
56+
__setup_env
57+
fi
58+
###########################
59+
60+
export PYTHONPATH="$(git rev-parse --show-toplevel)/lib/"
61+
62+
# Activate venv
63+
source .venv/bin/activate
64+
'';
65+
env = lib.optionalAttrs pkgs.stdenv.isLinux {
66+
# Python uses dynamic loading for certain libraries.
67+
# We'll set the linker path instead of patching RPATH
68+
LD_LIBRARY_PATH = lib.makeLibraryPath pkgs.pythonManylinuxPackages.manylinux2014;
69+
};
70+
in {
71+
devShell = pkgs.mkShell {
72+
inherit env packages shellHook;
73+
};
74+
});
75+
}

pyproject.toml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,15 @@ authors = [
66
{name = "Angus Hollands", email = "goosey15@gmail.com"},
77
]
88
dependencies = [
9-
"nbformat[fast]>=5",
9+
"nbformat>=5.10",
1010
"nbclient>=0.5.12",
1111
"nbconvert>=6.0",
1212
"traitlets>=5",
13-
"astunparse>=1.6; python_version < \"3.9\"",
14-
"ipython>=7.33.0",
13+
"ipython>=7.33",
1514
"typing-extensions>=3.10",
1615
"jupyter-core>=4.7",
1716
]
18-
requires-python = ">=3.7"
17+
requires-python = ">=3.9"
1918
readme = "README.md"
2019
license = {file = "LICENSE"}
2120
classifiers = [
@@ -27,9 +26,11 @@ classifiers = [
2726
"Programming Language :: Python",
2827
"Programming Language :: Python :: 3",
2928
"Programming Language :: Python :: 3 :: Only",
30-
"Programming Language :: Python :: 3.7",
31-
"Programming Language :: Python :: 3.8",
32-
"Programming Language :: Python :: 3.9"]
29+
"Programming Language :: Python :: 3.9",
30+
"Programming Language :: Python :: 3.10",
31+
"Programming Language :: Python :: 3.11",
32+
"Programming Language :: Python :: 3.12",
33+
"Programming Language :: Python :: 3.13"]
3334
keywords = [
3435
"literate-programming",
3536
"jupyter",
@@ -49,16 +50,15 @@ literary = "literary.transpile.exporter:LiteraryExporter"
4950

5051
[project.optional-dependencies]
5152

52-
[tool]
53-
[tool.pdm]
54-
[tool.pdm.dev-dependencies]
55-
dev = [
53+
[dependency-groups]
54+
develop = [
5655
"jupyterlab>=3.4.0",
5756
"pytest>=7.1.2",
58-
"literary>=4.0.0",
5957
"jupyterlab-code-formatter>=1.4.11",
6058
"black>=22.3.0",
6159
"isort>=5.10.1",
60+
# Needed for building literary live!
61+
"literary>=4.0.1"
6262
]
6363

6464
[tool.hatch.build]

src/literary/__init__.ipynb

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": null,
6+
"id": "9a348033-a307-4274-968d-680c360978c7",
7+
"metadata": {},
8+
"outputs": [],
9+
"source": []
10+
}
11+
],
12+
"metadata": {
13+
"kernelspec": {
14+
"display_name": "Python 3 (ipykernel)",
15+
"language": "python",
16+
"name": "python3"
17+
},
18+
"language_info": {
19+
"codemirror_mode": {
20+
"name": "ipython",
21+
"version": 3
22+
},
23+
"file_extension": ".py",
24+
"mimetype": "text/x-python",
25+
"name": "python",
26+
"nbconvert_exporter": "python",
27+
"pygments_lexer": "ipython3",
28+
"version": "3.13.5"
29+
}
30+
},
31+
"nbformat": 4,
32+
"nbformat_minor": 5
33+
}

0 commit comments

Comments
 (0)