开发者

Python environment management (devel/release)

I have released a package within my workplace; it is used by ~10 people. I have a very quick develop/test/release cycle (sometimes twice a day), and I am starting to suffer from an increased disorder in my environments. I want to manage this environment with tools such as virtualenv and setuptools, but I don't seem to get where I want.

For instance, I want to use a "test" database on development, but release to the "real" database. Something along the lines of:

if env == "devel":
 dbpath = "/path/to/devel.db"
if env == "release":
 dbpath = "/path/to/real.db"

Similarly, I have several configuration files with different parameters for development and release (today I forgot to change one, and I mailed the entire team dozens of emails!).

I want the code to remain clean and separated, so I would prefer not to code a solution like开发者_如何学Python the one presented above.

So, how would you create a workflow to manage this? I would prefer not to rely on environment variables and __file__ statements (but maybe I should?).

Apologies. I know this is not a very clever question, but I want to use the tools at my disposal in a reliable way.


I would prefer not to rely on environment variables and file statements (but maybe I should?).

You should.

You should use three things.

  1. Environment variables.

  2. Configuration files.

  3. Command-line parameters.

Just like every other command-line program.

If this is am imported module, not a program, then it should have NO configuration of any kind. All of the scripts which import your module must provide all configuration as arguments and parameters

There are no circumstances under which an imported module should have a configuration of its own.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜