commit c5222e16866659e8eb4085dee6605c0da37cf50f Author: Piotr Dobrowolski Date: Sat Aug 22 15:03:28 2020 +0200 first commit diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..9fed089 --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +{ nixpkgs ? import { +} }: + +let + inherit (nixpkgs) pkgs; +in + +pkgs.stdenv.mkDerivation { + name = "example-project"; + buildInputs = with pkgs; [ + (python3.withPackages (ppkgs: with ppkgs; [ (callPackage ./nix/kivy/default.nix {}) ])) + ]; +} diff --git a/nix/kivy/bork.nix b/nix/kivy/bork.nix new file mode 100644 index 0000000..74d6bfa --- /dev/null +++ b/nix/kivy/bork.nix @@ -0,0 +1,101 @@ +{ stdenv, buildPythonPackage, fetchPypi, maintainers, platforms, licenses, pkgs }: + +# From the 1.10.0 documentation: +# "This version of Kivy requires at least Cython version 0.23, and has been +# tested through 0.25.2. Later versions may work, but as they have not been +# tested there is no guarantee." + +assert stdenv.lib.versionAtLeast pkgs.cython.version "0.23"; + +# Rather than depending on a specific older version of Cython, we accept the +# off-chance of breakage: +# assert stdenv.lib.versionOlder self.cython.version "0.25.3"; + +buildPythonPackage rec { + pname = "Kivy"; + version = "1.10.0"; + name = "${pname}-${version}"; + + src = fetchPypi { + inherit pname version; + sha256 = "1394zh6kvf7k5d8vlzxcsfcailr3q59xwg9b1n7qaf25bvyq1h98"; + }; + + # setup.py invokes git on build but we're fetching a tarball, so + # can't retrieve git version. We remove the git-invocation from setup.py + # This patch can presumably be removed on the next version of Kivy, because the problem + # was addressed in https://github.com/kivy/kivy/issues/5365 + patches = [ + ./setup.py.patch + ]; + + buildInputs = with pkgs; [ + pkgconfig + cython + + #kivygarden # See https://github.com/kivy/kivy/issues/5367 suggestion I-2 + requests # See https://github.com/kivy/kivy/issues/5367 suggestion I-3 + docutils # See https://github.com/kivy/kivy/issues/5367 question Q-5 + pygments # See https://github.com/kivy/kivy/issues/5367 question Q-6 + + # nose # needed for tests (which are currently disabled) + + # The setup below is, as much as I can figure out how to make it, an attempt + # to create a "canonical full install" of Kivy on linux, as allued to in + # https://github.com/kivy/kivy/issues/5367 question Q-7 + + # Some sources to reconstruct such a thing are: + # .travis.yml (which contains the actual build instructions for CI) + # https://kivy.org/docs/installation/installation.html + # https://kivy.org/docs/installation/installation-linux.html + + pkgs.mesa + pkgs.mtdev + + pkgs.SDL2 + pkgs.SDL2_image + pkgs.SDL2_ttf + pkgs.SDL2_mixer + + # NOTE: The degree to which gstreamer actually works is unclear + pkgs.gst_all_1.gstreamer + pkgs.gst_all_1.gst-plugins-base + pkgs.gst_all_1.gst-plugins-good + pkgs.gst_all_1.gst-plugins-bad + + # Not done yet: + # "Camera is also unclear in the cross-platform sense, though for a + # canonical linux configuration the answer is probably opencv. SDL2 for + # image provider qualifies as "canonical", though it is my impression that + # ffpyplayer has wider and better format support." + ]; + + propagatedBuildInputs = with pkgs; [ + pillow + ] ; + + # We're not currently running tests, because there are 38 errors and 1 failure + # This number may be reduced somewhat once https://github.com/kivy/kivy/issues/5373 is fixed + + # KIVY_NO_CONFIG is needed, because otherwise tests attempt to write to the non-existing $HOME + # checkPhase = '' + # export KIVY_NO_CONFIG=1 + # nosetests + # ''; + + doCheck = false; + + postPatch = '' + substituteInPlace kivy/lib/mtdev.py \ + --replace "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${pkgs.mtdev}/lib/libmtdev.so.1')" + ''; + + meta = { + description = "A software library for rapid development of hardware-accelerated multitouch applications."; + homepage = "https://pypi.python.org/pypi/kivy"; + license = licenses.mit; + maintainers = with maintainers; [ vanschelven ]; + platforms = platforms.unix; # I can only test linux; in principle other platforms are supported + }; + +} diff --git a/nix/kivy/default.nix b/nix/kivy/default.nix new file mode 100644 index 0000000..b5e52f6 --- /dev/null +++ b/nix/kivy/default.nix @@ -0,0 +1,100 @@ +{ stdenv, buildPythonPackage, fetchPypi, pkgs, self }: + +# From the 1.10.0 documentation: +# "This version of Kivy requires at least Cython version 0.23, and has been +# tested through 0.25.2. Later versions may work, but as they have not been +# tested there is no guarantee." + +assert stdenv.lib.versionAtLeast self.cython.version "0.23"; + +# Rather than depending on a specific older version of Cython, we accept the +# off-chance of breakage: +# assert stdenv.lib.versionOlder self.cython.version "0.25.3"; + +buildPythonPackage rec { + pname = "Kivy"; + version = "1.10.0"; + name = "${pname}-${version}"; + + src = fetchPypi { + inherit pname version; + sha256 = "1394zh6kvf7k5d8vlzxcsfcailr3q59xwg9b1n7qaf25bvyq1h98"; + }; + + # setup.py invokes git on build but we're fetching a tarball, so + # can't retrieve git version. We remove the git-invocation from setup.py + # This patch can presumably be removed on the next version of Kivy, because the problem + # was addressed in https://github.com/kivy/kivy/issues/5365 + patches = [ + ./setup.py.patch + ]; + + buildInputs = with self; [ + pkgconfig + cython + + kivygarden # See https://github.com/kivy/kivy/issues/5367 suggestion I-2 + requests # See https://github.com/kivy/kivy/issues/5367 suggestion I-3 + docutils # See https://github.com/kivy/kivy/issues/5367 question Q-5 + pygments # See https://github.com/kivy/kivy/issues/5367 question Q-6 + + # nose # needed for tests (which are currently disabled) + + # The setup below is, as much as I can figure out how to make it, an attempt + # to create a "canonical full install" of Kivy on linux, as allued to in + # https://github.com/kivy/kivy/issues/5367 question Q-7 + + # Some sources to reconstruct such a thing are: + # .travis.yml (which contains the actual build instructions for CI) + # https://kivy.org/docs/installation/installation.html + # https://kivy.org/docs/installation/installation-linux.html + + pkgs.mesa + pkgs.mtdev + + pkgs.SDL2 + pkgs.SDL2_image + pkgs.SDL2_ttf + pkgs.SDL2_mixer + + # NOTE: The degree to which gstreamer actually works is unclear + pkgs.gst_all_1.gstreamer + pkgs.gst_all_1.gst-plugins-base + pkgs.gst_all_1.gst-plugins-good + pkgs.gst_all_1.gst-plugins-bad + + # Not done yet: + # "Camera is also unclear in the cross-platform sense, though for a + # canonical linux configuration the answer is probably opencv. SDL2 for + # image provider qualifies as "canonical", though it is my impression that + # ffpyplayer has wider and better format support." + ]; + + propagatedBuildInputs = with self; [ + pillow + ] ; + + # We're not currently running tests, because there are 38 errors and 1 failure + # This number may be reduced somewhat once https://github.com/kivy/kivy/issues/5373 is fixed + + # KIVY_NO_CONFIG is needed, because otherwise tests attempt to write to the non-existing $HOME + # checkPhase = '' + # export KIVY_NO_CONFIG=1 + # nosetests + # ''; + + doCheck = false; + + postPatch = '' + substituteInPlace kivy/lib/mtdev.py \ + --replace "LoadLibrary('libmtdev.so.1')" "LoadLibrary('${pkgs.mtdev}/lib/libmtdev.so.1')" + ''; + + meta = with stdenv.lib; { + description = "A software library for rapid development of hardware-accelerated multitouch applications."; + homepage = "https://pypi.python.org/pypi/kivy"; + license = licenses.mit; + maintainers = with maintainers; [ vanschelven ]; + platforms = platforms.unix; # I can only test linux; in principle other platforms are supported + }; +} diff --git a/nix/kivy/setup.py.patch b/nix/kivy/setup.py.patch new file mode 100644 index 0000000..2e3aa71 --- /dev/null +++ b/nix/kivy/setup.py.patch @@ -0,0 +1,16 @@ +--- Kivy-1.10.0/setup.py 2017-05-07 17:24:57.000000000 +0200 ++++ setup.py 2017-09-04 14:27:13.222721223 +0200 +@@ -42,12 +42,7 @@ + def get_version(filename='kivy/version.py'): + VERSION = kivy.__version__ + DATE = datetime.utcnow().strftime('%Y%m%d') +- try: +- GIT_REVISION = check_output( +- ['git', 'rev-parse', 'HEAD'] +- ).strip().decode('ascii') +- except CalledProcessError: +- GIT_REVISION = "Unknown" ++ GIT_REVISION = "Unknown" + + cnt = ( + "# THIS FILE IS GENERATED FROM KIVY SETUP.PY\n"