diff --git a/pkgs/development/python-modules/dramatiq/default.nix b/pkgs/development/python-modules/dramatiq/default.nix new file mode 100644 index 000000000000..8b7300d786f5 --- /dev/null +++ b/pkgs/development/python-modules/dramatiq/default.nix @@ -0,0 +1,106 @@ +{ lib +, stdenv +, buildPythonPackage +, pythonOlder +, fetchFromGitHub +, gevent +, pika +, prometheus-client +, pylibmc +, pytestCheckHook +, redis +, watchdog +, watchdog-gevent +}: + +buildPythonPackage rec { + pname = "dramatiq"; + version = "1.14.2"; + format = "setuptools"; + + disabled = pythonOlder "3.7"; + + src = fetchFromGitHub { + owner = "Bogdanp"; + repo = "dramatiq"; + rev = "v${version}"; + hash = "sha256-yv6HUJI7wsAQdBJ5QNv7qXhtzPvCsrF1389kyemAV7Y="; + }; + + propagatedBuildInputs = [ + prometheus-client + ]; + + passthru.optional-dependencies = { + all = [ + gevent + pika + pylibmc + redis + watchdog + watchdog-gevent + ]; + gevent = [ + gevent + ]; + memcached = [ + pylibmc + ]; + rabbitmq = [ + pika + ]; + redis = [ + redis + ]; + watch = [ + watchdog + watchdog-gevent + ]; + }; + + nativeCheckInputs = [ pytestCheckHook pika redis pylibmc ]; + + postPatch = '' + sed -i ./setup.cfg \ + -e 's:--cov dramatiq::' \ + -e 's:--cov-report html::' \ + -e 's:--benchmark-autosave::' \ + -e 's:--benchmark-compare::' \ + ''; + + disabledTests = [ + # Requires a running redis + "test_after_process_boot_call_has_no_blocked_signals" + "test_cli_can_be_reloaded_on_sighup" + "test_cli_can_watch_for_source_code_changes" + "test_cli_fork_functions_have_no_blocked_signals" + "test_consumer_threads_have_no_blocked_signals" + "test_middleware_fork_functions_have_no_blocked_signals" + "test_redis_broker_can_connect_via_client" + "test_redis_broker_can_connect_via_url" + "test_redis_process_100k_messages_with_cli" + "test_redis_process_10k_fib_with_cli" + "test_redis_process_1k_latency_with_cli" + "test_worker_threads_have_no_blocked_signals" + # Requires a running rabbitmq + "test_rabbitmq_broker_can_be_passed_a_list_of_parameters_for_failover" + "test_rabbitmq_broker_can_be_passed_a_list_of_uri_for_failover" + "test_rabbitmq_broker_can_be_passed_a_semicolon_separated_list_of_uris" + "test_rabbitmq_broker_connections_are_lazy" + "test_rabbitmq_process_100k_messages_with_cli" + "test_rabbitmq_process_10k_fib_with_cli" + "test_rabbitmq_process_1k_latency_with_cli" + ] ++ lib.optionals stdenv.isDarwin [ + # Takes too long for darwin ofborg + "test_retry_exceptions_can_specify_a_delay" + ]; + + pythonImportsCheck = [ "dramatiq" ]; + + meta = with lib; { + description = "Background Processing for Python 3"; + homepage = "https://github.com/Bogdanp/dramatiq"; + license = licenses.gpl3Only; + maintainers = with maintainers; [ traxys ]; + }; +} diff --git a/pkgs/development/python-modules/flask-dramatiq/default.nix b/pkgs/development/python-modules/flask-dramatiq/default.nix new file mode 100644 index 000000000000..6f8884516f49 --- /dev/null +++ b/pkgs/development/python-modules/flask-dramatiq/default.nix @@ -0,0 +1,85 @@ +{ lib +, buildPythonPackage +, pythonOlder +, fetchFromGitLab +, poetry-core +, dramatiq +, flask +, requests +, pytestCheckHook +, flask-migrate +, periodiq +, postgresql +, postgresqlTestHook +, psycopg2 +}: + +buildPythonPackage { + pname = "flask-dramatiq"; + version = "0.6.0"; + format = "pyproject"; + + disabled = pythonOlder "3.6"; + + src = fetchFromGitLab { + owner = "bersace"; + repo = "flask-dramatiq"; + rev = "840209e9bf582b4dda468e8bba515f248f3f8534"; + hash = "sha256-qjV1zyVzHPXMt+oUeGBdP9XVlbcSz2MF9Zygj543T4w="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace 'poetry>=0.12' 'poetry-core' \ + --replace 'poetry.masonry.api' 'poetry.core.masonry.api' + + patchShebangs --build ./example.py + + sed -i ./tests/unit/pytest.ini \ + -e 's:--cov=flask_dramatiq::' \ + -e 's:--cov-report=term-missing::' + ''; + + nativeBuildInputs = [ + poetry-core + ]; + + propagatedBuildInputs = [ + dramatiq + ]; + + nativeCheckInputs = [ + pytestCheckHook + flask + requests + flask-migrate + periodiq + postgresql + postgresqlTestHook + psycopg2 + ] ++ dramatiq.optional-dependencies.rabbitmq; + + postgresqlTestSetupPost = '' + substituteInPlace config.py \ + --replace 'SQLALCHEMY_DATABASE_URI = f"postgresql://{PGUSER}:{PGPASSWORD}@{PGHOST}/{PGDATABASE}"' \ + "SQLALCHEMY_DATABASE_URI = \"postgresql://$PGUSER/$PGDATABASE?host=$PGHOST\"" + python3 ./example.py db upgrade + ''; + + pytestFlagsArray = [ "-x" "tests/func/" "tests/unit"]; + + pythonImportsCheck = [ "flask_dramatiq" ]; + + # Does HTTP requests to localhost + disabledTests = [ + "test_fast" + "test_other" + ]; + + meta = with lib; { + description = "Adds Dramatiq support to your Flask application"; + homepage = "https://gitlab.com/bersace/flask-dramatiq"; + license = licenses.bsd3; + maintainers = with maintainers; [ traxys ]; + }; +} diff --git a/pkgs/development/python-modules/periodiq/default.nix b/pkgs/development/python-modules/periodiq/default.nix new file mode 100644 index 000000000000..5ed6a028aa38 --- /dev/null +++ b/pkgs/development/python-modules/periodiq/default.nix @@ -0,0 +1,55 @@ +{ lib +, buildPythonPackage +, pythonOlder +, fetchFromGitLab +, poetry-core +, dramatiq +, pendulum +, setuptools +, pytest-mock +, pytestCheckHook +}: + +buildPythonPackage rec { + pname = "periodiq"; + version = "0.12.1"; + format = "pyproject"; + + disabled = pythonOlder "3.5"; + + src = fetchFromGitLab { + owner = "bersace"; + repo = "periodiq"; + rev = "v${version}"; + hash = "sha256-Ar0n+Wi1OUtRdhVxrU7Nz4je8ylaHgPZbXE0a30hzU0="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace 'poetry>=0.12' 'poetry-core' \ + --replace 'poetry.masonry.api' 'poetry.core.masonry.api' + ''; + + nativeBuildInputs = [ + poetry-core + ]; + + propagatedBuildInputs = [ + dramatiq + pendulum + setuptools + ]; + + nativeCheckInputs = [ pytestCheckHook pytest-mock ]; + + pytestFlagsArray = [ "tests/unit" ]; + + pythonImportsCheck = [ "periodiq" ]; + + meta = with lib; { + description = "Simple Scheduler for Dramatiq Task Queue"; + homepage = "https://pypi.org/project/periodiq/"; + license = licenses.lgpl3Only; + maintainers = with maintainers; [ traxys ]; + }; +} diff --git a/pkgs/development/python-modules/staticmap/default.nix b/pkgs/development/python-modules/staticmap/default.nix new file mode 100644 index 000000000000..bb3eac8655bd --- /dev/null +++ b/pkgs/development/python-modules/staticmap/default.nix @@ -0,0 +1,31 @@ +{ lib +, buildPythonPackage +, fetchPypi +, pillow +, requests +}: + +buildPythonPackage rec { + pname = "staticmap"; + version = "0.5.7"; + format = "setuptools"; + + src = fetchPypi { + inherit pname version; + hash = "sha256-x6lrkCumEpLoGMILCBBhnWuBps21C8wauS1QrE2yCn8="; + }; + + propagatedBuildInputs = [ requests pillow ]; + + pythonImportsCheck = [ "staticmap" ]; + + # Tests seem to be broken + doCheck = false; + + meta = with lib; { + description = "A small, python-based library for creating map images with lines and markers"; + homepage = "https://pypi.org/project/staticmap/"; + license = with licenses; [ asl20 ]; + maintainers = with maintainers; [ traxys ]; + }; +} diff --git a/pkgs/development/python-modules/watchdog-gevent/default.nix b/pkgs/development/python-modules/watchdog-gevent/default.nix new file mode 100644 index 000000000000..e1b812b9612f --- /dev/null +++ b/pkgs/development/python-modules/watchdog-gevent/default.nix @@ -0,0 +1,40 @@ +{ lib +, buildPythonPackage +, fetchFromGitHub +, gevent +, pytestCheckHook +, watchdog +}: + +buildPythonPackage rec { + pname = "watchdog-gevent"; + version = "0.1.1"; + format = "setuptools"; + + # Need to fetch from github because tests are not present in pypi + src = fetchFromGitHub { + owner = "Bogdanp"; + repo = "watchdog_gevent"; + rev = "v${version}"; + hash = "sha256-FESm3fNuLmOg2ilI/x8U9LuAimHLnahcTHYzW/nzOVY="; + }; + + propagatedBuildInputs = [ watchdog gevent ]; + + postPatch = '' + sed -i setup.cfg \ + -e 's:--cov watchdog_gevent::' \ + -e 's:--cov-report html::' + ''; + + nativeCheckInputs = [ pytestCheckHook ]; + + pythonImportsCheck = [ "watchdog_gevent" ]; + + meta = with lib; { + description = "A gevent-based observer for watchdog"; + homepage = "https://github.com/Bogdanp/watchdog_gevent"; + license = licenses.asl20; + maintainers = with maintainers; [ traxys ]; + }; +} diff --git a/pkgs/servers/geospatial/fit-trackee/default.nix b/pkgs/servers/geospatial/fit-trackee/default.nix new file mode 100644 index 000000000000..c7bc7fbc2e5b --- /dev/null +++ b/pkgs/servers/geospatial/fit-trackee/default.nix @@ -0,0 +1,105 @@ +{ lib +, python3 +, fetchFromGitHub +, fetchPypi +, postgresql +, postgresqlTestHook +}: +let + python = python3.override { + packageOverrides = self: super: { + sqlalchemy = super.sqlalchemy.overridePythonAttrs (oldAttrs: rec { + version = "1.4.49"; + src = fetchPypi { + pname = "SQLAlchemy"; + inherit version; + hash = "sha256-Bv8ly64ww5bEt3N0ZPKn/Deme32kCZk7GCsCTOyArtk="; + }; + # Remove "test/typing" that does not exist + disabledTestPaths = [ + "test/aaa_profiling" + "test/ext/mypy" + ]; + }); + }; + }; + +in +python.pkgs.buildPythonApplication rec { + pname = "fit-trackee"; + version = "0.7.22"; + format = "pyproject"; + + src = fetchFromGitHub { + owner = "SamR1"; + repo = "FitTrackee"; + rev = "v${version}"; + hash = "sha256-aPQ8jLssN9nx0Bpd/44E3sQi2w0cR8ecG76DJjreeHA="; + }; + + postPatch = '' + substituteInPlace pyproject.toml \ + --replace psycopg2-binary psycopg2 \ + --replace 'poetry>=0.12' 'poetry-core' \ + --replace 'poetry.masonry.api' 'poetry.core.masonry.api' + ''; + + nativeBuildInputs = [ + python3.pkgs.poetry-core + ]; + + propagatedBuildInputs = with python.pkgs; [ + authlib + babel + dramatiq + flask + flask-bcrypt + flask-dramatiq + flask-limiter + flask-migrate + gpxpy + gunicorn + humanize + psycopg2 + pyjwt + pyopenssl + pytz + shortuuid + sqlalchemy + staticmap + ua-parser + ] ++ dramatiq.optional-dependencies.redis; + + pythonImportsCheck = [ "fittrackee" ]; + + nativeCheckInputs = with python.pkgs; [ + pytestCheckHook + freezegun + postgresqlTestHook + postgresql + ]; + + pytestFlagsArray = [ + "fittrackee" + ]; + + postgresqlTestSetupPost = '' + export DATABASE_TEST_URL=postgresql://$PGUSER/$PGDATABAS?host=$PGHOST + ''; + + postInstall = '' + mkdir -p $out/var/share/fittrackee-instance + ''; + + preCheck = '' + export TMP=$(mktemp -d) + ''; + + meta = with lib; { + description = "Self-hosted outdoor activity tracker :bicyclist"; + homepage = "https://github.com/SamR1/FitTrackee"; + changelog = "https://github.com/SamR1/FitTrackee/blob/${src.rev}/CHANGELOG.md"; + license = licenses.agpl3Only; + maintainers = with maintainers; [ traxys ]; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index eb0f75732755..a1fc94e3390c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -27557,6 +27557,8 @@ with pkgs; ### SERVERS / GEOSPATIAL + fit-trackee = callPackage ../servers/geospatial/fit-trackee { }; + geoserver = callPackage ../servers/geospatial/geoserver { }; mapcache = callPackage ../servers/geospatial/mapcache { }; diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 0dd42931c495..4c95ccdb3a5b 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -3267,6 +3267,8 @@ self: super: with self; { dragonfly = callPackage ../development/python-modules/dragonfly { }; + dramatiq = callPackage ../development/python-modules/dramatiq { }; + drawille = callPackage ../development/python-modules/drawille { }; drawilleplot = callPackage ../development/python-modules/drawilleplot { }; @@ -3964,6 +3966,8 @@ self: super: with self; { flask-cors = callPackage ../development/python-modules/flask-cors { }; + flask-dramatiq = callPackage ../development/python-modules/flask-dramatiq { }; + flask-elastic = callPackage ../development/python-modules/flask-elastic { }; flask-expects-json = callPackage ../development/python-modules/flask-expects-json { }; @@ -8846,6 +8850,8 @@ self: super: with self; { periodictable = callPackage ../development/python-modules/periodictable { }; + periodiq = callPackage ../development/python-modules/periodiq { }; + permissionedforms = callPackage ../development/python-modules/permissionedforms { }; persim = callPackage ../development/python-modules/persim { }; @@ -13342,6 +13348,8 @@ self: super: with self; { static3 = callPackage ../development/python-modules/static3 { }; + staticmap = callPackage ../development/python-modules/staticmap { }; + staticjinja = callPackage ../development/python-modules/staticjinja { }; statistics = callPackage ../development/python-modules/statistics { }; @@ -15421,6 +15429,8 @@ self: super: with self; { inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices; }; + watchdog-gevent = callPackage ../development/python-modules/watchdog-gevent { }; + watchfiles = callPackage ../development/python-modules/watchfiles { inherit (pkgs.darwin.apple_sdk.frameworks) CoreServices; };