Package: calmjs.bower
calmjs.bowerBowersupport for thecalmjsframework.IntroductionThis package provides the support for Bower into Python through thecalmjsframework.  Through the use of this package it is possible to
declare dependencies onbowerpackages through abower_jsonsection within asetuptoolscompatiblesetup.pyfor the given
Python package, to generate abower.jsonfile metadata which can be
referenced and reused by other Python packages that make use of thecalmjsframework.For details on how this works, please refer to the documentation for thecalmjspackage.InstallationWhile the goal ofcalmjs.boweris to bring in the support of Bower
intocalmjs, this library can function without Bower already installed
beforehand, ascalmjscan be leveraged to bring Bower into the current
Python environment.  However,Node.jsandnpmmust be installed and
available for this to be realized; if they are not installed please
follow the installation steps for Node.js appropriate for the running
environment/platform.To installcalmjs.bowerinto a given Python environment, it may be
installed directly from PyPI with the following command:$pipinstallcalmjs.bowerIf a local installation of Bower into the current directory is desired,
it can be done throughcalmjswith the following command:$calmjsnpm--installcalmjs.bowerWhich does the equivalent ofnpm install bower; while this does not
seem immediately advantageous, other Python packages that declared their
dependencies for specific sets of tool can be invoked like so, and to
follow through on that.  As an example,example.packagemay declare
dependencies on Bower throughnpmplus a number of other packages
available throughbower, the process then simply become this:$calmjsnpm--installexample.package$calmjsbower--installexample.packageAll standard JavaScript and Node.js dependencies forexample.packagewill now be installed into the current directory through the relevant
tools.  This process will also install all the other dependencies
throughnpmorbowerthat other Python packages depended on byexample.packagehave declared.  For more usage please refer to
further down this document or the documentation forcalmjs.Alternative installation methods (advanced users)Development is still ongoing withcalmjs.bower, for the latest
features and bug fixes, the development version can be installed through
git like so:$pipinstallcalmjs$pipinstallgit+https://github.com/calmjs/calmjs.bower.git#egg=calmjs.bowerAlternatively, the git repository can be cloned directly and executepython setup.py developwhile inside the root of the source
directory.Keep in mind thatcalmjsMUST be available before thesetup.pywithin thecalmjs.bowersource tree is executed, for it needs thepackage_jsonwriting capabilities incalmjs.  Please refer to the
base package for further information.Ascalmjsis declared as both a namespace and a package, mixing
installation methods as described above when installing with othercalmjspackages may result in the module importer being unable to look
up the target module.  While this normally will not affect end users,
provided they use the same, standard installation method (i.e. wheel),
for developers it can be troublesome.  To resolve this, either stick to
the same installation method for all packages (i.e.python setup.py develop), or import a module from the maincalmjspackage.  Here
is an example run:>>>importcalmjs.bowerTraceback(mostrecentcalllast):File"<stdin>",line1,in<module>ImportError:Nomodulenamed'calmjs.bower'>>>importcalmjs.base>>>importcalmjs.bower>>>If this behavior (and workaround) is undesirable, please ensure the
installation of allcalmjsrelated packages follow the same method
(i.e. eitherpython setup.py developfor all packages, or using the
wheels acquired throughpip).Testing the installationTo ensure that thecalmjsinstallation is functioning correctly, the
built-in testsuite can be executed by the following command:$python-munittestcalmjs.bower.tests.make_suiteIf there are failures, please file an issue on the issue tracker with
the full traceback, and/or the method of installation.  Please also
remember to include platform specific information, such as Python
version, operating system environments and version, and other related
information related to the issue at hand.UsageThecalmjs.bowerpackage will install the appropriate hooks into thecalmjsconsole entry point and alsosetuptoolsto facilitate the
generation ofbower.jsonfrom thebower_jsondeclarations in the
current package or other packages installed in the current environment.If no packages with conflicting declarations are installed, with thebowerbinary available through thePATHenvironment variable (or
in the current directory’snode_modules), running the utility will
result in something like this:$calmjsusage:calmjs[-h][-d][-q][-v][-V]<command>...positionalarguments:<command>npmnpmcompatibilityhelperbowerbowercompatibilityhelperIfbowerwas not available, a warning will also be displayed,
however this should only affect operations that need the binary itself.
As for details with usage, please invokecalmjs bower--help.The following help outlines typical usage ofbowerwith declarations
by supporting Python packages throughcalmjs, so much of the help is
copied and shared from that package, modified from its support fornpm.Declare abower.jsonfor a given Python packageIf a package wish to declare dependencies on packages available throughbower, it may do something like this in itssetup.py:fromsetuptoolsimportsetupbower_json={"dependencies":{"jquery":"~3.0.0","underscore":"~1.8.0",}}setup(name='example.package',...install_requires=['calmjs.bower',...],bower_json=bower_json,...)This will let users of this package install all the dependencies through
the appropriate package managers as outlined above in the installation
section.Declare explicit dependencies on paths insidebower_componentsGiven that the dependencies on specific versions of packages sourced
fromboweris explicitly specified, build tools will benefit again
from explicit declarations on files needed from those packages.  Namely,
the compiled packages could be declared in theextras_calmjssection
in JSON string much likebower_json, like so:extras_calmjs={'bower_components':{'jquery':'jquery/dist/jquery.js','underscore':'underscore/underscore.js',},}setup(name='example.package',...extras_calmjs=extras_calmjs,...)Sincebower_componentsis declared to be anextras_key,
conflicts with existing declarations in other packages within the
environment will be merged like how dependencies sections declared inbower_json.Please do note that complete paths must be declared (note that the.jsfilename suffix is included in the example); directories can
also be declared.  However, as these declarations are done from within
Python, explicit, full paths are required thus it is up to downstream
integration packages to properly handle and/or convert this into the
conventions that standard Node.js tools might expect (i.e. where the.jsfilename suffix is omitted).As of now, the support of.bowerrcconfiguration settings is not
currently implemented, so behavior of usage ofbowerthrough calmjs
will not account for locations that may be specified in that file.  For
the standard use case where dependencies are installed to some separate
directory as part of a typicalcalmjsworkflow it should not pose a
problem.TroubleshootingHere are some common issues that may be encountered with typical usage
ofcalmjs.bower.RuntimeWarning: Unable to locate the ‘bower’ binary;If this message appears, this simply means the default module setup
(i.e.from calmjs import bower) could not find a usablebowerbinary/runtime when it was imported.  As the default runtime does
various setup it only means that the helper methods may not be usable
out of the box.  This can always be rectified by havingboweralready
installed in the current directory (throughnpm) or have it be
available through thePATHenvironment variable.  Full details on
what can be done is written in the error message.ContributeIssue Tracker:https://github.com/calmjs/calmjs.bower/issuesSource Code:https://github.com/calmjs/calmjs.bowerLegalThecalmjs.bowerpackage is part of the calmjs project.The calmjs project is copyright (c) 2016 Auckland Bioengineering
Institute, University of Auckland.calmjs.boweris licensed under the
terms of the GPLv2 or later.Changelog1.0.2 (2016-09-07)Introduced CI on Windows via appveyor and a number of issues specific
to Python 2.7 on Windows have been fixed here and in both upstream.1.0.0 (2016-09-04)Initial implementation that enables the availability of bower-1.7.x
into the calmjs framework through the framework itself.Allow the declaration of bower.json through setuptools (as bower_json
setup field)Enablecalmjs boweroption in the same manner ascalmjs npm.