Hi Wolfgang,
On Wed, Apr 10, 2013 at 2:36 PM, Wolfgang Schnerring <
w...@gocept.com> wrote:
> I opted to not declare the dependencies in fanstatic's setup.py at
> all, i.e. not do a fanstatic[compilers] extra or something, since
> a) many compilers require external binaries (node.js-based and so on)
> which we couldn't declare anyway and b) collecting all possible
> dependencies under one extra feels wrong (wouldn't want to force *all*
> on somebody who just wants to use one), so we might as well leave it
> off completely and tell people to require Python packages for
> compilers "downstream", that is in their application.
Sounds very reasonable. We could use extras_require in setup.py:
extras_require = {
'cssmin': ['cssmin'],
'jsmin': ['jsmin'],
}
Where the keys are the names of minifiers/compilers and the values are
list of python packages. However, this would only work for python
packages, not for node/java dependencies. There is a chance of clashes
between compiler and minifier names, but I am willing to bet there
won't be a 'js compiler' called 'cssmin'.
@Wolfgang, in [a] you hook into sdist_compile; previously we discussed
hooking into zest.releaser. It seems the sdist_compile hook is more
versatile than a zest.releaser pre-release hook. This is a very cool
hack!
a)
https://bitbucket.org/fanstatic/fanstatic/src/70594589896703e0f79425e44edb0a841d380c60/fanstatic/compiler.py?at=wosc-compilers#cl-118
I took the liberty of fixing/adding some tests on the wosc-compilers
branch and added these features:
1. Added google closure compiler as a minifier, using the 'closure'
python package. Adding a compiler is a breeze! No problem for me to
keep them in the fanstatic package.
2. When compiling a resource, write a log record of the Resource being
compiled and the time spent. This can be picked up by a console
handler when working on a running app or in the fanstatic-compile
script by passing '-v' or '--verbose' for verbose output. This is a
nice indication to the developer when a server request is slow to load
when resources are compiled.
3. If you don't want the sources of your Resources to be publishable,
you can set your library 'ignores' setting to the globs of the sources
files; I have added this to the documentation.
I would like to discuss the following topics:
1. It is good practice not to do compilation on a production system.
When deploying an app to production, the compiler backend need not be
available. The NeededResources 'compile' flag determines whether
resources need to be compiled. If a fanstatic Library has
compiled/minified Resources, but the resulting files are not added to
the distribution as a result of a human error, the files will not be
served.
At the moment of Resource instantiation it is not known whether the
NeededResources configuration has the 'compile' and or 'minified'
settings.
There is not a lot we can do about this. For minified resources, we
could jump through all kind of hoops and use the original source file
in a last attempt to do "the right thing", but for compiled resources
that is not an option.
My suggestion is to do nothing to correct the human error; the person
who deployed the application can found out about the missing resources
in the server access logs.
2. In earlier discussions about compilers, we talked about storing the
information about the compiler (name and version) that was used to
compile a resource near the output file (in a manifest file or in the
filename), in order to detect that a new version of the compiler or a
compiler with a different name is now active and fanstatic should
recompile the resource. I think we can drop this functionality, the
"fanstatic-compile" script is handy in case of changes in the compiler
backends.
3. Should we compile the resources only for the packages that are
installed in development mode? In the fanstatic.registry code we do
something similar:
https://bitbucket.org/fanstatic/fanstatic/src/35e5f8b9d6e65ed05f4d26a1f2b1ff41f7a3ec9b/fanstatic/registry.py?at=default#cl-36
I am really excited about this feature and think we are nearing a
release! I am particularly happy about the feature of using both a
compiler and a minifier for a Resource, and to see that these steps
are executed in the correct order. And I am also happy that the
resource compilation feature doesn't need any changes in other
fanstatic features such as bundling.
Next steps:
1. fix on python3
2. @Martijn, could you have a look at the changes on the branch?
3. merge to default and release.
Cheers,
JJ