Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pkgs/applications/audio/lastwatch/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ pythonPackages.buildPythonPackage rec {

propagatedBuildInputs = pythonPath;

installCommand = "python setup.py install --prefix=$out";

meta = {
homepage = "https://github.com/aszlig/LastWatch";
description = "An inotify-based last.fm audio scrobbler";
Expand Down
9 changes: 7 additions & 2 deletions pkgs/applications/audio/quodlibet/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, fetchurl, python, buildPythonPackage, mutagen, pygtk, pygobject
{ stdenv, fetchurl, python, buildPythonPackage, mutagen, pygtk, pygobject, intltool
, pythonDBus, gst_python, withGstPlugins ? false, gst_plugins_base ? null
, gst_plugins_good ? null, gst_plugins_ugly ? null, gst_plugins_bad ? null }:

Expand Down Expand Up @@ -29,6 +29,11 @@ buildPythonPackage {
})
];

preConfigure = ''
# TODO: for now don't a apply gdist overrides, will be needed for shipping icons, gtk, etc
sed -i /distclass/d setup.py
'';

sourceRoot = "quodlibet-${version}";
postUnpack = ''
# the patch searches for plugins in directory ../plugins
Expand All @@ -42,7 +47,7 @@ buildPythonPackage {
];

propagatedBuildInputs = [
mutagen pygtk pygobject pythonDBus gst_python
mutagen pygtk pygobject pythonDBus gst_python intltool
];

postInstall = stdenv.lib.optionalString withGstPlugins ''
Expand Down
10 changes: 6 additions & 4 deletions pkgs/applications/video/miro/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,19 @@ buildPythonPackage rec {
plat/resources.py
'';

installCommand = ''
python setup.py install --prefix= --root="$out"
'';

# Disabled for now, because it requires networking and even if we skip those
# tests, the whole test run takes around 10-20 minutes.
doCheck = false;
checkPhase = ''
HOME="$TEMPDIR" LANG=en_US.UTF-8 python miro.real --unittest
'';

preInstall = ''
# see https://bitbucket.org/pypa/setuptools/issue/130/install_data-doesnt-respect-prefix
${python}/bin/${python.executable} setup.py install_data --root=$out
sed -i '/data_files=data_files/d' setup.py
'';

postInstall = ''
mv "$out/bin/miro.real" "$out/bin/miro"
'';
Expand Down
31 changes: 31 additions & 0 deletions pkgs/development/python-modules/distutils-cfg/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# global distutils configuration, see http://docs.python.org/2/install/index.html#distutils-configuration-files

{ stdenv, python, writeText, extraCfg ? "" }:


let
distutilsCfg = writeText "distutils.cfg" ''
[easy_install]

# don't allow network connections during build to ensure purity
allow-hosts = None

# make sure we always unzip installed packages otherwise setup hooks won't work
zip_ok = 0

${extraCfg}
'';
in stdenv.mkDerivation {
name = "${python.libPrefix}-distutils.cfg";

buildInputs = [ python ];

unpackPhase = "true";

installPhase = ''
dest="$out/lib/${python.libPrefix}/site-packages/distutils"
mkdir -p $dest
ln -s ${python}/lib/${python.libPrefix}/distutils/* $dest
ln -s ${distutilsCfg} $dest/distutils.cfg
'';
}
140 changes: 89 additions & 51 deletions pkgs/development/python-modules/generic/default.nix
Original file line number Diff line number Diff line change
@@ -1,84 +1,112 @@
/* This function provides a generic Python package builder. It is
intended to work with packages that use `setuptools'
intended to work with packages that use `distutils/setuptools'
(http://pypi.python.org/pypi/setuptools/), which represents a large
number of Python packages nowadays. */

{ python, setuptools, wrapPython, lib, offlineDistutils, recursivePthLoader }:
{ python, setuptools, wrapPython, lib, recursivePthLoader, distutils-cfg }:

{ name, namePrefix ? python.libPrefix + "-"
{ name

, buildInputs ? []
# by default prefix `name` e.g. "python3.3-${name}"
, namePrefix ? python.libPrefix + "-"

, propagatedBuildInputs ? []
, buildInputs ? []

, # List of packages that should be added to the PYTHONPATH
# environment variable in programs built by this function. Packages
# in the standard `propagatedBuildInputs' variable are also added.
# The difference is that `pythonPath' is not propagated to the user
# environment. This is preferrable for programs because it doesn't
# pollute the user environment.
pythonPath ? []
# pass extra information to the distutils global configuration (think as global setup.cfg)
, distutilsExtraCfg ? ""

, installCommand ?
''
easy_install --always-unzip --prefix="$out" .
''
# propagate build dependencies so in case we have A -> B -> C,
# C can import propagated packages by A
, propagatedBuildInputs ? []

, preConfigure ? "true"
# passed to "python setup.py install"
, setupPyInstallFlags ? []

, buildPhase ? "true"
# passed to "python setup.py build"
, setupPyBuildFlags ? []

# enable tests by default
, doCheck ? true

, checkPhase ?
''
runHook preCheck
${python}/bin/${python.executable} setup.py test
runHook postCheck
''

, preInstall ? ""
, postInstall ? ""
# List of packages that should be added to the PYTHONPATH
# environment variable in programs built by this function. Packages
# in the standard `propagatedBuildInputs' variable are also added.
# The difference is that `pythonPath' is not propagated to the user
# environment. This is preferrable for programs because it doesn't
# pollute the user environment.
, pythonPath ? []

, meta ? {}

, ... } @ attrs:

# Keep extra attributes from ATTR, e.g., `patchPhase', etc.
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
python.stdenv.mkDerivation (attrs // {
inherit doCheck buildPhase checkPhase;
inherit doCheck;

name = namePrefix + name;

# default to python's platforms and add maintainer(s) to every
# package
meta = {
platforms = python.meta.platforms;
} // meta // {
maintainers = (meta.maintainers or []) ++ [ lib.maintainers.chaoflow lib.maintainers.iElectric ];
};

# checkPhase after installPhase to run tests on installed packages
phases = "unpackPhase patchPhase configurePhase buildPhase installPhase checkPhase fixupPhase distPhase";

buildInputs = [ python wrapPython setuptools ] ++ buildInputs ++ pythonPath;
buildInputs = [ python wrapPython setuptools (distutils-cfg.override { extraCfg = distutilsExtraCfg; }) ] ++ buildInputs ++ pythonPath;

propagatedBuildInputs = propagatedBuildInputs ++ [ recursivePthLoader ];

pythonPath = [ setuptools ] ++ pythonPath;

preConfigure = ''
configurePhase = attrs.configurePhase or ''
runHook preConfigure

# patch python interpreter to write null timestamps when compiling python files
# with following var we tell python to activate the patch so that python doesn't
# try to update them when we freeze timestamps in nix store
export DETERMINISTIC_BUILD=1
PYTHONPATH="${offlineDistutils}/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
${preConfigure}

# prepend following line to import setuptools before distutils
# this way we make sure setuptools monkeypatches distutils commands
# this way setuptools provides extra helpers such as "python setup.py test"
sed -i '0,/import distutils/s//import setuptools;import distutils/' setup.py
sed -i '0,/from distutils/s//import setuptools;from distutils/' setup.py

runHook postConfigure
'';

installPhase = preInstall + ''
checkPhase = attrs.checkPhase or ''
runHook preCheck

${python}/bin/${python.executable} setup.py test

runHook postCheck
'';

buildPhase = attrs.buildPhase or ''
runHook preBuild

${python}/bin/${python.executable} setup.py build ${lib.concatStringsSep " " setupPyBuildFlags}

runHook postBuild
'';

installPhase = attrs.installPhase or ''
runHook preInstall

mkdir -p "$out/lib/${python.libPrefix}/site-packages"

echo "installing \`${name}' with \`easy_install'..."
export PYTHONPATH="$out/lib/${python.libPrefix}/site-packages:$PYTHONPATH"
${installCommand}

${python}/bin/${python.executable} setup.py install \
--install-lib=$out/lib/${python.libPrefix}/site-packages \
--old-and-unmanageable \
--prefix="$out" ${lib.concatStringsSep " " setupPyInstallFlags}

# --install-lib:
# sometimes packages specify where files should be installed outside the usual
# python lib prefix, we override that back so all infrastructure (setup hooks)
# work as expected

# --old-and-unmanagable:
# instruct setuptools not to use eggs but fallback to plan package install
# this also reduces one .pth file in the chain, but the main reason is to
# force install process to install only scripts for the package we are
# installing (otherwise it will install scripts also for dependencies)

# A pth file might have been generated to load the package from
# within its own site-packages, rename this package not to
Expand All @@ -94,26 +122,36 @@ python.stdenv.mkDerivation (attrs // {
# corresponding site.py needs to be included in the PYTHONPATH.
rm -f "$out/lib/${python.libPrefix}"/site-packages/site.py*

${postInstall}
runHook postInstall
'';

postFixup =
''
wrapPythonPrograms

# If a user installs a Python package, she probably also wants its
# dependencies in the user environment (since Python modules don't
# have something like an RPATH, so the only way to find the
# If a user installs a Python package, they probably also wants its
# dependencies in the user environment profile (only way to find the
# dependencies is to have them in the PYTHONPATH variable).
# Allows you to do: $ PYTHONPATH=~/.nix-profile/lib/python2.7/site-packages python
if test -e $out/nix-support/propagated-build-inputs; then
ln -s $out/nix-support/propagated-build-inputs $out/nix-support/propagated-user-env-packages
fi

# TODO: document
createBuildInputsPth build-inputs "$buildInputStrings"
for inputsfile in propagated-build-inputs propagated-native-build-inputs; do
if test -e $out/nix-support/$inputsfile; then
createBuildInputsPth $inputsfile "$(cat $out/nix-support/$inputsfile)"
fi
done
'';

meta = with lib.maintainers; {
# default to python's platforms
platforms = python.meta.platforms;
} // meta // {
# add extra maintainer(s) to every package
maintainers = (meta.maintainers or []) ++ [ chaoflow iElectric ];
};

})
21 changes: 0 additions & 21 deletions pkgs/development/python-modules/offline-distutils/default.nix

This file was deleted.

5 changes: 2 additions & 3 deletions pkgs/development/python-modules/pil/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ buildPythonPackage {

doCheck = true;

configurePhase = ''
preConfigure = ''
sed -i "setup.py" \
-e 's|^FREETYPE_ROOT =.*$|FREETYPE_ROOT = libinclude("${freetype}")|g ;
s|^JPEG_ROOT =.*$|JPEG_ROOT = libinclude("${libjpeg}")|g ;
s|^ZLIB_ROOT =.*$|ZLIB_ROOT = libinclude("${zlib}")|g ;'
'';

buildPhase = "python setup.py build_ext -i";
checkPhase = "python selftest.py";
#installPhase = "python setup.py install --prefix=$out";
buildPhase = "python setup.py build_ext -i";

meta = {
homepage = http://www.pythonware.com/products/pil/;
Expand Down
12 changes: 1 addition & 11 deletions pkgs/development/python-modules/pycrypto/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,7 @@ buildPythonPackage rec {
sha256 = "0g0ayql5b9mkjam8hym6zyg6bv77lbh66rv1fyvgqb17kfc1xkpj";
};

buildInputs = [ python gmp ];

buildPhase =
''
python ./setup.py build_ext --library-dirs=${gmp}/lib
'';

# installPhase =
# ''
# python ./setup.py install --prefix=$out
# '';
buildInputs = [ gmp ];

meta = {
homepage = "http://www.pycrypto.org/";
Expand Down
7 changes: 6 additions & 1 deletion pkgs/development/python-modules/pygtk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@ buildPythonPackage rec {

propagatedBuildInputs = [ gtk pygobject pycairo ];

installCommand = "make install";
configurePhase = "configurePhase";

buildPhase = "buildPhase";

installPhase = "installPhase";

checkPhase = stdenv.lib.optionalString (libglade == null)
''
sed -i -e "s/glade = importModule('gtk.glade', buildDir)//" \
Expand Down
10 changes: 5 additions & 5 deletions pkgs/development/python-modules/setuptools/default.nix
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
{ stdenv, fetchurl, python, wrapPython }:
{ stdenv, fetchurl, python, wrapPython, distutils-cfg }:

stdenv.mkDerivation rec {
shortName = "setuptools-${version}";
name = "${python.executable}-${shortName}";

version = "2.0.2";
version = "2.1";

src = fetchurl {
url = "http://pypi.python.org/packages/source/s/setuptools/${shortName}.tar.gz";
sha256 = "09nv5x45y8fgc0kjmmw4gig3hr0is9xlc5rq053vnbmkxr5q5xmi";
sha256 = "1m8qjvj5bfbphdags5s6pgmvk3xnw509lgdlq9whkq5a9mgxf8m7";
};

buildInputs = [ python wrapPython ];
buildInputs = [ python wrapPython distutils-cfg ];

buildPhase = "${python}/bin/${python.executable} setup.py build --build-base $out";
buildPhase = "${python}/bin/${python.executable} setup.py build";

installPhase =
''
Expand Down
Loading