Abuses Nix philosophy, allowing me to do `from nixpkgs import scipy` anytime
Project description
# nixpkgs-python-importer
## What
An importlib hack that allows `from nixpkgs import somepackage`.
Examples:
import nixpkgs.scipy.scipy
from nixpkgs.scipy import scipy
from nixpkgs.matplotlib.matplotlib import pyplot as plt
import nixpkgs.matplotlib.matplotlib.pyplot as plt
from nixpkgs.pillow.PIL import Image
## Why
I am a researcher and I use `python` and `xonsh` interactively a lot.
While I appreciate the purity of Nix, sometimes I really want to violate it
and pull in some dependency into my shell *right now*,
without tearing my session down, editing and rebuilding an environment,
and then recreating my session from history.
A convenient way of spawning a `xonsh` instance with an extra dependency
soothes the nerves a bit, but doesn't really free me from the recreation part.
I started writing a xonsh macro that ended up being a generic Python solution
with a pleasingly nice syntax. I mean, `from nixpkgs.scipy import scipy`.
Ain't that nice?
## How
`importlib` magic
## Try
The quickest way would be
```
nix-shell -p 'python3.withPackages(ps: with ps; [ ( python3.pkgs.buildPythonPackage rec { pname = "nixpkgs"; version="0.2.0"; src = pkgs.python3Packages.fetchPypi { inherit pname version; sha256 = "0825aplpkvphzpggmr25pxjyyqs3k6hmprz9a46ifr729sj9z68y"; }; propagatedBuildInputs = with pkgs.python3Packages; [ pbr pythonix ]; }) ])' --run python
```
then try `from nixpkgs import ` something.
## What
An importlib hack that allows `from nixpkgs import somepackage`.
Examples:
import nixpkgs.scipy.scipy
from nixpkgs.scipy import scipy
from nixpkgs.matplotlib.matplotlib import pyplot as plt
import nixpkgs.matplotlib.matplotlib.pyplot as plt
from nixpkgs.pillow.PIL import Image
## Why
I am a researcher and I use `python` and `xonsh` interactively a lot.
While I appreciate the purity of Nix, sometimes I really want to violate it
and pull in some dependency into my shell *right now*,
without tearing my session down, editing and rebuilding an environment,
and then recreating my session from history.
A convenient way of spawning a `xonsh` instance with an extra dependency
soothes the nerves a bit, but doesn't really free me from the recreation part.
I started writing a xonsh macro that ended up being a generic Python solution
with a pleasingly nice syntax. I mean, `from nixpkgs.scipy import scipy`.
Ain't that nice?
## How
`importlib` magic
## Try
The quickest way would be
```
nix-shell -p 'python3.withPackages(ps: with ps; [ ( python3.pkgs.buildPythonPackage rec { pname = "nixpkgs"; version="0.2.0"; src = pkgs.python3Packages.fetchPypi { inherit pname version; sha256 = "0825aplpkvphzpggmr25pxjyyqs3k6hmprz9a46ifr729sj9z68y"; }; propagatedBuildInputs = with pkgs.python3Packages; [ pbr pythonix ]; }) ])' --run python
```
then try `from nixpkgs import ` something.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
nixpkgs-0.2.1.tar.gz
(5.5 kB
view details)
File details
Details for the file nixpkgs-0.2.1.tar.gz
.
File metadata
- Download URL: nixpkgs-0.2.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.9.1 pkginfo/1.3.2 requests/2.18.4 setuptools/38.4.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26ddfc4619aa2467d2f035ab06e3c17310d98abcc4254e1de60f4109ec982d77 |
|
MD5 | cce3369524df6aa329a260d4facd9efb |
|
BLAKE2b-256 | d2089e2eaf88a178c77ba92b231f2bf9f41d3b621c3599cf2d99f98aa34f23aa |