docker: mobilizon-reshare: Upstream dynaconf. (#115)

This commit is contained in:
Giacomo Leidi 2021-12-08 21:11:41 +01:00 committed by GitHub
parent 2c0b0fb46d
commit f273873f67
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 8 additions and 318 deletions

2
.envrc
View File

@ -1,6 +1,6 @@
if command -v guix; then if command -v guix; then
rm -f .guix-root rm -f .guix-root
eval "$(guix time-machine -C channels-lock.scm -- shell -r .guix-root -D -f guix.scm -m manifest.scm --pure --search-paths -L . -L ./patches)" eval "$(guix time-machine -C channels-lock.scm -- shell -r .guix-root -D -f guix.scm -m manifest.scm --pure --search-paths -L .)"
# Add development scripts to PATH # Add development scripts to PATH
export PATH="$(pwd)/scripts:${PATH}" export PATH="$(pwd)/scripts:${PATH}"

View File

@ -3,7 +3,7 @@
(name 'guix) (name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git") (url "https://git.savannah.gnu.org/git/guix.git")
(commit (commit
"d495a902b26756e69bd8b028ec995107bfadf264") "20d525a842ca5d22edc4e2aa4a5d8225c2f5306c")
(introduction (introduction
(make-channel-introduction (make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad" "9edb3f66fd807b096b48283debdcddccfea34bad"

View File

@ -36,135 +36,6 @@
(define-public python-3.9-wrapper (define-public python-3.9-wrapper
(wrap-python3 python-3.9)) (wrap-python3 python-3.9))
;; TODO: This should probably be upstreamed.
(define-public python-dotenv
(package
(name "python-dotenv")
(version "0.17.0")
(source
(origin
(method url-fetch)
(uri (pypi-uri "python-dotenv" version))
(sha256
(base32
"0jjg7b8073gxsmh47ic152xdxym5zhw887ilh0ddl45gl0nph6s7"))))
(build-system python-build-system)
(propagated-inputs
`(("python-click" ,python-click)))
(native-inputs
`(("python-mock" ,python-mock)
("python-pytest" ,python-pytest)
("python-sh" ,python-sh)))
(home-page
"https://github.com/theskumar/python-dotenv")
(synopsis
"Setup environment variables according to .env files")
(description
"This package provides the @code{python-dotenv} Python module to
read key-value pairs from a .env file and set them as environment variables")
(license license:bsd-3)))
;; TODO: This should probably be upstreamed.
;; This is only for python-dynaconf.
(define-public python-dotenv-0.13.0
(package (inherit python-dotenv)
(name "python-dotenv")
(version "0.13.0")
(source
(origin
(method url-fetch)
(uri (pypi-uri "python-dotenv" version))
(sha256
(base32
"0x5dagmfn31phrbxlwacw3s4w5vibv8fxqc62nqcdvdhjsy0k69v"))))))
;; TODO: This should probably be upstreamed.
;; This is only for python-dynaconf.
(define-public python-ruamel.yaml-0.16.10
(package (inherit python-ruamel.yaml)
(name "python-ruamel.yaml")
(version "0.16.10")
(source
(origin
(method url-fetch)
(uri (pypi-uri "ruamel.yaml" version))
(sha256
(base32
"0m5rwlf3iwsb1w9l98qx9alvqxk41gfphksj03x2zxwbfx569709"))))))
;; TODO: This should probably be upstreamed.
(define-public python-dynaconf
(package
(name "dynaconf")
(version "3.1.5")
(source
(origin
(method git-fetch)
(uri
(git-reference
(url "https://github.com/rochacbruno/dynaconf")
(commit version)))
(file-name (git-file-name name version))
(sha256
(base32
"0hxp1iadwmva79l16frvc77jrisppb09z6k1asm0qfjjzwyaswg3"))
(patches (search-patches "dynaconf-Unvendor-dependencies.patch"))
(modules '((guix build utils)))
(snippet '(begin
;; Remove vendored dependencies
(let ((unvendor '("click" "dotenv" "ruamel" "toml")))
(with-directory-excursion "dynaconf/vendor"
(for-each delete-file-recursively unvendor))
(with-directory-excursion "dynaconf/vendor_src"
(for-each delete-file-recursively unvendor)))))))
(build-system python-build-system)
(arguments
`(#:phases
(modify-phases %standard-phases
(replace 'check
(lambda* (#:key tests? outputs #:allow-other-keys)
(when tests?
(setenv "PATH"
(string-append (assoc-ref outputs "out") "/bin:"
(getenv "PATH")))
;; These tests depend on hvac and a
;; live Vault process.
(delete-file "tests/test_vault.py")
(invoke "make" "test_only")))))))
(propagated-inputs
`(("python-click" ,python-click)
("python-configobj" ,python-configobj)
("python-dotenv" ,python-dotenv-0.13.0)
("python-ruamel.yaml" ,python-ruamel.yaml-0.16.10)
("python-toml" ,python-toml)))
(native-inputs
`(("python-django" ,python-django)
("python-flask" ,python-flask)
("python-pytest" ,python-pytest-6)
("python-pytest-cov" ,python-pytest-cov)
("python-pytest-mock" ,python-pytest-mock)))
(home-page "https://www.dynaconf.com/")
(synopsis "The dynamic configurator for your Python project")
(description
"This package provides @code{dynaconf} the dynamic configurator manager for
your Python project. It provides features such as:
@itemize
@item Inspired by the @url{https://12factor.net/config, 12-factor application guide};
@item Settings management (default values, validation, parsing, templating);
@item Protection of sensitive information (passwords/tokens);
@item Multiple file formats @code{toml|yaml|json|ini|py} and also customizable
loaders;
@item Full support for environment variables to override existing settings
(dotenv support included);
@item Optional layered system for multiple environments @code{[default,
development, testing, production]};
@item Built-in support for Hashicorp Vault and Redis as settings and secrets storage;
@item Built-in extensions for Django and Flask web frameworks;
@item CLI for common operations such as @code{init, list, write, validate, export}.
@end itemize")
(license license:expat)))
;; This is only for mobilizon-bots.git. ;; This is only for mobilizon-bots.git.
(define-public python-arrow-1.1 (define-public python-arrow-1.1
(package (inherit python-arrow) (package (inherit python-arrow)
@ -432,7 +303,7 @@ Facebook authentication.")
("python-arrow" ,python-arrow-1.1) ("python-arrow" ,python-arrow-1.1)
("python-beautifulsoup4" ,python-beautifulsoup4) ("python-beautifulsoup4" ,python-beautifulsoup4)
("python-click" ,python-click) ("python-click" ,python-click)
("python-dynaconf" ,python-dynaconf) ("dynaconf" ,dynaconf)
("python-facebook-sdk" ,python-facebook-sdk.git) ("python-facebook-sdk" ,python-facebook-sdk.git)
("python-jinja2" ,python-jinja2) ("python-jinja2" ,python-jinja2)
("python-markdownify" ,python-markdownify) ("python-markdownify" ,python-markdownify)

View File

@ -48,11 +48,10 @@ def build_settings(
Creates a Dynaconf base object. Configuration files are checked in this order: Creates a Dynaconf base object. Configuration files are checked in this order:
1. CLI argument 1. CLI argument
2. `MOBILIZION_RESHARE_SETTINGS_FILE` environment variable; 2. User configuration directory. On Linux that's `$XDG_CONFIG_HOME/mobilizon_reshare/<mobilizon-reshare-version>`;
3. User configuration directory. On Linux that's `$XDG_CONFIG_HOME/mobilizon_reshare/<mobilizon-reshare-version>`; 3. System configuration directory. On Linux that's the first element of
4. User configuration directory. On Linux that's the first element of
`$XDG_CONFIG_DIRS` + `/mobilizon_reshare/<mobilizon-reshare-version>`. `$XDG_CONFIG_DIRS` + `/mobilizon_reshare/<mobilizon-reshare-version>`.
5. The default configuration distributed with the package. 4. The default configuration distributed with the package.
The first available configuration file will be loaded. The first available configuration file will be loaded.
""" """

View File

@ -1,180 +0,0 @@
From 3f7b48195500cbbbbecd3cac2f5308c64004479b Mon Sep 17 00:00:00 2001
From: Giacomo Leidi <goodoldpaul@autistici.org>
Date: Sun, 29 Aug 2021 23:39:27 +0200
Subject: [PATCH] Use system site dependencies.
Box was not unvendored because it appears to be heavily patched.
---
dynaconf/cli.py | 4 ++--
dynaconf/default_settings.py | 2 +-
dynaconf/loaders/env_loader.py | 2 +-
dynaconf/loaders/toml_loader.py | 2 +-
dynaconf/loaders/yaml_loader.py | 2 +-
dynaconf/utils/parse_conf.py | 2 +-
dynaconf/vendor/box/converters.py | 4 ++--
dynaconf/vendor/box/from_file.py | 4 ++--
dynaconf/vendor_src/box/converters.py | 4 ++--
dynaconf/vendor_src/box/from_file.py | 4 ++--
tests/test_cli.py | 2 +-
11 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/dynaconf/cli.py b/dynaconf/cli.py
index 5bb8316..1341a95 100644
--- a/dynaconf/cli.py
+++ b/dynaconf/cli.py
@@ -20,8 +20,8 @@ from dynaconf.utils.functional import empty
from dynaconf.utils.parse_conf import parse_conf_data
from dynaconf.validator import ValidationError
from dynaconf.validator import Validator
-from dynaconf.vendor import click
-from dynaconf.vendor import toml
+import click
+import toml
CWD = Path.cwd()
diff --git a/dynaconf/default_settings.py b/dynaconf/default_settings.py
index 66601b0..9605fc5 100644
--- a/dynaconf/default_settings.py
+++ b/dynaconf/default_settings.py
@@ -8,7 +8,7 @@ from dynaconf.utils import upperfy
from dynaconf.utils import warn_deprecations
from dynaconf.utils.files import find_file
from dynaconf.utils.parse_conf import parse_conf_data
-from dynaconf.vendor.dotenv import load_dotenv
+from dotenv import load_dotenv
def try_renamed(key, value, older_key, current_key):
diff --git a/dynaconf/loaders/env_loader.py b/dynaconf/loaders/env_loader.py
index e7b13bd..b034c8a 100644
--- a/dynaconf/loaders/env_loader.py
+++ b/dynaconf/loaders/env_loader.py
@@ -2,7 +2,7 @@ from os import environ
from dynaconf.utils import upperfy
from dynaconf.utils.parse_conf import parse_conf_data
-from dynaconf.vendor.dotenv import cli as dotenv_cli
+from dotenv import cli as dotenv_cli
IDENTIFIER = "env"
diff --git a/dynaconf/loaders/toml_loader.py b/dynaconf/loaders/toml_loader.py
index 07b973f..d81d675 100644
--- a/dynaconf/loaders/toml_loader.py
+++ b/dynaconf/loaders/toml_loader.py
@@ -5,7 +5,7 @@ from dynaconf import default_settings
from dynaconf.constants import TOML_EXTENSIONS
from dynaconf.loaders.base import BaseLoader
from dynaconf.utils import object_merge
-from dynaconf.vendor import toml
+import toml
def load(obj, env=None, silent=True, key=None, filename=None):
diff --git a/dynaconf/loaders/yaml_loader.py b/dynaconf/loaders/yaml_loader.py
index 33c6532..3ef419a 100644
--- a/dynaconf/loaders/yaml_loader.py
+++ b/dynaconf/loaders/yaml_loader.py
@@ -7,7 +7,7 @@ from dynaconf.constants import YAML_EXTENSIONS
from dynaconf.loaders.base import BaseLoader
from dynaconf.utils import object_merge
from dynaconf.utils.parse_conf import try_to_encode
-from dynaconf.vendor.ruamel import yaml
+from ruamel import yaml
# Add support for Dynaconf Lazy values to YAML dumper
yaml.SafeDumper.yaml_representers[
diff --git a/dynaconf/utils/parse_conf.py b/dynaconf/utils/parse_conf.py
index c42b07a..01ccdae 100644
--- a/dynaconf/utils/parse_conf.py
+++ b/dynaconf/utils/parse_conf.py
@@ -9,7 +9,7 @@ from dynaconf.utils import isnamedtupleinstance
from dynaconf.utils import multi_replace
from dynaconf.utils import recursively_evaluate_lazy_format
from dynaconf.utils.boxing import DynaBox
-from dynaconf.vendor import toml
+import toml
try:
from jinja2 import Environment
diff --git a/dynaconf/vendor/box/converters.py b/dynaconf/vendor/box/converters.py
index 93cdcfb..e34c7dc 100644
--- a/dynaconf/vendor/box/converters.py
+++ b/dynaconf/vendor/box/converters.py
@@ -7,9 +7,9 @@ _B='utf-8'
_A=None
import csv,json,sys,warnings
from pathlib import Path
-import dynaconf.vendor.ruamel.yaml as yaml
+import ruamel.yaml as yaml
from dynaconf.vendor.box.exceptions import BoxError,BoxWarning
-from dynaconf.vendor import toml
+import toml
BOX_PARAMETERS='default_box','default_box_attr','conversion_box','frozen_box','camel_killer_box','box_safe_prefix','box_duplicates','ordered_box','default_box_none_transform','box_dots','modify_tuples_box','box_intact_types','box_recast'
def _exists(filename,create=_E):
A=filename;B=Path(A)
diff --git a/dynaconf/vendor/box/from_file.py b/dynaconf/vendor/box/from_file.py
index daa1137..d75940b 100644
--- a/dynaconf/vendor/box/from_file.py
+++ b/dynaconf/vendor/box/from_file.py
@@ -1,8 +1,8 @@
from json import JSONDecodeError
from pathlib import Path
from typing import Union
-from dynaconf.vendor.toml import TomlDecodeError
-from dynaconf.vendor.ruamel.yaml import YAMLError
+from toml import TomlDecodeError
+from ruamel.yaml import YAMLError
from .exceptions import BoxError
from .box import Box
from .box_list import BoxList
diff --git a/dynaconf/vendor_src/box/converters.py b/dynaconf/vendor_src/box/converters.py
index c9a2293..ae42bf6 100644
--- a/dynaconf/vendor_src/box/converters.py
+++ b/dynaconf/vendor_src/box/converters.py
@@ -9,9 +9,9 @@ import sys
import warnings
from pathlib import Path
-import dynaconf.vendor.ruamel.yaml as yaml
+import ruamel.yaml as yaml
from dynaconf.vendor.box.exceptions import BoxError, BoxWarning
-from dynaconf.vendor import toml
+import toml
BOX_PARAMETERS = ('default_box', 'default_box_attr', 'conversion_box',
diff --git a/dynaconf/vendor_src/box/from_file.py b/dynaconf/vendor_src/box/from_file.py
index 2e2a6ad..3f76819 100644
--- a/dynaconf/vendor_src/box/from_file.py
+++ b/dynaconf/vendor_src/box/from_file.py
@@ -3,8 +3,8 @@
from json import JSONDecodeError
from pathlib import Path
from typing import Union
-from dynaconf.vendor.toml import TomlDecodeError
-from dynaconf.vendor.ruamel.yaml import YAMLError
+from toml import TomlDecodeError
+from ruamel.yaml import YAMLError
from .exceptions import BoxError
diff --git a/tests/test_cli.py b/tests/test_cli.py
index 6693701..df44409 100644
--- a/tests/test_cli.py
+++ b/tests/test_cli.py
@@ -11,7 +11,7 @@ from dynaconf.cli import main
from dynaconf.cli import read_file_in_root_directory
from dynaconf.cli import WRITERS
from dynaconf.utils.files import read_file
-from dynaconf.vendor.click.testing import CliRunner
+from click.testing import CliRunner
runner = CliRunner()
base-commit: ebf7b17cffd5e08b212948bd8036d580718d5bf8
--
2.32.0

View File

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
set -eu set -eu
guix time-machine -C channels-lock.scm -- build -L . -L ./patches -f guix.scm guix time-machine -C channels-lock.scm -- build -L . -f guix.scm
guix time-machine -C channels-lock.scm -- system docker-image -L . -L ./patches --root=docker-image.tar.gz docker/image.scm guix time-machine -C channels-lock.scm -- system docker-image -L . --root=docker-image.tar.gz docker/image.scm