EDIT: I figured it out, would appreciate it if this is marked as NOT a duplicate because it isn't, by keeping __init__.py empty I was effectively creating a submodule with what I wanted to be the main module. Moving some key things over to __init__.py solved my problem.
I have a python module, expecter.py
class expecter():
def __init__(self, host, username, password):
# connect to host, setup typical ssh expect things
def dothingstohost(self):
self.sendcommandsandthings('etc')
with a setup.py like this (assume project has no subdirectories, simply a single expecter.py file)
from setuptools import setup
setup(
name='expecter',
version='1.21',
packages=['.',],
install_requires=[
"pexpect",
],
)
and I would like to call it like this
import expecter
connection = expecter('someserver', 'someuser', 'somepass')
However after trying numerous things I keep getting stuck in a situation where after a pip install I have to call it like this connection = expecter.expecter('blahblah')
. or pip doesn't like the way I've defined packages and it gets confused. I used to just keep this class alongside my other projects but it's getting larger and I am trying to separate it into its' own project.