I want write code fetch data from teradata using python. The code should work while running using spark on cluster as well as local. While running using spark I don't want to open connections on executors. So the plan is to run code on driver using teradatasql package. Since teradatasql packages so library I thought I don't have install teradata library on cluster. 
I packaged the dependencies i.e. teradatasql as egg file and passed it as --py-files. But while running on code teradatasql is not able to read library from egg file. 
Os error: teradatasql.so cannot open shared object file. Not a directory.
I followed the below steps to package the egg file.
1. pip install teradatasql --target./src # note all my code is in src folder. Doing this step will install teradatasql package in my src folder. it contains teradatasql.so library
2. In setup.py packages=find_packages('src'), package_data={'teradatasql':['teradatasql.so']}
3. python setup.py bdist_eggg
The teradatasql driver uses a shared library to communicate with the Teradata Database.
The teradatasql driver will not work if you repackage just the Python file portion of the driver. The error will occur that you got.
The intended use of the teradatasql driver is that you install it into your Python environment with the command: pip install teradatasql
We will not be able to effectively support you if you take apart and repackage the teradatasql driver. That is not a supported use case.
Running Teradatasql driver for python code using spark