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

setup.cfg: entry_points keys are made lowercase #1937

Closed
madig opened this issue Dec 10, 2019 · 6 comments · Fixed by #2580
Closed

setup.cfg: entry_points keys are made lowercase #1937

madig opened this issue Dec 10, 2019 · 6 comments · Fixed by #2580

Comments

@madig
Copy link
Contributor

madig commented Dec 10, 2019

This breaks when the entry point is actually case-sensitive.

  1. git clone https://github.com/pydoit/doit-plugin-sample
  2. Delete setup.py, use the following setup.cfg:
[metadata]
name = doit-plugin-sample
description = a simple doit command plugin

[options]
py_modules = 
    doit_sample_cmd
install_requires = 
    doit

[options.entry_points]
doit.COMMAND =
    plug_sample = doit_sample_cmd:SampleCmd
  1. Use this pyproject.toml:
[build-system]
requires = ["setuptools>=30.3.0", "wheel"]
  1. pip install . inside a venv.

Inspecting venv/*/site-packages/doit_plugin_sample-0.0.0.dist-info/entry_points.txt:

[doit.command]
plug_sample = doit_sample_cmd:SampleCmd

This will not work, as the entry point is doit.COMMAND.

@jaraco
Copy link
Member

jaraco commented Feb 22, 2021

This does look like a bug. setup.cfg should avoid changing the case of entry point names.

I'll start by replicating your finding. I'll fork the project and add the prescribed changes to the fork and then determine how it doesn't work (how it fails).

@jaraco
Copy link
Member

jaraco commented Feb 22, 2021

I created the repro as jaraco/doit-plugin-sample@setuptools/1937.

draft $ git clone gh://pydoit/doit-plugin-sample
Cloning into 'doit-plugin-sample'...
remote: Enumerating objects: 7, done.
remote: Counting objects: 100% (7/7), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 7 (delta 1), reused 7 (delta 1), pack-reused 0
Receiving objects: 100% (7/7), done.
Resolving deltas: 100% (1/1), done.
draft $ cd doit-plugin-sample/
doit-plugin-sample master $ hub fork
Updating jaraco
From https://github.com/pydoit/doit-plugin-sample
 * [new branch]      master     -> jaraco/master
new remote: jaraco
doit-plugin-sample master $ git checkout -b setuptools/1937
Switched to a new branch 'setuptools/1937'
doit-plugin-sample setuptools/1937 $ git rm setup.py
rm 'setup.py'
doit-plugin-sample setuptools/1937 $ cat > setup.cfg
[metadata]
name = doit-plugin-sample
description = a simple doit command plugin

[options]
py_modules = 
    doit_sample_cmd
install_requires = 
    doit

[options.entry_points]
doit.COMMAND =
    plug_sample = doit_sample_cmd:SampleCmd
doit-plugin-sample setuptools/1937 $ cat > pyproject.toml
[build-system]
requires = ["setuptools>=30.3.0", "wheel"]
doit-plugin-sample setuptools/1937 $ git add .
doit-plugin-sample setuptools/1937 $ git commit -a -m "Alter project as described in pypa/setuptools#1937"
[setuptools/1937 6a47e86] Alter project as described in pypa/setuptools#1937
 2 files changed, 15 insertions(+), 17 deletions(-)
 create mode 100644 pyproject.toml
 rewrite setup.py (99%)
 mode change 100755 => 100644
doit-plugin-sample setuptools/1937 $ git push jaraco
Enumerating objects: 6, done.
Counting objects: 100% (6/6), done.
Delta compression using up to 8 threads
Compressing objects: 100% (4/4), done.
Writing objects: 100% (4/4), 605 bytes | 605.00 KiB/s, done.
Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
remote: 
remote: Create a pull request for 'setuptools/1937' on GitHub by visiting:
remote:      https://github.com/jaraco/doit-plugin-sample/pull/new/setuptools/1937
remote: 
To github.com:jaraco/doit-plugin-sample.git
 * [new branch]      setuptools/1937 -> setuptools/1937

With that, I'm able to demonstrate how the doit plugin works when running under the HEAD of the repo (7f56bc5):

draft $ touch dodo.py
draft $ pip-run -q --use-pep517 doit git+https://github.com/pydoit/doit-plugin-sample@7f56bc5 setuptools -- -m doit plug_sample
  WARNING: Did not find branch or tag '7f56bc5', assuming revision or ref.
This sample command does nothing!

And fails when running under the fork version:

draft $ pip-run -q --use-pep517 doit git+https://github.com/jaraco/doit-plugin-sample@setuptools/1937 setuptools -- -m doit plug_sample
ERROR: Invalid parameter: "plug_sample". Must be a command, task, or a target.
Type "-m help" to see available commands.
Type "-m list" to see available tasks.

@jaraco
Copy link
Member

jaraco commented Feb 22, 2021

Note, I'm using pip-run to quickly facilitate swapping out different versions of doit-plugin-sample. I have to use --use-pep517 doit or its dependencies have an implicit dependency on setuptools. And I have to include setuptools because doit has an undeclared dependency on setuptools and fails silently if it's not present.

@jaraco
Copy link
Member

jaraco commented Feb 22, 2021

The problem can be more easily elicited with just the plugin by trying to load the plugin directly:

draft $ pip-run -q setuptools git+https://github.com/jaraco/doit-plugin-sample@setuptools/1937 -- -c "import pkg_resources; ep, = pkg_resources.iter_entry_points('doit.COMMAND'); print(ep)"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ValueError: not enough values to unpack (expected 1, got 0)

@jaraco
Copy link
Member

jaraco commented Feb 22, 2021

I believe it would be best if Setuptools could honor the case of the entry points as indicated in setup.cfg.

@melissa-kun-li
Copy link
Contributor

I'll take this on :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants