From 7db42ab3a3e062b173668cc961b7e6de048bfe08 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Tue, 26 Sep 2023 21:17:35 +0200 Subject: [PATCH 1/5] Remove poetry2nix --- .envrc | 8 +-- .github/workflows/tests.yml | 2 + dev.sh | 13 +++-- flake.lock | 79 +------------------------- flake.nix | 109 +++++++++++++----------------------- 5 files changed, 53 insertions(+), 158 deletions(-) diff --git a/.envrc b/.envrc index 826e7ca..708b96e 100644 --- a/.envrc +++ b/.envrc @@ -20,6 +20,7 @@ layout_poetry() { if [[ -d ".venv" ]]; then VIRTUAL_ENV="$(pwd)/.venv" + poetry install else VIRTUAL_ENV=$( poetry env info --path 2>/dev/null @@ -38,11 +39,10 @@ layout_poetry() { export VIRTUAL_ENV } -if ! has nix; then - layout poetry -fi - +layout poetry export PROJECT_DIR=$(pwd) export WEBPORT=$(($RANDOM + 1100)) export PGPORT=$(($WEBPORT + 100)) watch_file "$PGDATA/postgresql.conf" +watch_file ./dev.sh +watch_file ./pyproject.toml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index a30f5b2..4d6373f 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,6 +13,8 @@ jobs: - uses: actions/checkout@v3 - uses: cachix/install-nix-action@v22 - uses: DeterminateSystems/magic-nix-cache-action@main + - name: Environment setup + run: nix develop --command bash -c "poetry install" - name: Test run: nix develop --command bash -c "dev test" env: diff --git a/dev.sh b/dev.sh index 9e12973..bfd078d 100755 --- a/dev.sh +++ b/dev.sh @@ -89,7 +89,7 @@ descriptions["venv"]="Build a pseudo venv that editors like VS Code can use." tasks["venv"]=venv build-container() { - nix build && docker load Date: Tue, 26 Sep 2023 21:21:17 +0200 Subject: [PATCH 2/5] Update depencies --- poetry.lock | 97 ++++++++++------------------------------------------- 1 file changed, 18 insertions(+), 79 deletions(-) diff --git a/poetry.lock b/poetry.lock index ae94ed9..92d103b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,10 +1,9 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.5.1 and should not be changed by hand. [[package]] name = "asgiref" version = "3.7.2" description = "ASGI specs, helper code, and adapters" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -20,14 +19,13 @@ tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] [[package]] name = "astroid" -version = "2.15.6" +version = "2.15.8" description = "An abstract syntax tree for Python with inference support." -category = "dev" optional = false python-versions = ">=3.7.2" files = [ - {file = "astroid-2.15.6-py3-none-any.whl", hash = "sha256:389656ca57b6108f939cf5d2f9a2a825a3be50ba9d589670f393236e0a03b91c"}, - {file = "astroid-2.15.6.tar.gz", hash = "sha256:903f024859b7c7687d7a7f3a3f73b17301f8e42dfd9cc9df9d4418172d3e2dbd"}, + {file = "astroid-2.15.8-py3-none-any.whl", hash = "sha256:1aa149fc5c6589e3d0ece885b4491acd80af4f087baafa3fb5203b113e68cd3c"}, + {file = "astroid-2.15.8.tar.gz", hash = "sha256:6c107453dffee9055899705de3c9ead36e74119cee151e5a9aaf7f0b0e020a6a"}, ] [package.dependencies] @@ -42,7 +40,6 @@ wrapt = [ name = "black" version = "22.12.0" description = "The uncompromising code formatter." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -78,7 +75,6 @@ uvloop = ["uvloop (>=0.15.2)"] name = "click" version = "8.1.7" description = "Composable command line interface toolkit" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -93,7 +89,6 @@ colorama = {version = "*", markers = "platform_system == \"Windows\""} name = "colorama" version = "0.4.6" description = "Cross-platform colored terminal text." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*,>=2.7" files = [ @@ -105,7 +100,6 @@ files = [ name = "coverage" version = "7.3.1" description = "Code coverage measurement for Python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -173,7 +167,6 @@ toml = ["tomli"] name = "dill" version = "0.3.7" description = "serialize all of Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -188,7 +181,6 @@ graph = ["objgraph (>=1.7.2)"] name = "django" version = "4.2.5" description = "A high-level Python web framework that encourages rapid development and clean, pragmatic design." -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -209,7 +201,6 @@ bcrypt = ["bcrypt"] name = "django-crispy-forms" version = "1.14.0" description = "Best way to have Django DRY forms" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -221,7 +212,6 @@ files = [ name = "django-filter" version = "23.3" description = "Django-filter is a reusable Django application for allowing users to filter querysets dynamically." -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -236,7 +226,6 @@ Django = ">=3.2" name = "django-floppyforms" version = "1.9.0" description = "Full control of form rendering in the templates" -category = "main" optional = false python-versions = "*" files = [ @@ -248,7 +237,6 @@ files = [ name = "django-guardian" version = "2.4.0" description = "Implementation of per object permissions for Django." -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -263,7 +251,6 @@ Django = ">=2.2" name = "django-htmx" version = "1.16.0" description = "Extensions for using Django with htmx." -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -278,7 +265,6 @@ Django = ">=3.2" name = "django-model-utils" version = "4.3.1" description = "Django model mixins and utilities" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -293,7 +279,6 @@ Django = ">=3.2" name = "django-nested-admin" version = "4.0.2" description = "Django admin classes that allow for nested inlines" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -312,7 +297,6 @@ test = ["Pillow", "dj-database-url", "django-selenosis", "pytest", "pytest-cov", name = "django-stubs" version = "4.2.4" description = "Mypy stubs for Django" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -330,13 +314,12 @@ types-PyYAML = "*" typing-extensions = "*" [package.extras] -compatible-mypy = ["mypy (>=1.5.0,<1.6.0)"] +compatible-mypy = ["mypy (==1.5.*)"] [[package]] name = "django-stubs-ext" version = "4.2.2" description = "Monkey-patching and extensions for django-stubs" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -352,7 +335,6 @@ typing-extensions = "*" name = "django-tables2" version = "2.5.3" description = "Table/data-grid framework for Django" -category = "main" optional = false python-versions = "*" files = [ @@ -370,7 +352,6 @@ tablib = ["tablib"] name = "docstring-to-markdown" version = "0.12" description = "On the fly conversion of Python docstrings to markdown" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -382,7 +363,6 @@ files = [ name = "exceptiongroup" version = "1.1.3" description = "Backport of PEP 654 (exception groups)" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -397,7 +377,6 @@ test = ["pytest (>=6)"] name = "execnet" version = "2.0.2" description = "execnet: rapid multi-Python deployment" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -412,7 +391,6 @@ testing = ["hatch", "pre-commit", "pytest", "tox"] name = "faker" version = "12.0.1" description = "Faker is a Python package that generates fake data for you." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -427,7 +405,6 @@ python-dateutil = ">=2.4" name = "gunicorn" version = "21.2.0" description = "WSGI HTTP Server for UNIX" -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -448,7 +425,6 @@ tornado = ["tornado (>=0.2)"] name = "importlib-metadata" version = "6.8.0" description = "Read metadata from Python packages" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -468,7 +444,6 @@ testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs name = "iniconfig" version = "2.0.0" description = "brain-dead simple config-ini parsing" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -480,7 +455,6 @@ files = [ name = "isort" version = "5.12.0" description = "A Python utility / library to sort Python imports." -category = "dev" optional = false python-versions = ">=3.8.0" files = [ @@ -498,7 +472,6 @@ requirements-deprecated-finder = ["pip-api", "pipreqs"] name = "jedi" version = "0.19.0" description = "An autocompletion tool for Python that can be used for text editors." -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -518,7 +491,6 @@ testing = ["Django (<3.1)", "attrs", "colorama", "docopt", "pytest (<7.0.0)"] name = "lazy-object-proxy" version = "1.9.0" description = "A fast and thorough lazy object proxy." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -564,7 +536,6 @@ files = [ name = "mccabe" version = "0.7.0" description = "McCabe checker, plugin for flake8" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -576,7 +547,6 @@ files = [ name = "mixer" version = "7.2.2" description = "Mixer -- Is a fixtures replacement. Supported Django ORM, SqlAlchemy ORM, Mongoengine ODM and custom python objects." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -594,7 +564,6 @@ tests = ["Django (>=3.0)", "Flask (>=1.0)", "Marshmallow (>=3.9)", "SQLAlchemy ( name = "mypy" version = "1.5.1" description = "Optional static typing for Python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -641,7 +610,6 @@ reports = ["lxml"] name = "mypy-extensions" version = "1.0.0" description = "Type system extensions for programs checked with the mypy type checker." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -653,7 +621,6 @@ files = [ name = "packaging" version = "23.1" description = "Core utilities for Python packages" -category = "main" optional = false python-versions = ">=3.7" files = [ @@ -665,7 +632,6 @@ files = [ name = "parso" version = "0.8.3" description = "A Python Parser" -category = "dev" optional = false python-versions = ">=3.6" files = [ @@ -681,7 +647,6 @@ testing = ["docopt", "pytest (<6.0.0)"] name = "pathspec" version = "0.11.2" description = "Utility library for gitignore style pattern matching of file paths." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -693,7 +658,6 @@ files = [ name = "platformdirs" version = "3.10.0" description = "A small Python package for determining appropriate platform-specific dirs, e.g. a \"user data dir\"." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -709,7 +673,6 @@ test = ["appdirs (==1.4.4)", "covdefaults (>=2.3)", "pytest (>=7.4)", "pytest-co name = "pluggy" version = "1.3.0" description = "plugin and hook calling mechanisms for python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -725,7 +688,6 @@ testing = ["pytest", "pytest-benchmark"] name = "psycopg2-binary" version = "2.9.7" description = "psycopg2 - Python-PostgreSQL Database Adapter" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -793,18 +755,17 @@ files = [ [[package]] name = "pylint" -version = "2.17.5" +version = "2.17.6" description = "python code static checker" -category = "dev" optional = false python-versions = ">=3.7.2" files = [ - {file = "pylint-2.17.5-py3-none-any.whl", hash = "sha256:73995fb8216d3bed149c8d51bba25b2c52a8251a2c8ac846ec668ce38fab5413"}, - {file = "pylint-2.17.5.tar.gz", hash = "sha256:f7b601cbc06fef7e62a754e2b41294c2aa31f1cb659624b9a85bcba29eaf8252"}, + {file = "pylint-2.17.6-py3-none-any.whl", hash = "sha256:18a1412e873caf8ffb56b760ce1b5643675af23e6173a247b502406b24c716af"}, + {file = "pylint-2.17.6.tar.gz", hash = "sha256:be928cce5c76bf9acdc65ad01447a1e0b1a7bccffc609fb7fc40f2513045bd05"}, ] [package.dependencies] -astroid = ">=2.15.6,<=2.17.0-dev0" +astroid = ">=2.15.7,<=2.17.0-dev0" colorama = {version = ">=0.4.5", markers = "sys_platform == \"win32\""} dill = [ {version = ">=0.2", markers = "python_version < \"3.11\""}, @@ -825,7 +786,6 @@ testutils = ["gitpython (>3)"] name = "pylint-django" version = "2.5.3" description = "A Pylint plugin to help Pylint understand the Django web framework" -category = "dev" optional = false python-versions = "*" files = [ @@ -845,7 +805,6 @@ with-django = ["Django"] name = "pylint-plugin-utils" version = "0.8.2" description = "Utilities and helpers for writing Pylint plugins" -category = "dev" optional = false python-versions = ">=3.7,<4.0" files = [ @@ -860,7 +819,6 @@ pylint = ">=1.7" name = "pytest" version = "7.4.2" description = "pytest: simple powerful testing with Python" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -883,7 +841,6 @@ testing = ["argcomplete", "attrs (>=19.2.0)", "hypothesis (>=3.56)", "mock", "no name = "pytest-cov" version = "4.1.0" description = "Pytest plugin for measuring coverage." -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -902,7 +859,6 @@ testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtuale name = "pytest-django" version = "4.5.2" description = "A Django plugin for pytest." -category = "dev" optional = false python-versions = ">=3.5" files = [ @@ -921,7 +877,6 @@ testing = ["Django", "django-configurations (>=2.0)"] name = "pytest-xdist" version = "3.3.1" description = "pytest xdist plugin for distributed testing, most importantly across multiple CPUs" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -942,7 +897,6 @@ testing = ["filelock"] name = "python-dateutil" version = "2.8.2" description = "Extensions to the standard Python datetime module" -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,>=2.7" files = [ @@ -955,14 +909,13 @@ six = ">=1.5" [[package]] name = "python-lsp-jsonrpc" -version = "1.1.1" +version = "1.1.2" description = "JSON RPC 2.0 server library" -category = "dev" optional = false python-versions = ">=3.8" files = [ - {file = "python-lsp-jsonrpc-1.1.1.tar.gz", hash = "sha256:05cc914aa5ee2e7f52eb762014ba4996a8cc52459bfddb81fb96c56ace927908"}, - {file = "python_lsp_jsonrpc-1.1.1-py3-none-any.whl", hash = "sha256:2bd7771bd5e23ba2edb17101432c5fd680bbacedb8dddeb472a8250ca8d936d6"}, + {file = "python-lsp-jsonrpc-1.1.2.tar.gz", hash = "sha256:4688e453eef55cd952bff762c705cedefa12055c0aec17a06f595bcc002cc912"}, + {file = "python_lsp_jsonrpc-1.1.2-py3-none-any.whl", hash = "sha256:7339c2e9630ae98903fdaea1ace8c47fba0484983794d6aafd0bd8989be2b03c"}, ] [package.dependencies] @@ -975,7 +928,6 @@ test = ["coverage", "pycodestyle", "pyflakes", "pylint", "pytest", "pytest-cov"] name = "python-lsp-server" version = "1.8.0" description = "Python Language Server for the Language Server Protocol" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1009,7 +961,6 @@ yapf = ["whatthepatch (>=1.0.2,<2.0.0)", "yapf (>=0.33.0)"] name = "python-monkey-business" version = "1.0.0" description = "Utility functions for monkey-patching python code" -category = "main" optional = false python-versions = "*" files = [ @@ -1024,7 +975,6 @@ six = ">=1.7.0" name = "pyyaml" version = "6.0.1" description = "YAML parser and emitter for Python" -category = "main" optional = false python-versions = ">=3.6" files = [ @@ -1084,7 +1034,6 @@ files = [ name = "six" version = "1.16.0" description = "Python 2 and 3 compatibility utilities" -category = "main" optional = false python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*" files = [ @@ -1096,7 +1045,6 @@ files = [ name = "sqlparse" version = "0.4.4" description = "A non-validating SQL parser." -category = "main" optional = false python-versions = ">=3.5" files = [ @@ -1113,7 +1061,6 @@ test = ["pytest", "pytest-cov"] name = "tomli" version = "2.0.1" description = "A lil' TOML parser" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1125,7 +1072,6 @@ files = [ name = "tomlkit" version = "0.12.1" description = "Style preserving TOML library" -category = "dev" optional = false python-versions = ">=3.7" files = [ @@ -1135,33 +1081,30 @@ files = [ [[package]] name = "types-pytz" -version = "2023.3.1.0" +version = "2023.3.1.1" description = "Typing stubs for pytz" -category = "dev" optional = false python-versions = "*" files = [ - {file = "types-pytz-2023.3.1.0.tar.gz", hash = "sha256:8e7d2198cba44a72df7628887c90f68a568e1445f14db64631af50c3cab8c090"}, - {file = "types_pytz-2023.3.1.0-py3-none-any.whl", hash = "sha256:a660a38ed86d45970603e4f3b4877c7ba947668386a896fb5d9589c17e7b8407"}, + {file = "types-pytz-2023.3.1.1.tar.gz", hash = "sha256:cc23d0192cd49c8f6bba44ee0c81e4586a8f30204970fc0894d209a6b08dab9a"}, + {file = "types_pytz-2023.3.1.1-py3-none-any.whl", hash = "sha256:1999a123a3dc0e39a2ef6d19f3f8584211de9e6a77fe7a0259f04a524e90a5cf"}, ] [[package]] name = "types-pyyaml" -version = "6.0.12.11" +version = "6.0.12.12" description = "Typing stubs for PyYAML" -category = "dev" optional = false python-versions = "*" files = [ - {file = "types-PyYAML-6.0.12.11.tar.gz", hash = "sha256:7d340b19ca28cddfdba438ee638cd4084bde213e501a3978738543e27094775b"}, - {file = "types_PyYAML-6.0.12.11-py3-none-any.whl", hash = "sha256:a461508f3096d1d5810ec5ab95d7eeecb651f3a15b71959999988942063bf01d"}, + {file = "types-PyYAML-6.0.12.12.tar.gz", hash = "sha256:334373d392fde0fdf95af5c3f1661885fa10c52167b14593eb856289e1855062"}, + {file = "types_PyYAML-6.0.12.12-py3-none-any.whl", hash = "sha256:c05bc6c158facb0676674b7f11fe3960db4f389718e19e62bd2b84d6205cfd24"}, ] [[package]] name = "typing-extensions" version = "4.8.0" description = "Backported and Experimental Type Hints for Python 3.8+" -category = "main" optional = false python-versions = ">=3.8" files = [ @@ -1173,7 +1116,6 @@ files = [ name = "tzdata" version = "2023.3" description = "Provider of IANA time zone data" -category = "main" optional = false python-versions = ">=2" files = [ @@ -1185,7 +1127,6 @@ files = [ name = "ujson" version = "5.8.0" description = "Ultra fast JSON encoder and decoder for Python" -category = "dev" optional = false python-versions = ">=3.8" files = [ @@ -1256,7 +1197,6 @@ files = [ name = "wrapt" version = "1.15.0" description = "Module for decorators, wrappers and monkey patching." -category = "dev" optional = false python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" files = [ @@ -1341,7 +1281,6 @@ files = [ name = "zipp" version = "3.17.0" description = "Backport of pathlib-compatible object wrapper for zip files" -category = "dev" optional = false python-versions = ">=3.8" files = [ From bfb78ae3cbbc8645095f83a7406218bbe7d04fc8 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Tue, 26 Sep 2023 21:25:09 +0200 Subject: [PATCH 3/5] Add dev check command --- dev.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dev.sh b/dev.sh index bfd078d..71a80c1 100755 --- a/dev.sh +++ b/dev.sh @@ -142,6 +142,13 @@ test() { descriptions["test"]="Run the tests in the RAM DB and write a coverage report." tasks["test"]=test +check() { + lint + test +} +descriptions["check"]="Run lint and test in one session" +tasks["check"]=check + update() { poetry update } From 6f1998a7a36af39f4ee0f7c5fbd50ff75fdf4c08 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Wed, 27 Sep 2023 19:48:30 +0200 Subject: [PATCH 4/5] Add python to devshell --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 2c50515..ca6c787 100644 --- a/flake.nix +++ b/flake.nix @@ -24,6 +24,7 @@ devShells.default = pkgs.mkShell { buildInputs = [ pkgs.poetry + pkgs.python310 pkgs.overmind pkgs.postgresql_15 (pkgs.writeScriptBin "dev" "${builtins.readFile ./dev.sh}") From a79a52b42a756d298729f469417852f8b0e9e957 Mon Sep 17 00:00:00 2001 From: Andreas Zweili Date: Wed, 27 Sep 2023 20:20:45 +0200 Subject: [PATCH 5/5] Allow all hosts when developing The hostname changes a lot and some servers have multiple IPs. --- src/network_inventory/settings/local.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/network_inventory/settings/local.py b/src/network_inventory/settings/local.py index 0237dad..2d2ab5e 100644 --- a/src/network_inventory/settings/local.py +++ b/src/network_inventory/settings/local.py @@ -7,14 +7,7 @@ import os from .base import * -ALLOWED_HOSTS = [ - "localhost", - "127.0.0.1", - "0.0.0.0", - getfqdn(), - gethostname(), - gethostbyname(gethostname()), -] +ALLOWED_HOSTS = ["*"] CSRF_TRUSTED_ORIGINS = [ "http://localhost:8000",