Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add my module to travis-ci pythonpath

I'm setting up Travis-CI for my project, and oddly, I can't import my project:

$ python tests/tests.py
Traceback (most recent call last):
  File "tests/tests.py", line 11, in <module>
    from my_module.lib.importer import build_module_list
ImportError: No module named my_module.lib.importer

In production, I just create a symlink like so:

sudo ln -s /usr/local/my_module /usr/lib/python2.7/dist-packages/my_module

But I don't know -- or want to know, really -- Travis-CI's folder structure.

This seems like a solved problem, but I'm new to Travis-CI. What's the best way to make this work, so my code is added as an importable module?

like image 388
mlissner Avatar asked Sep 10 '14 01:09

mlissner


1 Answers

In complement of @Brian-Cain answer, you can also use setuptools instead of distutils. As of writing, distutils is being phased out, and setuptools is being used as a replacement, even though setuptools is not yet in standard library.

from setuptools import setup, find_packages

setup(name='Foo',
      version='0.0.1',
      description='Python Distribution Utilities',
      author='',
      author_email='',
      url='',
      packages=find_packages(exclude=['contrib', 'docs', 'tests*']),
     )

For a quick tutorial on making a setup.py with setuptools: https://packaging.python.org/tutorials/distributing-packages/

For a quick real example: https://github.com/pypa/sampleproject/blob/master/setup.py

like image 65
bizi Avatar answered Sep 18 '22 22:09

bizi