Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GuillaumeDesforges/fix-python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

23 Commits

Repository files navigation

fix-python

Work with Python "normally" on NixOS in one command!

Tired of all these "*.so not found" errors? Change the RPATH of all the binaries in your venv!

Requirements

  • Nix
  • nix-command and flakes experimental features must be enabled

Install

Use temporarily in a shell

nix shell github:GuillaumeDesforges/fix-python

Or add it to your profile

nix profile install github:GuillaumeDesforges/fix-python

Usage

In your Python project, create a virtual environment .venv and use your preferred tool (pip, poetry, ...) to install your dependencies.

Important

fix-python will patch binary files in the virtual environment without following symlinks.

For example, if you use the venv module from Python's standard library, please make sure you pass --copies when creating the environment.

python -m venv .venv --copies

By default, fix-python patches the packages given in the following expression:

let pkgs = import (builtins.getFlake "nixpkgs") { };
in [
 pkgs.gcc.cc
 pkgs.glibc
 pkgs.zlib
]

Note: these three packages are fundamental for most Python packages and should never be removed.

If you need to patch packages in addition to these, create a .nix/libs.nix file with a structure similar to the above that returns the array of packages that you want binaries to be linked with.

Note: you may add this .nix folder to your project .gitignore.

Finally, call fix-python.

fix-python --venv .venv [--libs .nix/libs.nix]

The list of options is:

$ ./fix-python --help
Usage: fix-python --venv .venv [--libs libs.nix] [--no-default-libs]
--help: show this help message
--venv: path to Python virtual environment
--libs: path to a Nix file which returns a list of derivations
--no-default-libs: don't patch C++ standard libraries, glibc, and zlib by default
--gpu: enable GPU support
--with-torch: fix pytorch dependencies issues
--deep: looks for anything executable to patch, very slow but needed sometimes (e.g. PyQt)
--verbose: increase verbosity

About

A simple CLI tool to use Python venv "normally" on NixOS

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 5

AltStyle によって変換されたページ (->オリジナル) /