Last active
July 24, 2017 20:12
-
-
Save datakurre/016dea359943a4598190 to your computer and use it in GitHub Desktop.
Python package development shell example in Nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from latex import build_pdf | |
min_latex = (r"\documentclass{article}" | |
r"\begin{document}" | |
r"Hello, world!" | |
r"\end{document}") | |
# this builds a pdf-file inside a temporary directory | |
pdf = build_pdf(min_latex) | |
# look at the first few bytes of the header | |
print bytes(pdf)[:10] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usage: nix-shell buildout.nix --run buildout-nix | |
[buildout] | |
parts = app | |
develop = . | |
[app] | |
recipe = collective.recipe.nix | |
eggs = app | |
build-inputs = texLive | |
outputs = app.nix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
stdenv.mkDerivation { | |
name = "buildout"; | |
buildInputs = [ | |
pythonPackages.zc_buildout_nix | |
]; | |
shellHook = '' | |
export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt | |
''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with import <nixpkgs> {}; | |
let dependencies = rec { | |
_latex = buildPythonPackage { | |
name = "latex-0.6.1"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/l/latex/latex-0.6.1.tar.gz"; | |
md5 = "aeab224095be52107b7b32f08a980c5a"; | |
}; | |
propagatedBuildInputs = [ | |
_tempdir | |
_data | |
_future | |
_shutilwhich | |
]; | |
doCheck = false; | |
}; | |
_shutilwhich = buildPythonPackage { | |
name = "shutilwhich-1.1.0"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/s/shutilwhich/shutilwhich-1.1.0.tar.gz"; | |
md5 = "915947c5cdae7afd748ac715ee547adb"; | |
}; | |
doCheck = false; | |
}; | |
_future = buildPythonPackage { | |
name = "future-0.15.2"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/f/future/future-0.15.2.tar.gz"; | |
md5 = "a68eb3c90b3b76714c5ceb8c09ea3a06"; | |
}; | |
doCheck = false; | |
}; | |
_data = buildPythonPackage { | |
name = "data-0.4"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/d/data/data-0.4.tar.gz"; | |
md5 = "e8b34bc3806cae346a7c54aad77b4fef"; | |
}; | |
propagatedBuildInputs = [ | |
_six | |
_decorator | |
_funcsigs | |
]; | |
doCheck = false; | |
}; | |
_tempdir = buildPythonPackage { | |
name = "tempdir-0.6"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/t/tempdir/tempdir-0.6.tar.gz"; | |
md5 = "93890c11a7101ae55eebf77b86c75a05"; | |
}; | |
doCheck = false; | |
}; | |
_funcsigs = buildPythonPackage { | |
name = "funcsigs-0.4"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/f/funcsigs/funcsigs-0.4.tar.gz"; | |
md5 = "fb1d031f284233e09701f6db1281c2a5"; | |
}; | |
doCheck = false; | |
}; | |
_decorator = buildPythonPackage { | |
name = "decorator-4.0.4"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/d/decorator/decorator-4.0.4.tar.gz"; | |
md5 = "dd3a0669e1e6f09699eefa2c7fbd9756"; | |
}; | |
doCheck = false; | |
}; | |
_six = buildPythonPackage { | |
name = "six-1.9.0"; | |
src = fetchurl { | |
url = "https://pypi.python.org/packages/source/s/six/six-1.9.0.tar.gz"; | |
md5 = "476881ef4012262dfc8adc645ee786c4"; | |
}; | |
doCheck = false; | |
}; | |
}; | |
in with dependencies; | |
stdenv.mkDerivation { | |
name = "env"; | |
buildInputs = [ | |
(python.buildEnv.override { | |
extraLibs = [ _latex ]; | |
}) | |
(texlive.combine { | |
inherit (texlive) scheme-basic; | |
}) | |
]; | |
shellHook = '' | |
export PYTHONPATH=`pwd`; | |
''; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup | |
setup(name='app', version='1.0.0', py_modules=['app'], install_requires=['latex']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment