Skip to content
This repository has been archived by the owner on Jan 13, 2024. It is now read-only.

Commit

Permalink
Better guess for module name
Browse files Browse the repository at this point in the history
  • Loading branch information
sdpython committed Mar 12, 2020
1 parent d053b4e commit 808bcb6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/pyquickhelper/pycode/setup_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,20 @@ def _update_version(v, nv):
if os.path.isdir(folder):
src = os.path.join(folder, 'src')
if module_name is None:
module_name = os.path.split(folder)[-1]
setu = os.path.join(folder, 'setup.py')
if not os.path.exists(setu):
raise FileNotFoundError(
"Unable to find 'setup.py' in '{}' and module_name is None.".format(
folder, filename))
reg = re.compile("(project_var_name = ['\\\"]([0-9.]+)['\\\"])")
with open(setu, 'r', encoding='utf-8') as f:
cst = f.read()
find = reg.findall(cst)
if len(find) == 0:
raise FileNotFoundError(
"Unable to find 'project_var_name' in 'setup.py' in '{}' "
"and module_name is None.".format(folder, filename))
module_name = find[0][1]
if os.path.exists(src) and module_name is not None:
filename = os.path.join(src, module_name, '__init__.py')
elif module_name is not None:
Expand Down

0 comments on commit 808bcb6

Please sign in to comment.