chrivers/pyjaco — Issue #7: Distributing js library with pypi package
Author: buchuki
Created: 2011-12-29 14:58:25+00:00
State: open

As I understand it, the py-builtins.js library is an integral part of any javascript compiled with pyjaco. Therefore, this file should be distributed with, or buildable from the python binary distribution shipped via setup.py.

As discussed in http://stackoverflow.com/questions/4519127/setuptools-package-data-folder-location there are essentially two ways to ship data files with setup.py; `package_data` and `data_files`. The problem with `package_data` is that the data file must be distributed inside the pyjaco library. The problem with `data_files` is that it is impossible to reliably determine the location of the installed file from inside the python code across operating systems and virtualenvs.

I see the following options:

* move the `library` directory to `pyjaco/jslib` or similar and ship the various `##-*.js` files in `package_data`. Then merge the `generate_library.py` script into `pyjs.py` so that the script can generate the complete library for users.
* leave `library` where it is, but when `setup.py` is run, ensure that `pyjaco/jslib` exists and generate `py-builtins.js` into that directory before calling setup. Then ship `py-builtins.js` as part of `package_data`.
* assume that `py-builtins.js` has been generated at the time that `setup.py` is run and include the script in `data_files`. Then create fragile code that attempts to guess where the file was installed. This fragile code is guaranteed not to work on all possible platforms, buildouts, or virtualenvs.

I am willing to implement either of the first two options. I have a preference for the first option because it means that only files that are included in version control are shipped with the distribution; py-builtins.js is generated from these files instead of being shipped directly. No setup.py hack is required to ensure that the data has been generated. I didn't want to start moving directories around without your blessing, though, so I'll await feedback on this issue before developing anything.