From 0e048be92228921972391c57d761eee119055581 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 20:15:53 -0300 Subject: [PATCH 01/33] Change test.yml --- .github/workflows/test.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b0f5248..4a38802 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,11 +1,7 @@ name: Danix File System -on: - push: - - dev - - pull_request: - - main +on: pull_request +on: push jobs: continuous-integration: From 2da93a09777b1fa1e2e14f6fd1d47af7f897a1ba Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 20:30:36 -0300 Subject: [PATCH 02/33] On branch dev Your branch is up to date with 'origin/dev'. Changes to be committed: modified: .github/workflows/test.yml modified: danix/makefile --- .github/workflows/test.yml | 23 ++++++++++++----------- danix/makefile | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 4a38802..2f5b2c4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,10 @@ name: Danix File System -on: pull_request -on: push +on: + pull_request: + branches: [main] + push: + branches: [dev] jobs: continuous-integration: @@ -11,16 +14,14 @@ jobs: - uses: actions/checkout@v3 - name: Test - uses: actions/setup-python@v2 + - shell: bash - with: python-version: 3.11 - - name: Install Requirements + - name: Install danix run: | - pip install -r requirements.txt - - name: Creating Database - run: | - python manage.py makemigrations - python manage.py migrate - - name: Run Danix - run: | - python danix.py + apt update -y + apt install make -y + cd danix + make install + make aliases diff --git a/danix/makefile b/danix/makefile index 242b9a1..65f6d78 100644 --- a/danix/makefile +++ b/danix/makefile @@ -105,4 +105,4 @@ clean: @rm -r $(MAIN_REPO) > /dev/null 2>&1 @rm -r $(DANIX_PATH) > /dev/null 2>&1 - @echo Danix cleaned! \ No newline at end of file + @echo Danix cleaned! From 67dcdf2631c23c863df9ac502622b3655651dd3e Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 21:32:02 -0300 Subject: [PATCH 03/33] Update test.yml --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2f5b2c4..f35800d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,8 +11,9 @@ jobs: runs-on: ubuntu-latest steps: + - uses: Checkout - uses: actions/checkout@v3 - - name: Test + - name: Python - uses: actions/setup-python@v2 - shell: bash - with: From a9f7ee04b4dff0acd8f11ccddf3993642ff71e90 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 21:41:59 -0300 Subject: [PATCH 04/33] Update test.yml --- .github/workflows/test.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f35800d..88abb34 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,13 +11,14 @@ jobs: runs-on: ubuntu-latest steps: - - uses: Checkout - - uses: actions/checkout@v3 + - name: Checkout + uses: actions/checkout@v3 + - name: Python - - uses: actions/setup-python@v2 - - shell: bash - - with: - python-version: 3.11 + uses: actions/setup-python@v2 + with: + python-version: 3.10 + - name: Install danix run: | apt update -y From c7f0f8d4866b41592f46e5468e54fd44a2c75d57 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 21:43:58 -0300 Subject: [PATCH 05/33] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 88abb34..76967c0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,7 +17,7 @@ jobs: - name: Python uses: actions/setup-python@v2 with: - python-version: 3.10 + python-version: "3.10" - name: Install danix run: | From a0db88324991bcb596300587932592f63721ee86 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 21:45:53 -0300 Subject: [PATCH 06/33] Update test.yml --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 76967c0..aa0a137 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,9 +21,8 @@ jobs: - name: Install danix run: | - apt update -y - apt install make -y + sudo apt update -y + sudo apt install make -y cd danix make install make aliases - From 3b887fee423f92fe7b715145b509c94f3610c92b Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 21:50:53 -0300 Subject: [PATCH 07/33] Update test.yml --- .github/workflows/test.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index aa0a137..0b55526 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,5 +24,6 @@ jobs: sudo apt update -y sudo apt install make -y cd danix - make install - make aliases + sudo make install + sudo make aliases + sudo danix From 23ee4a3eb2dd5af0d81463ca4ccf1efccd1d1dc5 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 21:54:15 -0300 Subject: [PATCH 08/33] Update test.yml --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1719788..980fe25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,4 +24,7 @@ jobs: sudo apt update -y sudo apt install make -y cd danix + sudo make install + sudo make aliases + sudo danix From 76ef136fb42a7fa85554432f85526c52616ef767 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 21:57:56 -0300 Subject: [PATCH 09/33] Create registry.py --- danix/registry.py | 437 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 437 insertions(+) create mode 100644 danix/registry.py diff --git a/danix/registry.py b/danix/registry.py new file mode 100644 index 0000000..dd9ee90 --- /dev/null +++ b/danix/registry.py @@ -0,0 +1,437 @@ +import functools +import sys +import threading +import warnings +from collections import Counter, defaultdict +from functools import partial + +from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured + +from .config import AppConfig + + +class Apps: + """ + A registry that stores the configuration of installed applications. + + It also keeps track of models, e.g. to provide reverse relations. + """ + + def __init__(self, installed_apps=()): + # installed_apps is set to None when creating the main registry + # because it cannot be populated at that point. Other registries must + # provide a list of installed apps and are populated immediately. + if installed_apps is None and hasattr(sys.modules[__name__], "apps"): + raise RuntimeError("You must supply an installed_apps argument.") + + # Mapping of app labels => model names => model classes. Every time a + # model is imported, ModelBase.__new__ calls apps.register_model which + # creates an entry in all_models. All imported models are registered, + # regardless of whether they're defined in an installed application + # and whether the registry has been populated. Since it isn't possible + # to reimport a module safely (it could reexecute initialization code) + # all_models is never overridden or reset. + self.all_models = defaultdict(dict) + + # Mapping of labels to AppConfig instances for installed apps. + self.app_configs = {} + + # Stack of app_configs. Used to store the current state in + # set_available_apps and set_installed_apps. + self.stored_app_configs = [] + + # Whether the registry is populated. + self.apps_ready = self.models_ready = self.ready = False + # For the autoreloader. + self.ready_event = threading.Event() + + # Lock for thread-safe population. + self._lock = threading.RLock() + self.loading = False + + # Maps ("app_label", "modelname") tuples to lists of functions to be + # called when the corresponding model is ready. Used by this class's + # `lazy_model_operation()` and `do_pending_operations()` methods. + self._pending_operations = defaultdict(list) + + # Populate apps and models, unless it's the main registry. + if installed_apps is not None: + self.populate(installed_apps) + + def populate(self, installed_apps=None): + """ + Load application configurations and models. + + Import each application module and then each model module. + + It is thread-safe and idempotent, but not reentrant. + """ + if self.ready: + return + + # populate() might be called by two threads in parallel on servers + # that create threads before initializing the WSGI callable. + with self._lock: + if self.ready: + return + + # An RLock prevents other threads from entering this section. The + # compare and set operation below is atomic. + if self.loading: + # Prevent reentrant calls to avoid running AppConfig.ready() + # methods twice. + self.app_configs = {} + #raise RuntimeError("populate() isn't reentrant") + self.loading = True + + # Phase 1: initialize app configs and import app modules. + for entry in installed_apps: + if isinstance(entry, AppConfig): + app_config = entry + else: + app_config = AppConfig.create(entry) + if app_config.label in self.app_configs: + raise ImproperlyConfigured( + "Application labels aren't unique, " + "duplicates: %s" % app_config.label + ) + + self.app_configs[app_config.label] = app_config + app_config.apps = self + + # Check for duplicate app names. + counts = Counter( + app_config.name for app_config in self.app_configs.values() + ) + duplicates = [name for name, count in counts.most_common() if count > 1] + if duplicates: + raise ImproperlyConfigured( + "Application names aren't unique, " + "duplicates: %s" % ", ".join(duplicates) + ) + + self.apps_ready = True + + # Phase 2: import models modules. + for app_config in self.app_configs.values(): + app_config.import_models() + + self.clear_cache() + + self.models_ready = True + + # Phase 3: run ready() methods of app configs. + for app_config in self.get_app_configs(): + app_config.ready() + + self.ready = True + self.ready_event.set() + + def check_apps_ready(self): + """Raise an exception if all apps haven't been imported yet.""" + if not self.apps_ready: + from django.conf import settings + + # If "not ready" is due to unconfigured settings, accessing + # INSTALLED_APPS raises a more helpful ImproperlyConfigured + # exception. + settings.INSTALLED_APPS + raise AppRegistryNotReady("Apps aren't loaded yet.") + + def check_models_ready(self): + """Raise an exception if all models haven't been imported yet.""" + if not self.models_ready: + raise AppRegistryNotReady("Models aren't loaded yet.") + + def get_app_configs(self): + """Import applications and return an iterable of app configs.""" + self.check_apps_ready() + return self.app_configs.values() + + def get_app_config(self, app_label): + """ + Import applications and returns an app config for the given label. + + Raise LookupError if no application exists with this label. + """ + self.check_apps_ready() + try: + return self.app_configs[app_label] + except KeyError: + message = "No installed app with label '%s'." % app_label + for app_config in self.get_app_configs(): + if app_config.name == app_label: + message += " Did you mean '%s'?" % app_config.label + break + raise LookupError(message) + + # This method is performance-critical at least for Django's test suite. + @functools.lru_cache(maxsize=None) + def get_models(self, include_auto_created=False, include_swapped=False): + """ + Return a list of all installed models. + + By default, the following models aren't included: + + - auto-created models for many-to-many relations without + an explicit intermediate table, + - models that have been swapped out. + + Set the corresponding keyword argument to True to include such models. + """ + self.check_models_ready() + + result = [] + for app_config in self.app_configs.values(): + result.extend(app_config.get_models(include_auto_created, include_swapped)) + return result + + def get_model(self, app_label, model_name=None, require_ready=True): + """ + Return the model matching the given app_label and model_name. + + As a shortcut, app_label may be in the form .. + + model_name is case-insensitive. + + Raise LookupError if no application exists with this label, or no + model exists with this name in the application. Raise ValueError if + called with a single argument that doesn't contain exactly one dot. + """ + if require_ready: + self.check_models_ready() + else: + self.check_apps_ready() + + if model_name is None: + app_label, model_name = app_label.split(".") + + app_config = self.get_app_config(app_label) + + if not require_ready and app_config.models is None: + app_config.import_models() + + return app_config.get_model(model_name, require_ready=require_ready) + + def register_model(self, app_label, model): + # Since this method is called when models are imported, it cannot + # perform imports because of the risk of import loops. It mustn't + # call get_app_config(). + model_name = model._meta.model_name + app_models = self.all_models[app_label] + if model_name in app_models: + if ( + model.__name__ == app_models[model_name].__name__ + and model.__module__ == app_models[model_name].__module__ + ): + warnings.warn( + "Model '%s.%s' was already registered. Reloading models is not " + "advised as it can lead to inconsistencies, most notably with " + "related models." % (app_label, model_name), + RuntimeWarning, + stacklevel=2, + ) + else: + raise RuntimeError( + "Conflicting '%s' models in application '%s': %s and %s." + % (model_name, app_label, app_models[model_name], model) + ) + app_models[model_name] = model + self.do_pending_operations(model) + self.clear_cache() + + def is_installed(self, app_name): + """ + Check whether an application with this name exists in the registry. + + app_name is the full name of the app e.g. 'django.contrib.admin'. + """ + self.check_apps_ready() + return any(ac.name == app_name for ac in self.app_configs.values()) + + def get_containing_app_config(self, object_name): + """ + Look for an app config containing a given object. + + object_name is the dotted Python path to the object. + + Return the app config for the inner application in case of nesting. + Return None if the object isn't in any registered app config. + """ + self.check_apps_ready() + candidates = [] + for app_config in self.app_configs.values(): + if object_name.startswith(app_config.name): + subpath = object_name[len(app_config.name) :] + if subpath == "" or subpath[0] == ".": + candidates.append(app_config) + if candidates: + return sorted(candidates, key=lambda ac: -len(ac.name))[0] + + def get_registered_model(self, app_label, model_name): + """ + Similar to get_model(), but doesn't require that an app exists with + the given app_label. + + It's safe to call this method at import time, even while the registry + is being populated. + """ + model = self.all_models[app_label].get(model_name.lower()) + if model is None: + raise LookupError("Model '%s.%s' not registered." % (app_label, model_name)) + return model + + @functools.lru_cache(maxsize=None) + def get_swappable_settings_name(self, to_string): + """ + For a given model string (e.g. "auth.User"), return the name of the + corresponding settings name if it refers to a swappable model. If the + referred model is not swappable, return None. + + This method is decorated with lru_cache because it's performance + critical when it comes to migrations. Since the swappable settings don't + change after Django has loaded the settings, there is no reason to get + the respective settings attribute over and over again. + """ + to_string = to_string.lower() + for model in self.get_models(include_swapped=True): + swapped = model._meta.swapped + # Is this model swapped out for the model given by to_string? + if swapped and swapped.lower() == to_string: + return model._meta.swappable + # Is this model swappable and the one given by to_string? + if model._meta.swappable and model._meta.label_lower == to_string: + return model._meta.swappable + return None + + def set_available_apps(self, available): + """ + Restrict the set of installed apps used by get_app_config[s]. + + available must be an iterable of application names. + + set_available_apps() must be balanced with unset_available_apps(). + + Primarily used for performance optimization in TransactionTestCase. + + This method is safe in the sense that it doesn't trigger any imports. + """ + available = set(available) + installed = {app_config.name for app_config in self.get_app_configs()} + if not available.issubset(installed): + raise ValueError( + "Available apps isn't a subset of installed apps, extra apps: %s" + % ", ".join(available - installed) + ) + + self.stored_app_configs.append(self.app_configs) + self.app_configs = { + label: app_config + for label, app_config in self.app_configs.items() + if app_config.name in available + } + self.clear_cache() + + def unset_available_apps(self): + """Cancel a previous call to set_available_apps().""" + self.app_configs = self.stored_app_configs.pop() + self.clear_cache() + + def set_installed_apps(self, installed): + """ + Enable a different set of installed apps for get_app_config[s]. + + installed must be an iterable in the same format as INSTALLED_APPS. + + set_installed_apps() must be balanced with unset_installed_apps(), + even if it exits with an exception. + + Primarily used as a receiver of the setting_changed signal in tests. + + This method may trigger new imports, which may add new models to the + registry of all imported models. They will stay in the registry even + after unset_installed_apps(). Since it isn't possible to replay + imports safely (e.g. that could lead to registering listeners twice), + models are registered when they're imported and never removed. + """ + if not self.ready: + raise AppRegistryNotReady("App registry isn't ready yet.") + self.stored_app_configs.append(self.app_configs) + self.app_configs = {} + self.apps_ready = self.models_ready = self.loading = self.ready = False + self.clear_cache() + self.populate(installed) + + def unset_installed_apps(self): + """Cancel a previous call to set_installed_apps().""" + self.app_configs = self.stored_app_configs.pop() + self.apps_ready = self.models_ready = self.ready = True + self.clear_cache() + + def clear_cache(self): + """ + Clear all internal caches, for methods that alter the app registry. + + This is mostly used in tests. + """ + # Call expire cache on each model. This will purge + # the relation tree and the fields cache. + self.get_models.cache_clear() + if self.ready: + # Circumvent self.get_models() to prevent that the cache is refilled. + # This particularly prevents that an empty value is cached while cloning. + for app_config in self.app_configs.values(): + for model in app_config.get_models(include_auto_created=True): + model._meta._expire_cache() + + def lazy_model_operation(self, function, *model_keys): + """ + Take a function and a number of ("app_label", "modelname") tuples, and + when all the corresponding models have been imported and registered, + call the function with the model classes as its arguments. + + The function passed to this method must accept exactly n models as + arguments, where n=len(model_keys). + """ + # Base case: no arguments, just execute the function. + if not model_keys: + function() + # Recursive case: take the head of model_keys, wait for the + # corresponding model class to be imported and registered, then apply + # that argument to the supplied function. Pass the resulting partial + # to lazy_model_operation() along with the remaining model args and + # repeat until all models are loaded and all arguments are applied. + else: + next_model, *more_models = model_keys + + # This will be executed after the class corresponding to next_model + # has been imported and registered. The `func` attribute provides + # duck-type compatibility with partials. + def apply_next_model(model): + next_function = partial(apply_next_model.func, model) + self.lazy_model_operation(next_function, *more_models) + + apply_next_model.func = function + + # If the model has already been imported and registered, partially + # apply it to the function now. If not, add it to the list of + # pending operations for the model, where it will be executed with + # the model class as its sole argument once the model is ready. + try: + model_class = self.get_registered_model(*next_model) + except LookupError: + self._pending_operations[next_model].append(apply_next_model) + else: + apply_next_model(model_class) + + def do_pending_operations(self, model): + """ + Take a newly-prepared model and pass it to each function waiting for + it. This is called at the very end of Apps.register_model(). + """ + key = model._meta.app_label, model._meta.model_name + for function in self._pending_operations.pop(key, []): + function(model) + + +apps = Apps(installed_apps=None) From 1dd94576cb207c1ba4b07a96270ba711df0d56c8 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:05:06 -0300 Subject: [PATCH 10/33] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 980fe25..856cb30 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,7 @@ jobs: sudo apt update -y sudo apt install make -y cd danix + sudo mv ./registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py sudo make install sudo make aliases sudo danix From 79367633983397f696f032707e416b0cda442a27 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:08:06 -0300 Subject: [PATCH 11/33] Update test.yml --- .github/workflows/test.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 856cb30..626f263 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,8 @@ jobs: sudo apt update -y sudo apt install make -y cd danix - sudo mv ./registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py + sudo rm /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py + sudo mv registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ sudo make install sudo make aliases sudo danix From 3ed215ebcfe2f5cb5f7abe9a5ee778077622e5e0 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:16:19 -0300 Subject: [PATCH 12/33] Update test.yml --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 626f263..980fe25 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,8 +24,6 @@ jobs: sudo apt update -y sudo apt install make -y cd danix - sudo rm /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py - sudo mv registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ sudo make install sudo make aliases sudo danix From e7902f245fe29e9377dfbb9055e0b3392375f4a0 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:17:58 -0300 Subject: [PATCH 13/33] Update makefile --- danix/makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/danix/makefile b/danix/makefile index 44a7ee8..42ef792 100644 --- a/danix/makefile +++ b/danix/makefile @@ -48,6 +48,9 @@ else @touch $(DANIX_PATH)/db/$(DB_NAME) > /dev/null 2>&1 @$(PIP) install -r $(DANIX_PATH)/requirements.txt > /dev/null 2>&1 + @rm /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py > /dev/null 2>&1 + @mv $(DANIX_PATH)/registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ > /dev/null 2>&1 + @$(PYTHON) $(DANIX_PATH)/manage.py migrate @echo "Installation successfully!!! Please 'make aliases without' sudo" From 470e5ab76699495efe6f7f794906e0ea92d37abe Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:20:00 -0300 Subject: [PATCH 14/33] Update makefile --- danix/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/danix/makefile b/danix/makefile index 42ef792..73f0158 100644 --- a/danix/makefile +++ b/danix/makefile @@ -48,8 +48,8 @@ else @touch $(DANIX_PATH)/db/$(DB_NAME) > /dev/null 2>&1 @$(PIP) install -r $(DANIX_PATH)/requirements.txt > /dev/null 2>&1 - @rm /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py > /dev/null 2>&1 - @mv $(DANIX_PATH)/registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ > /dev/null 2>&1 + @rm /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py + @mv $(DANIX_PATH)/registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ @$(PYTHON) $(DANIX_PATH)/manage.py migrate From 0725e73ba46b859e596e2d396fccaa37ae89bec7 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:23:37 -0300 Subject: [PATCH 15/33] Update makefile --- danix/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/danix/makefile b/danix/makefile index 73f0158..4be1151 100644 --- a/danix/makefile +++ b/danix/makefile @@ -45,8 +45,8 @@ else @echo ENV_STARTED=$(ENV_STARTED) >> $(DANIX_PATH)/.env @echo ENV_STOPPED=$(ENV_STOPPED) >> $(DANIX_PATH)/.env - @touch $(DANIX_PATH)/db/$(DB_NAME) > /dev/null 2>&1 - @$(PIP) install -r $(DANIX_PATH)/requirements.txt > /dev/null 2>&1 + @touch $(DANIX_PATH)/db/$(DB_NAME) + @$(PIP) install -r $(DANIX_PATH)/requirements.txt @rm /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py @mv $(DANIX_PATH)/registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ From 22e66f6255676880e644430bd5d5a2a48b4a4899 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:26:09 -0300 Subject: [PATCH 16/33] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 980fe25..f4675ec 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,7 @@ jobs: - name: Install danix run: | + ls -la /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ sudo apt update -y sudo apt install make -y cd danix From f7b27a953ce22f74529f1667246f68e380834dfb Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:30:14 -0300 Subject: [PATCH 17/33] Update test.yml --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f4675ec..2c28dbd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,6 +21,8 @@ jobs: - name: Install danix run: | + pip install django + pip install -r requirements.txt ls -la /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ sudo apt update -y sudo apt install make -y From 404cd09e597e24c28e83dcce01bde9f93b2d2b3c Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:31:51 -0300 Subject: [PATCH 18/33] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2c28dbd..28bf0a4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,12 +21,12 @@ jobs: - name: Install danix run: | + cd danix pip install django pip install -r requirements.txt ls -la /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ sudo apt update -y sudo apt install make -y - cd danix sudo make install sudo make aliases sudo danix From c3a87711a0494c3302e3fa7d7acf4c7a53dd6d52 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:35:01 -0300 Subject: [PATCH 19/33] Update test.yml --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 28bf0a4..95d6948 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,8 +24,8 @@ jobs: cd danix pip install django pip install -r requirements.txt - ls -la /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ - sudo apt update -y + sudo rm -r /opt/hostedtoolcache/Python/(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py + sudo mv registry.py rm -r /opt/hostedtoolcache/Python/(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ sudo apt install make -y sudo make install sudo make aliases From 628a80aff09fb8e53aedc4b4c131a4e82e7b6941 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:35:40 -0300 Subject: [PATCH 20/33] Update makefile --- danix/makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/danix/makefile b/danix/makefile index 4be1151..af03775 100644 --- a/danix/makefile +++ b/danix/makefile @@ -48,9 +48,6 @@ else @touch $(DANIX_PATH)/db/$(DB_NAME) @$(PIP) install -r $(DANIX_PATH)/requirements.txt - @rm /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/registry.py - @mv $(DANIX_PATH)/registry.py /usr/local/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/dist-packages/django/apps/ - @$(PYTHON) $(DANIX_PATH)/manage.py migrate @echo "Installation successfully!!! Please 'make aliases without' sudo" From b4dc3d04b70c1b466f1240ead261ca055fdd3c97 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:37:26 -0300 Subject: [PATCH 21/33] Update test.yml --- .github/workflows/test.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 95d6948..5d03cd0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,10 +22,9 @@ jobs: - name: Install danix run: | cd danix - pip install django pip install -r requirements.txt - sudo rm -r /opt/hostedtoolcache/Python/(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py - sudo mv registry.py rm -r /opt/hostedtoolcache/Python/(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ + sudo rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py + sudo mv registry.py rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ sudo apt install make -y sudo make install sudo make aliases From 63f28ac36c37ba5a8274a2475ff11aac7a17ab71 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:45:11 -0300 Subject: [PATCH 22/33] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5d03cd0..e71e220 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,7 @@ jobs: cd danix pip install -r requirements.txt sudo rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py - sudo mv registry.py rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ + sudo mv registry.py /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ sudo apt install make -y sudo make install sudo make aliases From e6352055253eaa4dbad645157ce5479c2728f97a Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:47:08 -0300 Subject: [PATCH 23/33] Update test.yml --- .github/workflows/test.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e71e220..325e5f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,9 +22,6 @@ jobs: - name: Install danix run: | cd danix - pip install -r requirements.txt - sudo rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py - sudo mv registry.py /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ sudo apt install make -y sudo make install sudo make aliases From 36cc9f6b631c14591e034a24706b75418d41b179 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:48:06 -0300 Subject: [PATCH 24/33] Update makefile --- danix/makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/danix/makefile b/danix/makefile index af03775..648e297 100644 --- a/danix/makefile +++ b/danix/makefile @@ -48,6 +48,9 @@ else @touch $(DANIX_PATH)/db/$(DB_NAME) @$(PIP) install -r $(DANIX_PATH)/requirements.txt + @rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py + @mv $(DANIX_PATH)/registry.py /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ + @$(PYTHON) $(DANIX_PATH)/manage.py migrate @echo "Installation successfully!!! Please 'make aliases without' sudo" From b3f22323af41c517bf411458cc113f86ade6c8d5 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 22:51:03 -0300 Subject: [PATCH 25/33] Update makefile --- danix/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/danix/makefile b/danix/makefile index 648e297..92861ff 100644 --- a/danix/makefile +++ b/danix/makefile @@ -47,9 +47,9 @@ else @touch $(DANIX_PATH)/db/$(DB_NAME) @$(PIP) install -r $(DANIX_PATH)/requirements.txt - + @rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py - @mv $(DANIX_PATH)/registry.py /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ + @mv $(DANIX_PATH)/registry.py /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ @$(PYTHON) $(DANIX_PATH)/manage.py migrate From 063bc2373d972b7cf3c75c39b2181ec6169230b3 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:05:02 -0300 Subject: [PATCH 26/33] Update makefile --- danix/makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/danix/makefile b/danix/makefile index 92861ff..b260b1a 100644 --- a/danix/makefile +++ b/danix/makefile @@ -48,8 +48,8 @@ else @touch $(DANIX_PATH)/db/$(DB_NAME) @$(PIP) install -r $(DANIX_PATH)/requirements.txt - @rm -r /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/registry.py - @mv $(DANIX_PATH)/registry.py /opt/hostedtoolcache/Python/$(python --version 2>&1 | awk '{print $2}')/x64/lib/python$(python --version 2>&1 | awk '{print $2}' | cut -d'.' -f1,2)/site-packages/django/apps/ + @rm -r $(python -c "import sysconfig; print(sysconfig.get_paths()['purelib'])")/django/apps/registry.py + @mv $(DANIX_PATH)/registry.py $(python -c "import sysconfig; print(sysconfig.get_paths()['purelib'])")/django/apps/django/apps/ @$(PYTHON) $(DANIX_PATH)/manage.py migrate From dc5c5d2ede88d47f9a757bfdd7973b93b4ea672d Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:46:57 -0300 Subject: [PATCH 27/33] Update makefile --- danix/makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/danix/makefile b/danix/makefile index b260b1a..0a410e3 100644 --- a/danix/makefile +++ b/danix/makefile @@ -14,7 +14,7 @@ ENV_STARTED=Environment started successfully! ENV_STOPPED=Environment stopped successfully! ENV_STOPPED_ERROR=Error! The environment is stopped! ENV_PATTERN_ERROR=Environment name pattern contains in multiples environments - +PYTHON_PATH := $(shell python -c "import sysconfig; print(sysconfig.get_paths()['purelib'])") install: @@ -48,8 +48,8 @@ else @touch $(DANIX_PATH)/db/$(DB_NAME) @$(PIP) install -r $(DANIX_PATH)/requirements.txt - @rm -r $(python -c "import sysconfig; print(sysconfig.get_paths()['purelib'])")/django/apps/registry.py - @mv $(DANIX_PATH)/registry.py $(python -c "import sysconfig; print(sysconfig.get_paths()['purelib'])")/django/apps/django/apps/ + @rm -r $(PYTHON_PATH)/django/apps/registry.py + @mv $(DANIX_PATH)/registry.py $(PYTHON_PATH)/django/apps/ @$(PYTHON) $(DANIX_PATH)/manage.py migrate From cac54b5485214f7032f527c8ce701fd8a70a8208 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:49:14 -0300 Subject: [PATCH 28/33] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 325e5f6..83ab4d1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,5 +25,5 @@ jobs: sudo apt install make -y sudo make install sudo make aliases - sudo danix + danix From 65f01bab9e39d8b8301bda979318aee89d04652d Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:50:37 -0300 Subject: [PATCH 29/33] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83ab4d1..b616db2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,6 +24,6 @@ jobs: cd danix sudo apt install make -y sudo make install - sudo make aliases + make aliases danix From 03a9d65e8ef3a87fdb52738cdda6fa7315ccc0ce Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:54:02 -0300 Subject: [PATCH 30/33] Update test.yml --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b616db2..bbc30f5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,6 +20,7 @@ jobs: python-version: "3.10" - name: Install danix + shell: bash run: | cd danix sudo apt install make -y From 3622dde8eb52496481e71151fd0c802b1eb237f9 Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:56:38 -0300 Subject: [PATCH 31/33] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bbc30f5..f62c221 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,6 +25,6 @@ jobs: cd danix sudo apt install make -y sudo make install - make aliases + sudo python /usr/share/danix/main.py danix From 06239d1edb5d5d0110115875b48652e6af4b97ac Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:57:28 -0300 Subject: [PATCH 32/33] Update test.yml --- .github/workflows/test.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f62c221..ec18782 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,5 +26,4 @@ jobs: sudo apt install make -y sudo make install sudo python /usr/share/danix/main.py - danix From 08eb84a5fce738c551720e2d8fbdf54482842dbe Mon Sep 17 00:00:00 2001 From: Vinicius Silva Date: Mon, 25 Dec 2023 23:58:51 -0300 Subject: [PATCH 33/33] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ec18782..f45a707 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -25,5 +25,5 @@ jobs: cd danix sudo apt install make -y sudo make install - sudo python /usr/share/danix/main.py + sudo python /usr/share/danix/main.py --help