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?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With