Giter Club home page Giter Club logo

Comments (10)

bertonha avatar bertonha commented on August 14, 2024

👍 This will solve my problems with docker and local run

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

from python-decouple.

bertonha avatar bertonha commented on August 14, 2024

@henriquebastos in my local machine I use sqlite to develop and on docker use mysql.
in my .env was DB=sqlite.
When I start docker the file .env "override" the docker environment variables.

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

Christofer, idealy you should use a different/specific .env file for
every instance, and define defaults (fallbacks) for some options on
your settings.py.

.env is not the project config file (that's the settings.py). The
.env is the instance config file.

from python-decouple.

osantana avatar osantana commented on August 14, 2024

One problem I have is that I use .env with my local settings during development (eg. DATABASE_URL = mysql://...@localhost /...) and I also use Docker to run integration tests on my machine. These tests need specific settings provided by envvars (eg. DATABASE_URL = mysql://...@dbserver/...).

The problem happens when I run the tests in Docker and the .env file appears inside the container. In this case python-decouple use this file instead of envvars provided.

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

Got it. it make sense to me that decouple supports the unix style of overriding options.

Should this also happen with .ini files?

@osantana can you update a PR with tests?

from python-decouple.

osantana avatar osantana commented on August 14, 2024

Yes, I can do it.

But this change is backward incompatible, so, it could break something. Is it ok for you?

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

Yes. I understand we're changin the priorities on how decouple
evaluates an option. Today, for .env we use environ as a fallback.
This change will use environ to override .env, aligning decouple
with the common unix behavior.

Right now (without actual code), I don't see reasons why we shouldn't do
it. And I'm +1 for that.

About the PR:

  1. Make sure you adapt/extend the current tests for this new behavior. It
    will be easier to review the patch.
  2. Note that decouple should still raise the undefined exception when
    (1) an option does not exists (either on file and environ) and (2) no
    default parameter was passed to config.

Thank you for doing this. :)

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

Just released version 3.0 supporting environment variables overriding config files. This closes #10 and #17.

I've experimented with the RapositoryChain patch and with inheritance. In the end it felt like yak shaving and I simply made RepositoryEnv and RepositoryIni explicitly check on os.environ.

From this issue we're still pending the path search. I've thought about it and I would be satisfied with an inversion of dependency of the search path on AutoConfig and Config.

So by default we could search from the settings.py path, but users could instantiate their own AutoConfig or Config with a specific path, like: config = AutoConfig('my/custom/search/path/')

However, since I've never needed this I wasn't sure this was an actual useful feature.

from python-decouple.

henriquebastos avatar henriquebastos commented on August 14, 2024

@osantana the main clame of this issue is already on previous version, so I'm closing the issue.

from python-decouple.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.