{"library":"oslo-config","title":"Oslo Configuration API","description":"Oslo.config is a Python library from the OpenStack project that provides a robust API for parsing command-line arguments and .ini-style configuration files. It's a fundamental component for OpenStack services, offering a unified and flexible way to manage application settings. The library supports multiple configuration sources, including defaults, configuration files, environment variables, and command-line arguments, with a defined precedence order. The current version is 10.3.0, and it maintains an active release cadence tied to the OpenStack development cycle.","language":"python","status":"active","last_verified":"Fri May 15","install":{"commands":["pip install oslo.config"],"cli":{"name":"oslo-config-generator","version":"10.3.0"}},"imports":["from oslo_config import cfg"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import sys\nfrom oslo_config import cfg\nimport os\n\n# Define a configuration group and options\nCONF = cfg.CONF\ncommon_opts = [\n    cfg.StrOpt('bind_host', default='0.0.0.0', help='IP address to listen on'),\n    cfg.IntOpt('bind_port', default=8080, help='Port to listen on'),\n    cfg.BoolOpt('debug', default=False, help='Enable debug logging')\n]\n\n# Register options\nCONF.register_opts(common_opts, group='DEFAULT')\n\n# You can also register options in a specific group\napi_group = cfg.OptGroup(name='api', title='API Options')\nCONF.register_group(api_group)\napi_opts = [\n    cfg.StrOpt('url', default='http://localhost:8080', help='Base URL for the API'),\n    cfg.IntOpt('timeout', default=30, help='API request timeout in seconds')\n]\nCONF.register_opts(api_opts, group=api_group)\n\n# Example config file content (save as 'app.conf')\n# [DEFAULT]\n# bind_host = 127.0.0.1\n# debug = True\n#\n# [api]\n# url = https://api.example.com\n\n# Parse command line arguments and config files\n# For testing, we simulate args and a config file\n# In a real app, you'd use: CONF(sys.argv[1:], project='myproject', default_config_files=['/etc/myproject/app.conf'])\n\n# Create a dummy config file for demonstration\nconfig_file_path = 'app.conf'\nwith open(config_file_path, 'w') as f:\n    f.write('[DEFAULT]\\n')\n    f.write('bind_host = 127.0.0.1\\n')\n    f.write('debug = True\\n')\n    f.write('\\n[api]\\n')\n    f.write('url = https://api.example.com\\n')\n\n# Simulate CLI args (e.g., --debug=false --api-timeout=60)\nsys_args = ['program_name', '--config-file', config_file_path, '--api-timeout', '60']\n\n# oslo.config needs to be explicitly parsed. The first argument is the program name.\n# We use os.environ.get for security (e.g., if a secret was passed as an env var)\nCONF(args=sys_args[1:], project='myproject')\n\nprint(f\"Bind Host: {CONF.bind_host}\")\nprint(f\"Bind Port: {CONF.bind_port}\")\nprint(f\"Debug Mode: {CONF.debug}\")\nprint(f\"API URL: {CONF.api.url}\")\nprint(f\"API Timeout: {CONF.api.timeout}\")\n\n# Clean up the dummy config file\nos.remove(config_file_path)\n","lang":"python","description":"This quickstart demonstrates how to define configuration options, register them (both globally and within groups), and then parse values from a simulated configuration file and command-line arguments. It highlights the explicit parsing step required for oslo.config to load settings from external sources. The example also shows how to access the parsed configuration values.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":{"tag":null,"tag_description":null,"last_tested":"2026-05-15","installed_version":"10.0.0","pypi_latest":"10.3.0","is_stale":true,"summary":{"python_range":"3.10–3.9","success_rate":100,"avg_install_s":3,"avg_import_s":0.41,"wheel_type":"wheel"},"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.35,"mem_mb":7.3,"disk_size":"36.5M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.7,"import_time_s":0.25,"mem_mb":7.3,"disk_size":"38M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.58,"mem_mb":8.1,"disk_size":"39.7M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":2.8,"import_time_s":0.55,"mem_mb":8.1,"disk_size":"41M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.44,"mem_mb":7.9,"disk_size":"40.2M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.2,"import_time_s":0.55,"mem_mb":7.9,"disk_size":"41M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.4,"mem_mb":7.4,"disk_size":"39.9M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.3,"import_time_s":0.43,"mem_mb":7.4,"disk_size":"41M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":null,"import_time_s":0.26,"mem_mb":6,"disk_size":"35.7M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"oslo.config","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"clean","install_time_s":3.2,"import_time_s":0.25,"mem_mb":6,"disk_size":"37M"}]}}