This commit is contained in:
xu0o0
2020-04-17 17:33:44 +08:00
committed by Dave Halter
parent 803c3cb271
commit f871f5e726

View File

@@ -128,15 +128,6 @@ class Script(object):
# An empty path (also empty string) should always result in no path. # An empty path (also empty string) should always result in no path.
self.path = os.path.abspath(path) if path else None self.path = os.path.abspath(path) if path else None
# TODO deprecate and remove sys_path from the Script API.
if sys_path is not None:
project._sys_path = sys_path
warnings.warn(
"Deprecated since version 0.17.0. Use the project API instead, "
"which means Script(project=Project(dir, sys_path=sys_path)) instead.",
DeprecationWarning,
stacklevel=2
)
if encoding is None: if encoding is None:
encoding = 'utf-8' encoding = 'utf-8'
else: else:
@@ -180,6 +171,15 @@ class Script(object):
project = get_default_project( project = get_default_project(
os.path.dirname(self.path) if path else None os.path.dirname(self.path) if path else None
) )
# TODO deprecate and remove sys_path from the Script API.
if sys_path is not None:
project._sys_path = sys_path
warnings.warn(
"Deprecated since version 0.17.0. Use the project API instead, "
"which means Script(project=Project(dir, sys_path=sys_path)) instead.",
DeprecationWarning,
stacklevel=2
)
self._inference_state = InferenceState( self._inference_state = InferenceState(
project, environment=environment, script_path=self.path project, environment=environment, script_path=self.path