Skip to content

Commit

Permalink
Problem: Does not complain for typo in 'scripts'
Browse files Browse the repository at this point in the history
Solution: Warn when a script name passed in 'scripts' argument of easy_install.scripts
is not defined in egg entry points.
  • Loading branch information
gotcha committed May 21, 2020
1 parent 202f679 commit f5eec30
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Change History
3.0.0a2 (unreleased)
====================

- Warn when a script name passed in 'scripts' argument of easy_install.scripts
is not defined in egg entry points.

- Show only once pip warning about python version.

- Better patch for ``pkg_resources.Distribution.hashcmp`` performance.
Expand Down
15 changes: 15 additions & 0 deletions src/zc/buildout/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,10 @@ def scripts(reqs, working_set, executable, dest=None,
else:
entry_points.append(req)

entry_points_names = []

for name, module_name, attrs in entry_points:
entry_points_names.append(name)
if scripts is not None:
sname = scripts.get(name)
if sname is None:
Expand All @@ -1219,6 +1222,18 @@ def scripts(reqs, working_set, executable, dest=None,
initialization, rpsetup)
)

# warn when a script name passed in 'scripts' argument
# is not defined in an entry point.
if scripts is not None:
for name, target in scripts.items():
if name not in entry_points_names:
if name == target:
logger.warning("Could not generate script '%s' as it is not "
"defined in the egg entry points.", name)
else:
logger.warning("Could not generate script '%s' as script "
"'%s' is not defined in the egg entry points.", name, target)

for name, contents in distutils_scripts:
if scripts is not None:
sname = scripts.get(name)
Expand Down
42 changes: 42 additions & 0 deletions zc.recipe.egg_/src/zc/recipe/egg/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,48 @@ You can also control the name used for scripts:
- buildout
- foo

If a wrong script name is provided, buildout tells about it:

>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
...
... [demo]
... recipe = zc.recipe.egg
... find-links = %(server)s
... index = %(server)s/index
... scripts = undefined
... """ % dict(server=link_server))

>>> print system(buildout),
Uninstalling demo.
Installing demo.
Could not generate script 'undefined' as it is not defined in the egg entry points.

>>> ls(sample_buildout, 'bin')
- buildout

>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
...
... [demo]
... recipe = zc.recipe.egg
... find-links = %(server)s
... index = %(server)s/index
... scripts = foo=undefined
... """ % dict(server=link_server))

>>> print system(buildout),
Uninstalling demo.
Installing demo.
Could not generate script 'foo' as script 'undefined' is not defined in the egg entry points.

>>> ls(sample_buildout, 'bin')
- buildout

Specifying extra script paths
-----------------------------

Expand Down

0 comments on commit f5eec30

Please sign in to comment.