Skip to content

tests: Fix python path in runtests.py#137

Closed
orbea wants to merge 1 commit intomanugarg:masterfrom
orbea:pymod
Closed

tests: Fix python path in runtests.py#137
orbea wants to merge 1 commit intomanugarg:masterfrom
orbea:pymod

Conversation

@orbea
Copy link
Contributor

@orbea orbea commented May 14, 2022

Note: Please review that I am solving this correctly, thanks!

In Gentoo the runtests.py script fails when it fails to determine the pacparser path.

This happens because py_ver expands to 3.9 when the expected directory ends in 39. This can be solved by replacing any periods in the string.

python ../tests/runtests.py
Traceback (most recent call last):
  File "/tmp/pacparser/src/../tests/runtests.py", line 31, in runtests
    pacparser_module_path = glob.glob(os.path.join(
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pacparser/src/../tests/runtests.py", line 81, in <module>
    main()
  File "/tmp/pacparser/src/../tests/runtests.py", line 78, in main
    runtests(pacfile, testdata, tests_dir)
  File "/tmp/pacparser/src/../tests/runtests.py", line 34, in runtests
    raise Exception('Tests failed. Could not determine pacparser path.')
Exception: Tests failed. Could not determine pacparser path.

Full build log: pacparser.pymod.log

Reproduction: make -C src pymod

@orbea
Copy link
Contributor Author

orbea commented May 14, 2022

Seems some of the CI tests aren't happy with this idea...

@orbea
Copy link
Contributor Author

orbea commented May 14, 2022

My second attempt works for CI and local builds at least.

In Gentoo the runtests.py script fails when it fails to determine the
pacparser path.

This happens because 'py_ver' expands to '3.9' when the expected
directory ends in '39'. This can be solved by replacing any periods in
the string.

python ../tests/runtests.py
Traceback (most recent call last):
  File "/tmp/pacparser/src/../tests/runtests.py", line 31, in runtests
    pacparser_module_path = glob.glob(os.path.join(
IndexError: list index out of range

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/tmp/pacparser/src/../tests/runtests.py", line 81, in <module>
    main()
  File "/tmp/pacparser/src/../tests/runtests.py", line 78, in main
    runtests(pacfile, testdata, tests_dir)
  File "/tmp/pacparser/src/../tests/runtests.py", line 34, in runtests
    raise Exception('Tests failed. Could not determine pacparser path.')
Exception: Tests failed. Could not determine pacparser path.
orbea added a commit to orbea/gentoo that referenced this pull request May 14, 2022
Bug: https://bugs.gentoo.org/793425
Upstream-PR: manugarg/pacparser#136
Upstream-PR: manugarg/pacparser#137
Signed-off-by: orbea <orbea@riseup.net>
orbea added a commit to orbea/gentoo that referenced this pull request May 14, 2022
Bug: https://bugs.gentoo.org/793425
Upstream-PR: manugarg/pacparser#136
Upstream-PR: manugarg/pacparser#137
Signed-off-by: orbea <orbea@riseup.net>
orbea added a commit to orbea/gentoo that referenced this pull request May 14, 2022
Bug: https://bugs.gentoo.org/793425
Upstream-PR: manugarg/pacparser#106
Upstream-PR: manugarg/pacparser#136
Upstream-PR: manugarg/pacparser#137
Upstream-Commit: manugarg/pacparser@c6258eb
Signed-off-by: orbea <orbea@riseup.net>
orbea added a commit to orbea/gentoo that referenced this pull request May 14, 2022
Bug: https://bugs.gentoo.org/793425
Upstream-PR: manugarg/pacparser#106
Upstream-PR: manugarg/pacparser#136
Upstream-PR: manugarg/pacparser#137
Upstream-Commit: manugarg/pacparser@c6258eb
Signed-off-by: orbea <orbea@riseup.net>
orbea added a commit to orbea/gentoo that referenced this pull request May 14, 2022
Bug: https://bugs.gentoo.org/793425
Upstream-PR: manugarg/pacparser#106
Upstream-PR: manugarg/pacparser#136
Upstream-PR: manugarg/pacparser#137
Upstream-Commit: manugarg/pacparser@c6258eb
Signed-off-by: orbea <orbea@riseup.net>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request May 15, 2022
Bug: https://bugs.gentoo.org/793425
Upstream-PR: manugarg/pacparser#106
Upstream-PR: manugarg/pacparser#136
Upstream-PR: manugarg/pacparser#137
Upstream-Commit: manugarg/pacparser@c6258eb
Signed-off-by: orbea <orbea@riseup.net>
Closes: #25487
Signed-off-by: Sam James <sam@gentoo.org>
@orbea orbea mentioned this pull request May 25, 2022
Comment on lines +29 to +42
ver = '.'.join([str(x) for x in sys.version_info[0:2]])
py_ver = [ver, ver.replace('.', '')]
try:
pacparser_module_path = glob.glob(os.path.join(
tests_dir, '..', 'src', 'pymod', 'build', 'lib*%s' % py_ver))[0]
module_path = glob.glob(os.path.join(
tests_dir, '..', 'src', 'pymod', 'build', 'lib*'))
module_found = False
for module in module_path:
for version in py_ver:
if module.endswith(version):
module_found = True
break
if module_found:
pacparser_module_path = module
break
Copy link

@smuzaffar smuzaffar Sep 21, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@orbea , I also got the same error while building with python 3.9. A simpel change like works

Suggested change
ver = '.'.join([str(x) for x in sys.version_info[0:2]])
py_ver = [ver, ver.replace('.', '')]
try:
pacparser_module_path = glob.glob(os.path.join(
tests_dir, '..', 'src', 'pymod', 'build', 'lib*%s' % py_ver))[0]
module_path = glob.glob(os.path.join(
tests_dir, '..', 'src', 'pymod', 'build', 'lib*'))
module_found = False
for module in module_path:
for version in py_ver:
if module.endswith(version):
module_found = True
break
if module_found:
pacparser_module_path = module
break
py_ver = "%s*" & sys.version_info[0]
try:
pacparser_module_path = glob.glob(os.path.join(
tests_dir, '..', 'src', 'pymod', 'build', 'lib*%s' % py_ver))[0]

so basically just using py_ver = "%s*" & sys.version_info[0] was enough.

@manugarg
Copy link
Owner

Thanks a lot @orbea for this PR. We don't need this anymore though -- #142 fixes both setup.py and runtests.py.

@manugarg manugarg closed this Feb 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants