cmds.projects: Two fixes to Python search path generation #49
2 changed files with 12 additions and 4 deletions
|
|
@ -19,12 +19,17 @@ class Fmt(Enum):
|
||||||
|
|
||||||
class CmdCreateFile(Cmd): # export
|
class CmdCreateFile(Cmd): # export
|
||||||
|
|
||||||
def __jw_required(self, module: str | None = None) -> list[str]:
|
def __jw_required(
|
||||||
|
self,
|
||||||
|
*,
|
||||||
|
module: str | None = None,
|
||||||
|
include_self: bool = False,
|
||||||
|
) -> list[str]:
|
||||||
if module is None:
|
if module is None:
|
||||||
module = self.app.args.module
|
module = self.app.args.module
|
||||||
if module is None:
|
if module is None:
|
||||||
raise Exception('Can\'t get required packages without module name')
|
raise Exception('Can\'t get required packages without module name')
|
||||||
return pkg_relations(
|
ret = pkg_relations(
|
||||||
self.app,
|
self.app,
|
||||||
rel_type = 'requires',
|
rel_type = 'requires',
|
||||||
flavours = ['run'],
|
flavours = ['run'],
|
||||||
|
|
@ -37,6 +42,9 @@ class CmdCreateFile(Cmd): # export
|
||||||
hide_self = False,
|
hide_self = False,
|
||||||
hide_jw_pkg = False,
|
hide_jw_pkg = False,
|
||||||
)
|
)
|
||||||
|
if include_self and module not in ret:
|
||||||
|
ret = [module, *ret]
|
||||||
|
return ret
|
||||||
|
|
||||||
def __render(
|
def __render(
|
||||||
self,
|
self,
|
||||||
|
|
@ -65,7 +73,7 @@ class CmdCreateFile(Cmd): # export
|
||||||
|
|
||||||
def render_pyright(self, module: str, extra_fields: RenderValues) -> str:
|
def render_pyright(self, module: str, extra_fields: RenderValues) -> str:
|
||||||
extra_paths = []
|
extra_paths = []
|
||||||
for m in self.__jw_required():
|
for m in self.__jw_required(include_self = True):
|
||||||
path = self.app.find_dir(m, search_subdirs = ['src/python', 'tools/python'])
|
path = self.app.find_dir(m, search_subdirs = ['src/python', 'tools/python'])
|
||||||
if path is None:
|
if path is None:
|
||||||
log(WARNING, f'No project directory for module "{m}"')
|
log(WARNING, f'No project directory for module "{m}"')
|
||||||
|
|
|
||||||
|
|
@ -55,4 +55,4 @@ class CmdPythonpath(Cmd): # export
|
||||||
path = f'{args.path_component_prefix}{path}'
|
path = f'{args.path_component_prefix}{path}'
|
||||||
out.append(path)
|
out.append(path)
|
||||||
if out:
|
if out:
|
||||||
print(args.delimiter.join(out))
|
print(args.delimiter.join(reversed(out)))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue