Skip to content

Commit

Permalink
Add a FAQ entry about using data files
Browse files Browse the repository at this point in the history
Closes gh-38
  • Loading branch information
takluyver committed Mar 6, 2015
1 parent 5273a84 commit 90ded5d
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions doc/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,22 @@ Python by default, though you can override this :ref:`in the config file <cfg_py
Whichever method you use, compiled libraries must have the same bit-ness as
the version of Python that's installed.

Using data files
----------------

Applications often need data files along with their code. The easiest way to use
data files with Pynsist is to store them in a Python package (a directory with
a ``__init__.py`` file) you're creating for your application. They will be
copied automatically, and modules in that package can locate them using
``__file__`` like this::

data_file_path = os.path.join(os.path.dirname(__file__), 'file.dat')

If you don't want to put data files inside a Python package, you will need to
list them in the ``files`` key of the ``[Include]`` section of the config file.
Your code can find them relative to the location of the launch script running your
application (``sys.module['__main__'].__file__``).

This comment has been minimized.

Copy link
@aaren

aaren Mar 6, 2015

should be sys.modules (not sys.module)

This comment has been minimized.

Copy link
@takluyver

takluyver Mar 7, 2015

Author Owner

Well spotted, thanks. I've fixed it now.


Alternatives
------------

Expand Down

1 comment on commit 90ded5d

@aaren
Copy link

@aaren aaren commented on 90ded5d Mar 6, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's great. Thanks for clarifying :)

Please sign in to comment.