Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6658133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T01:51:21+00:00 2026-05-26T01:51:21+00:00

In development mode, I have the following directory tree : | my_project/ | setup.py

  • 0

In development mode, I have the following directory tree :

| my_project/
| setup.py
| my_project/
    | __init__.py
    | main.py
    | conf/
        | myproject.conf

I use ConfigParser to parse the myproject.conf file.

In my code, it’s easy to load the file with a good path : my_project/conf/myproject.conf

The problem is : When I install my project using the setup.py, the configuration file are situated (thanks to setup.py) in the /etc/my_project/myproject.conf and my application in the /usr/lib/python<version>/site-packages/my_project/.

How can I refer my my_project/conf/myproject.conf file in my project in “production” mode, and refer to the local file (my_project/conf/myproject.conf) in “devel” mode.

In addition, I would like to be portable if possible (Work on windows for example).

What’s the good practice to do that ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T01:51:21+00:00Added an answer on May 26, 2026 at 1:51 am

    Have you seen how configuration files work? Read up on “rc” files, as they’re sometimes called. “bashrc”, “vimrc”, etc.

    There’s usually a multi-step search for the configuration file.

    1. Local directory. ./myproject.conf.

    2. User’s home directory (~user/myproject.conf)

    3. A standard system-wide directory (/etc/myproject/myproject.conf)

    4. A place named by an environment variable (MYPROJECT_CONF)

    The Python installation would be the last place to look.

    config= None
    for loc in os.curdir, os.path.expanduser("~"), "/etc/myproject", os.environ.get("MYPROJECT_CONF"):
        try: 
            with open(os.path.join(loc,"myproject.conf")) as source:
                config.readfp( source )
        except IOError:
            pass
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In development I use jetty as the servlet container. I have the following development
I have a rails application, running in development mode ( with a sqlite database
I have the following setup: Code on my local machine (OS X) shared as
I'm particularly fond of the way the following SAAS companies have enabled application development
We have our gwt application working fine on the development mode with gwt 2.4rc1
I'm using webrick to run my rails app in development mode. The page includes
Debug mode in MigLayout is quite powerful option for development and debugging. It is
During development I have to clear cache in Firefox all the time in order
I have a successful Rails 3.0.x project with the following subset of Gems in
I usually use Geany or Hi-Tide under Debian (GNU/Linux) for firmware development, mainly C

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.