Ticket #119 (closed enhancement: fixed)
paster create dies on project names with "-" characters (revisited)
| Reported by: | pjenvey@… | Owned by: | ianb |
|---|---|---|---|
| Priority: | high | Milestone: | 1.4.1 |
| Component: | exceptions | Version: | |
| Severity: | minor | Keywords: | |
| Cc: |
Description
This is very similar to #53, but it's a separate issue
pjenvey@bob:~/tmp$ paster create --template=pylons pylons-test
Selected and implied templates:
Pylons#pylons Pylons application template
Variables:
package: pylonstest
project: pylons-test
Creating template pylons
Creating directory ./pylons-test
Recursing into +package+
Creating ./pylons-test/pylonstest/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/__init__.py
Recursing into components
Creating ./pylons-test/pylonstest/components/
Copying empty.myt to ./pylons-test/pylonstest/components/empty.myt
Recursing into config
Creating ./pylons-test/pylonstest/config/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/config/__init__.py
Copying environment.py_tmpl to ./pylons-test/pylonstest/config/environment.py
Copying environment.py_tmpl__ to ./pylons-test/pylonstest/config/environment.py_tmpl__
Copying middleware.py_tmpl to ./pylons-test/pylonstest/config/middleware.py
Copying routing.py_tmpl to ./pylons-test/pylonstest/config/routing.py
Recursing into controllers
Creating ./pylons-test/pylonstest/controllers/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/controllers/__init__.py
Copying error.py_tmpl to ./pylons-test/pylonstest/controllers/error.py
Copying template.py_tmpl to ./pylons-test/pylonstest/controllers/template.py
Recursing into docs
Creating ./pylons-test/pylonstest/docs/
Copying index.txt_tmpl to ./pylons-test/pylonstest/docs/index.txt
Recursing into i18n
Creating ./pylons-test/pylonstest/i18n/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/i18n/__init__.py
Recursing into lib
Creating ./pylons-test/pylonstest/lib/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/lib/__init__.py
Copying app_globals.py_tmpl to ./pylons-test/pylonstest/lib/app_globals.py
Copying base.py_tmpl to ./pylons-test/pylonstest/lib/base.py
Copying helpers.py_tmpl to ./pylons-test/pylonstest/lib/helpers.py
Recursing into models
Creating ./pylons-test/pylonstest/models/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/models/__init__.py
Recursing into public
Creating ./pylons-test/pylonstest/public/
Copying index.html_tmpl to ./pylons-test/pylonstest/public/index.html
Recursing into templates
Creating ./pylons-test/pylonstest/templates/
Copying autohandler to ./pylons-test/pylonstest/templates/autohandler
Recursing into tests
Creating ./pylons-test/pylonstest/tests/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/tests/__init__.py
Recursing into functional
Creating ./pylons-test/pylonstest/tests/functional/
Copying __init__.py_tmpl to ./pylons-test/pylonstest/tests/functional/__init__.py
Copying test_models.py_tmpl to ./pylons-test/pylonstest/tests/test_models.py
Copying websetup.py_tmpl to ./pylons-test/pylonstest/websetup.py
Recursing into +project+.egg-info
Creating ./pylons-test/pylons-test.egg-info/
Copying paste_deploy_config.ini_tmpl_tmpl to ./pylons-test/pylons-test.egg-info/paste_deploy_config.ini_tmpl
Copying README.txt_tmpl to ./pylons-test/README.txt
Copying development.ini_tmpl to ./pylons-test/development.ini
Copying setup.cfg_tmpl to ./pylons-test/setup.cfg
Copying setup.py_tmpl to ./pylons-test/setup.py
Running /usr/local/bin/python setup.py egg_info
Adding Pylons to paster_plugins.txt
Traceback (most recent call last):
File "/usr/local/bin/paster", line 7, in ?
execfile(__file__)
File "/usr/home/pjenvey/src/python/paste/PasteScript/scripts/paster", line 18, in ?
command.run()
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/command.py", line 70, in run
invoke(command, command_name, options, args[1:])
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/command.py", line 110, in invoke
exit_code = runner.run(args)
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/command.py", line 205, in run
result = self.command()
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/create_distro.py", line 129, in command
pluginlib.add_plugin(egg_info_dir, spec)
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/pluginlib.py", line 20, in add_plugin
f = open(fn, 'w')
IOError: [Errno 2] No such file or directory: './pylons-test/pylons_test.egg-info/paster_plugins.txt'
#53's exception is (notice the hyphen):
IOError: [Errno 2] No such file or directory: './pylons-test/pylons-test.egg-info/paster_plugins.txt'
This one's is (notice the hyphen replaced with an underscore):
IOError: [Errno 2] No such file or directory: './pylons-test/pylons_test.egg-info/paster_plugins.txt'
#53 was partly resolved by using paste.script.pluginlib.egg_info_dir to determine the safe .egg-info dir name (replaces the hyphen with the underscore)
The new issue lies the standard for templating .egg-info directories. The standard is to use the '+project+' var (which allows hyphens). Pylons has had this '+project+.egg-info' dir for a while, and just recently PasteScript?'s basic_package template now has the same directory:
pjenvey@bob:~/src/python/pylons/pylons/templates$ ls -ald paster_template/+* drwxr-xr-x 13 pjenvey g13 512 Mar 7 14:05 paster_template/+package+/ drwxr-xr-x 3 pjenvey g13 512 Mar 27 15:21 paster_template/+project+.egg-info/
pjenvey@bob:~/src/python/paste/PasteScript/paste/script/templates$ ls -lad basic_package/+* drwxr-xr-x 3 pjenvey g13 512 Apr 28 09:42 basic_package/+package+/ drwxr-xr-x 3 pjenvey g13 512 Apr 28 09:42 basic_package/+project+.egg-info/
During 'paster create', these templates are interpreted, and my example 'pylons-test' project ends up with an egg-info directory that contains a hyphen: 'pylons-test.egg-info'
Obviously this is bad (as you already know setuptools discourages hyphens). When 'paster create' runs 'python setup.py egg_info' after our badly named .egg-info template is interpreted, we get the following warning:
------------------------------------------------------------------------------ Note: Your current .egg-info directory has a '-' in its name; this will not work correctly with "setup.py develop". Please rename pylons-test.egg-info to pylons_test.egg-info to correct this problem. ------------------------------------------------------------------------------
('paster create' hides this message from the user)
The egg_info command would have created a properly named .egg-info dir: 'pylons_test.egg-info', if the .egg-info dir created from the template didn't already exist. Since it does exist, it uses it and issues the warning
Then when paste.script.create_distro expects to encounter that properly named .egg-info dir without the hyphen, the exception is raised
The possible solutions I see:
o Have a proper egg-info template var. Then everyone has to rename their egg-info template dir to '+egg-info-name+.egg-info', or better yet have the var handle the entire name: '+project-egg-info+' or '+egg-info+'
o '+package+' appears to be safe (but I don't know this for sure). Use '+package+.egg-info' instead of '+project+.egg-info'. This might break setuptools if it's ever expecting the normal .egg-info name (maybe not, if it's automatically picking up our badly named dir). Nonetheless, this would give us a less correct egg-info dir name than the first solution (possibly correct enough)
o Implement a hack that detects the '+project+.egg-info' filename, and use a clean egg-info name instead of '+project+'. Nobody would have to change anything, but it's a kludge
Here's an output of PasteScript? trunk's basic template breaking as pylons does, now that it includes the '+project+.egg-info' dir:
pjenvey@bob:~/tmp$ paster create paste-test
Selected and implied templates:
PasteScript#basic_package A basic setuptools-enabled package
Variables:
package: pastetest
project: paste-test
Creating template basic_package
Creating directory ./paste-test
Recursing into +package+
Creating ./paste-test/pastetest/
Copying __init__.py to ./paste-test/pastetest/__init__.py
Recursing into +project+.egg-info
Creating ./paste-test/paste-test.egg-info/
Recursing into docs
Creating ./paste-test/docs/
Copying setup.cfg to ./paste-test/setup.cfg
Copying setup.py_tmpl to ./paste-test/setup.py
Running /usr/local/bin/python setup.py egg_info
Traceback (most recent call last):
File "/usr/local/bin/paster", line 7, in ?
execfile(__file__)
File "/usr/home/pjenvey/src/python/paste/PasteScript/scripts/paster", line 18, in ?
command.run()
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/command.py", line 70, in run
invoke(command, command_name, options, args[1:])
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/command.py", line 110, in invoke
exit_code = runner.run(args)
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/command.py", line 205, in run
result = self.command()
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/create_distro.py", line 133, in command
pluginlib.add_plugin(egg_info_dir, 'PasteScript')
File "/usr/home/pjenvey/src/python/paste/PasteScript/paste/script/pluginlib.py", line 20, in add_plugin
f = open(fn, 'w')
IOError: [Errno 2] No such file or directory: './paste-test/paste_test.egg-info/paster_plugins.txt'
