Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw a better error message when a malformed requirement is being parsed #106

Closed
jayceslesar opened this issue Jul 8, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@jayceslesar
Copy link

jayceslesar commented Jul 8, 2022

Is your feature request related to a problem? Please describe.

I had a malformed requirement of

git+ssh://git@github.com/me/my-project@my-branch

which is a malformed requirement (and should be)

my-project @ git+ssh://git@github.com/me/my-project@my-branch

and an error message of

Traceback (most recent call last):
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/_vendor/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/_vendor/pyparsing/core.py", line 1134, in parse_string
    raise exc.with_traceback(None)
pdm.pep517._vendor.pyparsing.exceptions.ParseException: Expected string_end, found '+'  (at char 3), (line:1, col:4)

Describe the solution you'd like

A better error message that says something like "invalid requirement at location (location) or something "

@jayceslesar jayceslesar added the enhancement New feature or request label Jul 8, 2022
@frostming
Copy link
Contributor

frostming commented Jul 8, 2022

Can you show the full traceback? I would like to the see caller stack

@jayceslesar
Copy link
Author

jayceslesar commented Jul 8, 2022

Traceback (most recent call last):
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/_vendor/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/_vendor/pyparsing/core.py", line 1134, in parse_string
    raise exc.with_traceback(None)
pdm.pep517._vendor.pyparsing.exceptions.ParseException: Expected string_end, found '+'  (at char 3), (line:1, col:4)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 363, in <module>
    main()
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 345, in main
    json_out['return_val'] = hook(**hook_input['kwargs'])
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pep517/in_process/_in_process.py", line 261, in build_wheel
    return _build_backend().build_wheel(wheel_directory, config_settings,
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/api.py", line 72, in build_wheel
    return Path(builder.build(wheel_directory)).name
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/wheel.py", line 78, in build
    self._write_metadata(zip_file)
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/wheel.py", line 151, in _write_metadata
    self._write_metadata_file(f)
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/wheel.py", line 300, in _write_metadata_file
    fp.write(self.format_pkginfo())
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/base.py", line 415, in format_pkginfo
    for extra, reqs in sorted(meta.requires_extra.items()):
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/metadata.py", line 273, in requires_extra
    parsed = Requirement(r)
  File "/tmp/pdm-build-env-_3xcxqno-shared/lib/python3.8/site-packages/pdm/pep517/_vendor/packaging/requirements.py", line 104, in __init__
    raise InvalidRequirement(
pdm.pep517._vendor.packaging.requirements.InvalidRequirement: Parse error at "'+ssh://g'": Expected string_end
Install my-project 2.0.1.dev33+g0154204 failed
Traceback (most recent call last):
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/bin/pdm", line 8, in <module>
    sys.exit(main())
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/core.py", line 232, in main
    return Core().main(args)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/core.py", line 167, in main
    raise cast(Exception, err).with_traceback(traceback)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/core.py", line 162, in main
    f(options.project, options)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/cli/commands/sync.py", line 33, in handle
    actions.do_sync(
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/cli/actions.py", line 209, in do_sync
    handler.synchronize()
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/installers/synchronizers.py", line 389, in synchronize
    self.install_candidate(self_key)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/installers/synchronizers.py", line 207, in install_candidate
    self.manager.install(can)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/installers/manager.py", line 39, in install
    installer(prepared.build(), self.environment, prepared.direct_url())
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/models/candidates.py", line 331, in build
    self.wheel = builder.build(build_dir, metadata_directory=self._metadata_dir)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/builders/wheel.py", line 28, in build
    filename = self._hook.build_wheel(out_dir, config_settings, metadata_directory)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pep517/wrappers.py", line 208, in build_wheel
    return self._call_hook('build_wheel', {
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pep517/wrappers.py", line 322, in _call_hook
    self._subprocess_runner(
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 246, in subprocess_runner
    return log_subprocessor(cmd, cwd, extra_environ=env)
  File "/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pdm/builders/base.py", line 87, in log_subprocessor
    raise BuildError(
pdm.exceptions.BuildError: Call command ['/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/bin/python', '/tmp/builds/H7BWEQYC/2/my-code/my-project/venv/lib/python3.8/site-packages/pep517/in_process/_in_process.py', 'build_wheel', '/tmp/tmpp2ja5nb3'] return non-zero status(1).

@frostming frostming transferred this issue from pdm-project/pdm Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants