From ac783e5803ab562c1b7ce17b1b4ab6b5af95006d Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Fri, 20 May 2022 00:33:58 -0700 Subject: [PATCH] Build stuff --- .gitignore | 1 + default.nix | 13 +++++++++++++ setup.py | 8 ++++++++ test.sh | 23 +++++++++++++++++++++++ 4 files changed, 45 insertions(+) create mode 100644 .gitignore create mode 100644 default.nix create mode 100644 setup.py create mode 100755 test.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b2be92b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +result diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..7be4d9c --- /dev/null +++ b/default.nix @@ -0,0 +1,13 @@ +{ pkgs ? import { }, lint ? false }: +pkgs.python3Packages.callPackage +({ lib, buildPythonPackage, autopep8, mypy, pylint, }: + buildPythonPackage rec { + pname = "nix-pin-deps"; + version = "1.0.0"; + src = lib.cleanSource ./.; + checkInputs = [ mypy ] ++ lib.optionals lint [ autopep8 pylint ]; + doCheck = true; + checkPhase = '' + ./test.sh ${lib.optionalString lint "lint"} + ''; + }) { } diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..e581026 --- /dev/null +++ b/setup.py @@ -0,0 +1,8 @@ +from setuptools import setup + +setup( + name='nix-pin-deps', + version='1.0.0', + py_modules=['nix_pin_deps'], + entry_points={'console_scripts': ['nix-pin-deps = nix_pin_deps:main']}, +) diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..146f901 --- /dev/null +++ b/test.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +set -e + +find . -name build -prune -o -name dist -prune -o -name '*.py' -print0 | + xargs -0 mypy --strict --ignore-missing-imports --no-warn-unused-ignores + +if [ "$1" = lint ];then + + pylint --reports=n --persistent=n --ignore-imports=y \ + -d fixme,invalid-name,missing-docstring,subprocess-run-check,too-few-public-methods *.py + + formatting_needs_fixing=$( + find . -name '*.py' -print0 | + xargs -0 -n1 autopep8 --diff -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa + ) + if [[ "$formatting_needs_fixing" ]];then + echo "Formatting needs fixing:" + echo "$formatting_needs_fixing" + exit 1 + fi + +fi -- 2.44.1