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

The distlib script maker does not parse entry points correctly #203

Closed
1 task done
FlavioAmurrioCS opened this issue Jul 17, 2023 · 4 comments
Closed
1 task done

Comments

@FlavioAmurrioCS
Copy link

Description

I created some CLI tools for myself a while back where I defined the command I'll invoke as , or something prefixed with a , such as ,docker to make it easier to find the when tab completing(Idea I got from one of Brandon Rhodes' talks). Since I make updates often and want it to be available globally, I installed my package as I use pipx I installed my package with pipx install --editable . and it always worked and got used it.

I recently noticed that if I install the package without the --editable flag it now fails with the following error

TypeError: expected str, bytes or os.PathLike object, not NoneType

Doing some digging around I found the following:

When installing normally (ie : pip install package) which uses a regex and capture groups to parse the console_script specification. Since , is not part of the capture group name is now None and therefore causing the error above when getting to ScriptMaker._make_script . For the ,docker command it now becomes docker since the , was not captured.
https://github.com/pypa/pip/blob/b252ad819bc7b998508a7ed8789b60dceddfd603/src/pip/_vendor/distlib/util.py#L710-L743

When installing as editable(ie : pip install --editable package), the following snippet is in charge parsing the console_scripts
https://github.com/pypa/pip/blob/b252ad819bc7b998508a7ed8789b60dceddfd603/src/pip/_internal/metadata/pkg_resources.py#L185-L189

Example Entry Point

[options.entry_points]
console_scripts =
    , = comma.cli.main:app_main
    ,docker = comma.cli.docker:app_docker

Documentation mentions name may contain any characters except =, but it cannot start or end with any whitespace character, or start with [. which suggest , should be valid.

The name may contain any characters except =, but it cannot start or end with any whitespace character, or start with [. For new entry points, it is recommended to use only letters, numbers, underscores, dots and dashes (regex [\w.-]+).

Expected behavior

Comma should be capture in the ENTRY_RE regex name capture group to allow for , to become a valid command.

pip version

23.0.1

Python version

3.11

OS

Mac

How to Reproduce

git clone https://github.com/FlavioAmurrioCS/commabug.git /tmp/comma
virtuealenv /tmp/venv
/tmp/venv/bin/pip install /tmp/comma/  # Will show error

Output

No response

Code of Conduct

@FlavioAmurrioCS
Copy link
Author

Was told to report issue issue here. (Original Issue pypa/pip#12151)

@vsajip vsajip closed this as completed in ac36501 Jul 17, 2023
@FlavioAmurrioCS
Copy link
Author

Thanks!

@FlavioAmurrioCS
Copy link
Author

@vsajip What is the process for this change to make it to the latest pip? I saw in the other conversation(pypa/pip#12151) that this fix was part of distlib 0.3.7 but have yet to see the fix propagate to pip.

@vsajip
Copy link
Collaborator

vsajip commented Oct 16, 2023

I see you've asked on the pip issue tracker too. The releases of pip are entirely up to them. They apparently plan to do a release this month, but from what I can see they're still using distlib 0.3.6.

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

No branches or pull requests

2 participants