Skip to content
This repository was archived by the owner on Aug 11, 2023. It is now read-only.

Commit 74f4799

Browse files
committed
Fix a warning that "Could not determine version of package ccdproc" from
configuration system (since the __version__ member doesn't yet exist for the package when the configuration file is copied).
1 parent 3aee7d6 commit 74f4799

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

‎packagename/_astropy_init.py‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ def test(package=None, test_path=None, args=None, plugins=None,
111111
coverage=coverage, open_files=open_files, **kwargs)
112112

113113
if not _ASTROPY_SETUP_:
114-
115114
import os
116115
from warnings import warn
117116
from astropy import config
@@ -121,10 +120,19 @@ def test(package=None, test_path=None, args=None, plugins=None,
121120

122121
if not os.environ.get('ASTROPY_SKIP_CONFIG_UPDATE', False):
123122
config_dir = os.path.dirname(__file__)
124-
try:
125-
config.configuration.update_default_config(__package__, config_dir)
126-
except config.configuration.ConfigurationDefaultMissingError as e:
127-
wmsg = (e.args[0] + " Cannot install default profile. If you are "
128-
"importing from source, this is expected.")
129-
warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg))
130-
del e
123+
config_template = os.path.join(config_dir, __package__ + ".cfg")
124+
if os.path.isfile(config_template):
125+
try:
126+
config.configuration.update_default_config(
127+
__package__, config_dir, version=__version__)
128+
except TypeError as orig_error:
129+
try:
130+
config.configuration.update_default_config(
131+
__package__, config_dir)
132+
except config.configuration.ConfigurationDefaultMissingError as e:
133+
wmsg = (e.args[0] + " Cannot install default profile. If you are "
134+
"importing from source, this is expected.")
135+
warn(config.configuration.ConfigurationDefaultMissingWarning(wmsg))
136+
del e
137+
except:
138+
raise orig_error

0 commit comments

Comments
 (0)