[python-flask-assets/epel7] enabled %check and added the BuildRequires for running tests
kumarpraveen
kumarpraveen at fedoraproject.org
Wed Jan 14 05:12:41 UTC 2015
commit 2f8e37adad45b2bf9e560bb8a7ea3bd3e58d1744
Author: Praveen Kumar <prkumar at redhat.com>
Date: Wed Jan 14 10:41:30 2015 +0530
enabled %check and added the BuildRequires for running tests
- patched to work with python-webassets-0.9 in epel7
- patched to disable invalid tests on el7
0001-remove-flask-script-requires-in-epel.patch | 40 ++++
0002-revert-port-to-new-webassets-api.patch | 235 +++++++++++++++++++++++
python-flask-assets.spec | 46 ++++-
3 files changed, 318 insertions(+), 3 deletions(-)
---
diff --git a/0001-remove-flask-script-requires-in-epel.patch b/0001-remove-flask-script-requires-in-epel.patch
new file mode 100644
index 0000000..8d47cdd
--- /dev/null
+++ b/0001-remove-flask-script-requires-in-epel.patch
@@ -0,0 +1,40 @@
+diff --git a/setup.py b/setup.py
+index e0f54c1..b341bf8 100755
+--- a/setup.py
++++ b/setup.py
+@@ -63,6 +63,5 @@ setup(
+ test_suite='nose.collector',
+ tests_require=[
+ 'nose',
+- 'flask-script'
+ ],
+ )
+diff --git a/tests/test_script.py b/tests/test_script.py
+index 57a98d5..eda8b46 100644
+--- a/tests/test_script.py
++++ b/tests/test_script.py
+@@ -1,7 +1,12 @@
+ from __future__ import absolute_import
+
+-import sys
+ from nose import SkipTest
++try:
++ from flask.ext.script import Manager
++except:
++ raise SkipTest()
++
++import sys
+ from flask import Flask
+ from flask.ext.assets import Environment, ManageAssets
+ from webassets.script import GenericArgparseImplementation
+@@ -11,10 +16,6 @@ from tests.helpers import TempEnvironmentHelper
+ if sys.version_info[:2] == (2, 6):
+ raise SkipTest()
+
+-try:
+- from flask.ext.script import Manager
+-except:
+- raise SkipTest()
+
+
+ # The CLI likes to log to stderr, which isn't nice to the test output.
diff --git a/0002-revert-port-to-new-webassets-api.patch b/0002-revert-port-to-new-webassets-api.patch
new file mode 100644
index 0000000..00a2198
--- /dev/null
+++ b/0002-revert-port-to-new-webassets-api.patch
@@ -0,0 +1,235 @@
+diff --git a/src/flask_assets.py b/src/flask_assets.py
+index cd7e890..42251cc 100644
+--- a/src/flask_assets.py
++++ b/src/flask_assets.py
+@@ -9,9 +9,7 @@ from webassets.loaders import PythonLoader, YAMLLoader
+
+
+ __version__ = (0, 10)
+-# this is patched to work with a modified version of webassets-0.9 that's available
+-# in epel7
+-__webassets_version__ = ('>=0.9',) # webassets core compatibility. used in setup.py
++__webassets_version__ = ('>=0.10',) # webassets core compatibility. used in setup.py
+
+
+ __all__ = ('Environment', 'Bundle',)
+@@ -148,46 +146,45 @@ class FlaskResolver(Resolver):
+ are no longer resolved.
+ """
+
+- def split_prefix(self, item):
++ def split_prefix(self, ctx, item):
+ """See if ``item`` has blueprint prefix, return (directory, rel_path).
+ """
++ app = ctx.environment._app
+ try:
+- if hasattr(self.env._app, 'blueprints'):
++ if hasattr(app, 'blueprints'):
+ blueprint, name = item.split('/', 1)
+- directory = get_static_folder(self.env._app.blueprints[blueprint])
++ directory = get_static_folder(app.blueprints[blueprint])
+ endpoint = '%s.static' % blueprint
+ item = name
+ else:
+ # Module support for Flask < 0.7
+ module, name = item.split('/', 1)
+- directory = get_static_folder(self.env._app.modules[module])
++ directory = get_static_folder(app.modules[module])
+ endpoint = '%s.static' % module
+ item = name
+ except (ValueError, KeyError):
+- directory = get_static_folder(self.env._app)
++ directory = get_static_folder(app)
+ endpoint = 'static'
+
+ return directory, item, endpoint
+
+- @property
+- def use_webassets_system_for_output(self):
+- return self.env.config.get('directory') is not None or \
+- self.env.config.get('url') is not None
++ def use_webassets_system_for_output(self, ctx):
++ return ctx.config.get('directory') is not None or \
++ ctx.config.get('url') is not None
+
+- @property
+- def use_webassets_system_for_sources(self):
+- return bool(self.env.load_path)
++ def use_webassets_system_for_sources(self, ctx):
++ return bool(ctx.load_path)
+
+- def search_for_source(self, item):
++ def search_for_source(self, ctx, item):
+ # If a load_path is set, use it instead of the Flask static system.
+ #
+ # Note: With only env.directory set, we don't go to default;
+ # Setting env.directory only makes the output directory fixed.
+- if self.use_webassets_system_for_sources:
+- return Resolver.search_for_source(self, item)
++ if self.use_webassets_system_for_sources(ctx):
++ return Resolver.search_for_source(self, ctx, item)
+
+ # Look in correct blueprint's directory
+- directory, item, endpoint = self.split_prefix(item)
++ directory, item, endpoint = self.split_prefix(ctx, item)
+ try:
+ return self.consider_single_directory(directory, item)
+ except IOError:
+@@ -195,31 +192,31 @@ class FlaskResolver(Resolver):
+ # expect an IOError upon missing files. They need to be rewritten.
+ return path.normpath(path.join(directory, item))
+
+- def resolve_output_to_path(self, target, bundle):
++ def resolve_output_to_path(self, ctx, target, bundle):
+ # If a directory/url pair is set, always use it for output files
+- if self.use_webassets_system_for_output:
+- return Resolver.resolve_output_to_path(self, target, bundle)
++ if self.use_webassets_system_for_output(ctx):
++ return Resolver.resolve_output_to_path(self, ctx, target, bundle)
+
+ # Allow targeting blueprint static folders
+- directory, rel_path, endpoint = self.split_prefix(target)
++ directory, rel_path, endpoint = self.split_prefix(ctx, target)
+ return path.normpath(path.join(directory, rel_path))
+
+- def resolve_source_to_url(self, filepath, item):
++ def resolve_source_to_url(self, ctx, filepath, item):
+ # If a load path is set, use it instead of the Flask static system.
+- if self.use_webassets_system_for_sources:
+- return super(FlaskResolver, self).resolve_source_to_url(filepath, item)
++ if self.use_webassets_system_for_sources(ctx):
++ return super(FlaskResolver, self).resolve_source_to_url(ctx, filepath, item)
+
+- return self.convert_item_to_flask_url(item, filepath)
++ return self.convert_item_to_flask_url(ctx, item, filepath)
+
+- def resolve_output_to_url(self, target):
++ def resolve_output_to_url(self, ctx, target):
+ # With a directory/url pair set, use it for output files.
+- if self.use_webassets_system_for_output:
+- return Resolver.resolve_output_to_url(self, target)
++ if self.use_webassets_system_for_output(ctx):
++ return Resolver.resolve_output_to_url(self, ctx, target)
+
+ # Otherwise, behaves like all other flask URLs.
+- return self.convert_item_to_flask_url(target)
++ return self.convert_item_to_flask_url(ctx, target)
+
+- def convert_item_to_flask_url(self, item, filepath=None):
++ def convert_item_to_flask_url(self, ctx, item, filepath=None):
+ """Given a relative reference like `foo/bar.css`, returns
+ the Flask static url. By doing so it takes into account
+ blueprints, i.e. in the aformentioned example,
+@@ -233,7 +230,7 @@ class FlaskResolver(Resolver):
+ then we import the url_for function from flask.ext.s3,
+ otherwise we import url_for from flask directly.
+ """
+- if self.env._app.config.get("FLASK_ASSETS_USE_S3"):
++ if ctx.environment._app.config.get("FLASK_ASSETS_USE_S3"):
+ try:
+ from flask.ext.s3 import url_for
+ except ImportError as e:
+@@ -242,22 +239,22 @@ class FlaskResolver(Resolver):
+ else:
+ from flask import url_for
+
+- directory, rel_path, endpoint = self.split_prefix(item)
++ directory, rel_path, endpoint = self.split_prefix(ctx, item)
+
+ if filepath is not None:
+ filename = filepath[len(directory)+1:]
+ else:
+ filename = rel_path
+
+- ctx = None
++ flask_ctx = None
+ if not _request_ctx_stack.top:
+- ctx = self.env._app.test_request_context()
+- ctx.push()
++ flask_ctx = ctx.environment._app.test_request_context()
++ flask_ctx.push()
+ try:
+ return url_for(endpoint, filename=filename)
+ finally:
+- if ctx:
+- ctx.pop()
++ if flask_ctx:
++ flask_ctx.pop()
+
+
+ class Environment(BaseEnvironment):
+diff --git a/tests/test_integration.py b/tests/test_integration.py
+index 67fb3ac..7d7e030 100644
+--- a/tests/test_integration.py
++++ b/tests/test_integration.py
+@@ -75,11 +75,11 @@ class TestUrlAndDirectory(TempEnvironmentHelper):
+ """
+ assert not 'url' in self.env.config
+
+- assert Bundle('foo').urls(self.env) == ['/app_static/foo']
++ assert Bundle('foo', env=self.env).urls() == ['/app_static/foo']
+ # Urls for files that point to a module use that module's url prefix.
+- assert Bundle('module/bar').urls(self.env) == ['/mod_static/bar']
++ assert Bundle('module/bar', env=self.env).urls() == ['/mod_static/bar']
+ # Try with a prefix that's not actually a valid module
+- assert Bundle('nomodule/bar').urls(self.env) == ['/app_static/nomodule/bar']
++ assert Bundle('nomodule/bar', env=self.env).urls() == ['/app_static/nomodule/bar']
+
+ # [Regression] Ensure that any request context we may have added
+ # to the stack has been removed.
+@@ -96,14 +96,15 @@ class TestUrlAndDirectory(TempEnvironmentHelper):
+ # We do not recognize references to modules.
+ assert get_all_bundle_files(Bundle('module/bar'), self.env) == [self.path('module/bar')]
+
+- assert Bundle('foo').urls(self.env) == ['/custom/foo']
+- assert Bundle('module/bar').urls(self.env) == ['/custom/module/bar']
++
++ assert Bundle('foo', env=self.env).urls() == ['/custom/foo']
++ assert Bundle('module/bar', env=self.env).urls() == ['/custom/module/bar']
+
+ # [Regression] With a load path configured, generating output
+ # urls still works, and it still uses the flask system.
+ self.env.debug = False
+ self.env.url_expire = False
+- assert Bundle('foo', output='out').urls(self.env) == ['/app_static/out']
++ assert Bundle('foo', output='out', env=self.env).urls() == ['/app_static/out']
+
+ def test_custom_directory_and_url(self):
+ """Custom directory/url are configured - this will affect how
+@@ -118,9 +119,9 @@ class TestUrlAndDirectory(TempEnvironmentHelper):
+ self.env.debug = False # Return build urls
+ self.env.url_expire = False # No query strings
+
+- assert Bundle('a', output='foo').urls(self.env) == ['/custom/foo']
++ assert Bundle('a', output='foo', env=self.env).urls() == ['/custom/foo']
+ # We do not recognize references to modules.
+- assert Bundle('a', output='module/bar').urls(self.env) == ['/custom/module/bar']
++ assert Bundle('a', output='module/bar', env=self.env).urls() == ['/custom/module/bar']
+
+ def test_existing_request_object_used(self):
+ """[Regression] Check for a bug where the url generation code of
+@@ -133,13 +134,13 @@ class TestUrlAndDirectory(TempEnvironmentHelper):
+ """
+ with self.app.test_request_context(
+ '/', environ_overrides={'SCRIPT_NAME': '/yourapp'}):
+- assert Bundle('foo').urls(self.env) == ['/yourapp/app_static/foo']
++ assert Bundle('foo', env=self.env).urls() == ['/yourapp/app_static/foo']
+
+ def test_glob(self):
+ """Make sure url generation works with globs."""
+ self.app.static_folder = self.tempdir
+ self.create_files({'a.js': 'foo', 'b.js': 'bar'})
+- assert list(sorted(self.mkbundle('*.js').urls(self.env))) == [
++ assert list(sorted(self.mkbundle('*.js', env=self.env).urls())) == [
+ '/app_static/a.js', '/app_static/b.js']
+
+
+@@ -159,7 +160,7 @@ class TestUrlAndDirectoryWithInitApp(object):
+ """
+ with self.app.test_request_context():
+ assert not 'url' in self.env.config
+- assert Bundle('foo').urls(self.env) == ['/initapp_static/foo']
++ assert Bundle('foo', env=self.env).urls() == ['/initapp_static/foo']
+
+ assert not 'directory' in self.env.config
+ root = self.app.root_path
diff --git a/python-flask-assets.spec b/python-flask-assets.spec
index 32b5ac9..318576e 100644
--- a/python-flask-assets.spec
+++ b/python-flask-assets.spec
@@ -5,23 +5,41 @@
Name: python-flask-assets
Version: 0.10
-Release: 1%{?dist}
+Release: 2%{?dist}
Summary: Asset management for flask
Group: Development/Libraries
License: BSD
URL: http://github.com/miracle2k/flask-assets
Source0: http://pypi.python.org/packages/source/F/%{mod_name}/%{mod_name}-%{version}.tar.gz
-
+Patch0: 0001-remove-flask-script-requires-in-epel.patch
+Patch1: 0002-revert-port-to-new-webassets-api.patch
BuildArch: noarch
-BuildRequires: python2-devel
+BuildRequires: python-devel
BuildRequires: python-setuptools
BuildRequires: python-webassets
+BuildRequires: PyYAML
+BuildRequires: python-nose
+BuildRequires: python-mock
+BuildRequires: python-flask
+%if 0%{?fedora}
+# the tests use python-flask-script but skip those tests if flask-script is
+# not available and there is no python-flask-script extension in epel
+BuildRequires: python-flask-script
+%endif
+
Requires: python-webassets
+Requires: python-flask
+
%if 0%{?with_python3}
BuildRequires: python3-devel
BuildRequires: python3-setuptools
BuildRequires: python3-webassets
+BuildRequires: python3-PyYAML
+BuildRequires: python3-nose
+BuildRequires: python3-mock
+BuildRequires: python3-flask
+BuildRequires: python3-flask-script
%endif
%description
@@ -42,6 +60,14 @@ for merging, minifying and compiling CSS and Javascript files.
%prep
%setup -q -n %{mod_name}-%{version}
+%if 0%{?rhel}
+# there is no python-flask-script build in epel, so remove the requires and
+# apply a patch submitted upstream to skip the tests before a traceback kills
+# the affected tests so that the skipping actually happens
+%patch0 -p1
+%patch1 -p1 -R
+%endif
+
rm -f docs/_themes/.gitignore
rm -f docs/.gitignore
@@ -69,6 +95,15 @@ mkdir -p $RPM_BUILD_ROOT%{python3_sitelib}
popd
%endif
+%check
+%{__python} setup.py test
+
+%if 0%{?with_python3}
+pushd %{py3dir}
+%{__python3} setup.py test
+popd
+%endif
+
%files
%doc docs/ README.rst CHANGES LICENSE PKG-INFO
%{python_sitelib}/*
@@ -80,6 +115,11 @@ popd
%endif # with_python3
%changelog
+* Wed Dec 17 2014 Tim Flink <tflink at fedoraproject.org> 0.10-2
+- enabled %check and added the BuildRequires for running tests
+- patched to work with python-webassets-0.9 in epel7
+- patched to disable invalid tests on el7
+
* Thu Dec 11 2014 Praveen Kumar <kumarpraveen.nitdgp at gmail.com> 0.10-1
- Update to latest source
- Add python3 support
More information about the scm-commits
mailing list