Skip to main content

# nixpkgs-python-importer

## What

An importlib hack that allows from nixpkgs.pythonpackagename import modulename.

Examples:

from nixpkgs.scipy import scipy import nixpkgs.scipy.scipy from nixpkgs.matplotlib.matplotlib import pyplot as plt import nixpkgs.matplotlib.matplotlib.pyplot as plt from nixpkgs.pillow.PIL import Image

## Why

I used to be a researcher who used 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 to try it would be (on a recent NixOS):

` nix run -f '(import <nixpkgs> {}).python3.withPackages(ps:[ps.nixpkgs])' -c python ` then try from nixpkgs.pbr import pbr (or any other package).

If that doesn’t work, you may also try your luck with unstable nixpkgs:

` nix run -f channel:nixos-unstable '(import <nixpkgs> {}).python3.withPackages(ps:[ps.nixpkgs])' -c python `

Metadata

Release files for nixpkgs 0.2.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nixpkgs 0.2.4
File Size Uploaded Provenance
nixpkgs-0.2.4.tar.gz 5.8 kB Without provenance Details

Release files / nixpkgs-0.2.4.tar.gz

Download URL nixpkgs-0.2.4.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
6d5b50d7937b78c3c2724d89fadaa55dbbde01a35c106090da14567517c19b36
BLAKE2b-256 checksum
How to use checksums
b5ddae4ca71cf62847421ea775317ff18a8e9b4813c49c5dc3f331a79e644c3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.4

Security for nixpkgs 0.2.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page