I am trying out the Pyramid tutorial example and it's built-in setup.py file appears to be set up to add static files to the egg file but it doesn't actually happen. I've done some search and toying with the settings but I'm unable to get the desired behavio开发者_StackOverflow社区r.
- There is a MANIFEST.in file, it contains a line:
include *.ini
include_package_data
is set toTrue
package_data
contains the entry:{ '' : ['*.ini'] }'
It doesn't seem to matter what setting I change, there appears to be no effect. I should probably mention the desired files are listed in the SOURCES.txt file.
The files I'd like to have included are in the root of the distribution's directory (where setup.py resides).
What do I seem to be missing here?
The top level .ini files of pyramid are "non-package data files", i.e. there is no __init__.py
in the directory they reside. This somehow means that they will not be included in the egg archive generated with setup.py bdist_egg
, even if your conditions 1 and 2 are satisfied.
To include such "non-package data files", I think the cleanest way is to add them as data_files
to setup()
, e.g.
setup(
...
data_files=[
('', [
'development.ini',
'production.ini',
]),
],
zip_safe=False,
...
)
Then, the files will be included in the egg archive at the top level, retrievable with:
import os
import pkg_resources
dist = pkg_resources.get_distribution('MyApp')
config_file = os.path.join(dist.location, 'production.ini')
Not sure what's going on there, but if I do "setup.py sdist" on a freshly built Pyramid scaffold, this is where I get to.
Creating the project:
[chrism@thinko env26]$ bin/paster create -t pyramid_routesalchemy MyApp
Selected and implied templates:
pyramid#pyramid_routesalchemy pyramid SQLAlchemy project using url dispatch (no traversal)
Variables:
egg: MyApp
package: myapp
project: MyApp
Creating template pyramid_routesalchemy
Creating directory ./MyApp
Recursing into +package+
Creating ./MyApp/myapp/
Copying __init__.py_tmpl to ./MyApp/myapp/__init__.py
Copying models.py to ./MyApp/myapp/models.py
Recursing into static
Creating ./MyApp/myapp/static/
Copying favicon.ico to ./MyApp/myapp/static/favicon.ico
Copying footerbg.png to ./MyApp/myapp/static/footerbg.png
Copying headerbg.png to ./MyApp/myapp/static/headerbg.png
Copying ie6.css to ./MyApp/myapp/static/ie6.css
Copying middlebg.png to ./MyApp/myapp/static/middlebg.png
Copying pylons.css to ./MyApp/myapp/static/pylons.css
Copying pyramid-small.png to ./MyApp/myapp/static/pyramid-small.png
Copying pyramid.png to ./MyApp/myapp/static/pyramid.png
Copying transparent.gif to ./MyApp/myapp/static/transparent.gif
Recursing into templates
Creating ./MyApp/myapp/templates/
Copying mytemplate.pt_tmpl to ./MyApp/myapp/templates/mytemplate.pt
Copying tests.py_tmpl to ./MyApp/myapp/tests.py
Copying views.py_tmpl to ./MyApp/myapp/views.py
Copying CHANGES.txt_tmpl to ./MyApp/CHANGES.txt
Copying MANIFEST.in_tmpl to ./MyApp/MANIFEST.in
Copying README.txt_tmpl to ./MyApp/README.txt
Copying development.ini_tmpl to ./MyApp/development.ini
Copying production.ini_tmpl to ./MyApp/production.ini
Copying setup.cfg_tmpl to ./MyApp/setup.cfg
Copying setup.py_tmpl to ./MyApp/setup.py
Welcome to Pyramid. Sorry for the convenience.
Running /home/chrism/projects/pyramid/env26/bin/python setup.py egg_info
Running sdist:
[chrism@thinko env26]$ cd MyApp/
[chrism@thinko MyApp]$ ../bin/python setup.py sdist
running sdist
running egg_info
writing requirements to MyApp.egg-info/requires.txt
writing MyApp.egg-info/PKG-INFO
writing top-level names to MyApp.egg-info/top_level.txt
writing dependency_links to MyApp.egg-info/dependency_links.txt
writing entry points to MyApp.egg-info/entry_points.txt
writing requirements to MyApp.egg-info/requires.txt
writing MyApp.egg-info/PKG-INFO
writing top-level names to MyApp.egg-info/top_level.txt
writing dependency_links to MyApp.egg-info/dependency_links.txt
writing entry points to MyApp.egg-info/entry_points.txt
writing paster_plugins to MyApp.egg-info/paster_plugins.txt
reading manifest file 'MyApp.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '*.rst'
warning: no files found matching '*.jpg' under directory 'myapp'
warning: no files found matching '*.txt' under directory 'myapp'
warning: no files found matching '*.mak' under directory 'myapp'
w arning: no files found matching '*.mako' under directory 'myapp'
warning: no files found matching '*.js' under directory 'myapp'
warning: no files found matching '*.html' under directory 'myapp'
warning: no files found matching '*.xml' under directory 'myapp'
writing manifest file 'MyApp.egg-info/SOURCES.txt'
warning: sdist: missing required meta-data: url
warning: sdist: missing meta-data: either (author and author_email) or (maintainer and maintainer_email) must be supplied
creating MyApp-0.0
creating MyApp-0.0/MyApp.egg-info
creating MyApp-0.0/myapp
creating MyApp-0.0/myapp/static
creating MyApp-0.0/myapp/templates
making hard links in MyApp-0.0...
hard linking CHANGES.txt -> MyApp-0.0
hard linking MANIFEST.in -> MyApp-0.0
hard linking README.txt -> MyApp-0.0
hard linking development.ini -> MyApp-0.0
hard linking production.ini -> MyApp-0.0
hard linking setup.cfg -> MyApp-0.0
hard linking setup.py -> MyApp-0.0
hard linking MyApp.egg-info/PKG-INFO -> MyApp-0.0/MyApp.egg-info
hard linking MyApp.egg-info/SOURCES.txt -> MyApp-0.0/MyApp.egg-info
hard linking MyApp.egg-info/dependency_links.txt -> MyApp-0.0/MyApp.egg-info
hard linking MyApp.egg-info/entry_points.txt -> MyApp-0.0/MyApp.egg-info
hard linking MyApp.egg-info/not-zip-safe -> MyApp-0.0/MyApp.egg-info
h ard linking MyApp.egg-info/paster_plugins.txt -> MyApp-0.0/MyApp.egg-info
hard linking MyApp.egg-info/requires.txt -> MyApp-0.0/MyApp.egg-info
hard linking MyApp.egg-info/top_level.txt -> MyApp-0.0/MyApp.egg-info
hard linking myapp/__init__.py -> MyApp-0.0/myapp
hard linking myapp/models.py -> MyApp-0.0/myapp
hard linking myapp/tests.py -> MyApp-0.0/myapp
hard linking myapp/views.py -> MyApp-0.0/myapp
hard linking myapp/static/favicon.ico -> MyApp-0.0/myapp/static
hard linking myapp/static/footerbg.png -> MyApp-0.0/myapp/static
hard linking myapp/static/headerbg.png -> MyApp-0.0/myapp/static
hard linking myapp/static/ie6.css -> MyApp-0.0/myapp/static
hard linking myapp/static/middlebg.png -> MyApp-0.0/myapp/static
hard linking myapp/static/pylons.css -> MyApp-0.0/myapp/static
hard linking myapp/static/pyramid-small.png -> MyApp-0.0/myapp/static
hard linking myapp/static/pyramid.png -> MyApp-0.0/myapp/static
hard linking myapp/static/transparent.gif -> MyApp-0.0/myapp/static
hard linking myapp/templates/mytemplate.pt -> MyApp-0.0/myapp/templates
copying setup.cfg -> MyApp-0.0
Writing MyApp-0.0/setup.cfg
creating dist
tar -cf dist/MyApp-0.0.tar MyApp-0.0
gzip -f9 dist/MyApp-0.0.tar
removing 'MyApp-0.0' (and everything under it)
The .ini files that were created in the scaffold are put into the resulting tarball:
[chrism@thinko MyApp]$ tar tvzf dist/MyApp-0.0.tar.gz
drwxr-xr-x chrism/chrism 0 2011-07-28 16:08 MyApp-0.0/
-rw-r--r-- chrism/chrism 1162 2011-07-28 16:07 MyApp-0.0/setup.py
-rw-r--r-- chrism/chrism 16 2011-07-28 16:07 MyApp-0.0/README.txt
-rw-r--r-- chrism/chrism 28 2011-07-28 16:07 MyApp-0.0/CHANGES.txt
-rw-r--r-- chrism/chrism 1457 2011-07-28 16:07 MyApp-0.0/production.ini
drwxr-xr-x chrism/chrism 0 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/
-rw-r--r-- chrism/chrism 1 2011-07-28 16:07 MyApp-0.0/MyApp.egg-info/not-zip-safe
-rw-r--r-- chrism/chrism 649 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/SOURCES.txt
-rw-r--r-- chrism/chrism 6 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/top_level.txt
-rw-r--r-- chrism/chrism 73 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/requires.txt
-rw-r--r-- chrism/chrism 514 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/PKG-INFO
-rw-r--r-- chrism/chrism 8 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/paster_plugins.txt
-rw-r--r-- chrism/chrism 56 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/entry_points.txt
-rw-r--r-- chrism/chrism 1 2011-07-28 16:08 MyApp-0.0/MyApp.egg-info/dependency_links.txt
-rw-r--r-- chrism/chrism 514 2011-07-28 16:08 MyApp-0.0/PKG-INFO
drwxr-xr-x chrism/chrism 0 2011-07-28 16:08 MyApp-0.0/myapp/
drwxr-xr-x chrism/chrism 0 2011-07-28 16:08 MyApp-0.0/myapp/templates/
-rw-r--r-- chrism/chrism 3446 2011-07-28 16:07 MyApp-0.0/myapp/templates/mytemplate.pt
-rw-r--r-- chrism/chrism 682 2011-07-28 16:07 MyApp-0.0/myapp/tests.py
-rw-r--r-- chrism/chrism 237 2011-07-28 16:07 MyApp-0.0/myapp/views.py
-rw-r--r-- chrism/chrism 1088 2011-07-28 16:07 MyApp-0.0/myapp/models.py
drwxr-xr-x chrism/chrism 0 2011-07-28 16:08 MyApp-0.0/myapp/static/
-rw-r--r-- chrism/chrism 203 2011-07-28 16:07 MyApp-0.0/myapp/static/headerbg.png
-rw-r--r-- chrism/chrism 2797 2011-07-28 16:07 MyApp-0.0/myapp/static/middlebg.png
-rw-r--r-- chrism/chrism 49 2011-07-28 16:07 MyApp-0.0/myapp/static/transparent.gif
-rw-r--r-- chrism/chrism 33055 2011-07-28 16:07 MyApp-0.0/myapp/static/pyramid.png
-rw-r--r-- chrism/chrism 4387 2011-07-28 16:07 MyApp-0.0/myapp/static/pylons.css
-rw-r--r-- chrism/chrism 1406 2011-07-28 16:07 MyApp-0.0/myapp/static/favicon.ico
-rw-r--r-- chrism/chrism 7044 2011-07-28 16:07 MyApp-0.0/myapp/static/pyramid-small.png
-rw-r--r-- chrism/chrism 758 2011-07-28 16:07 MyApp-0.0/myapp/static/ie6.css
-rw-r--r-- chrism/chrism 333 2011-07-28 16:07 MyApp-0.0/myapp/static/footerbg.png
-rw-r--r-- chrism/chrism 616 2011-07-28 16:07 MyApp-0.0/myapp/__init__.py
-rw-r--r-- chrism/chrism 533 2011-07-28 16:08 MyApp-0.0/setup.cfg
-rw-r--r-- chrism/chrism 1123 2011-07-28 16:07 MyApp-0.0/development.ini
-rw-r--r-- chrism/chrism 128 2011-07-28 16:07 MyApp-0.0/MANIFEST.in
精彩评论