I'm having an issue. I'm porting a lot of code to Python from various other languages of things I've coded over the years and turning it into a large package.
Because not everything fits under a single package - I am nesting packages within. The main package is AcecoolLib, which has init, all of the nested packages have it too.
Because I want to be able to import AcecoolLib - and have everything imported beneath it, all of my init files import everything within their respective folder, and any packages beneath. I only nest 1 deep at the moment - I am not sure whether or not this will change. Probably not.
I have tried absolute imports, and I have tried relative. I have tried modifying sys.modules, and sys.path. I have tried adding paths and I don't know where I can map a name to the path. I end up with a lot of the package loading properly, and some areas I end up with errors where Acecool.X doesn't exist. I fix one, and another one pops up.
One I fixed was - I thought, because I had a few packages named list / tuple / dict that since these are referenced to data-types, that changing them may be beneficial. so I put them into a nested package called array and renamed all of them to include an s on the end. lists, tuples, dicts. not a fan of this - but the error went away.
I'm getting an error in my steam directory now but I don't know of steam being a protected name.
I am using the package, right now, in Sublime Text. I will be using it there for plugins I'm writing - to replace the current system I use which is a single file Acecool.py imported as AcecoolLib in another plugin... It's ugly, hard to maintain, etc.. so I moved some of the code into packages.
In short - I am running into a lot of issues.
This is the first main attempt: https://bitbucket.org/Acecool/acecoollib/src/master/
And this is where I'm at currently: https://www.dropbox.com/s/xvaubq78hlhym9o/AcecoolLib.7z?dl=0
I have tried a lot of variation....
I have looked over other packages which import through nested packages and I haven't found anything which shows me doing anything different ( before I started adding a bunch of crap to the start to find a solution )...
There must be something which lets me set up the paths for each package, and then define they all get added to the AcecoolLib namespace, with nested namespaces within...
I want to be able to go into AcecoolLib/tests/ dir and run tests throughout by running the scripts directly from tests. I also want to be able to import from external / internal sources to have access to everything if I need it.
I also want to be able to import just nested packages or the entire. ie: import AcecoolLib means I should be able to get to Acecool.util.accessors - and so on... or if I import Acecool.util then I don't see AcecoolLib.math - but I could import it.
Right now I'm testing importing everything as my current project uses almost every single function, etc... I added a few as tests..
I have read quite a lot on the subject of importing and I have come across countless 'this is the right way' 'no this' 'nope, this', and so on... none of which work. I have come across articles which say never use this type of import, or this... etc.. most of the articles aren't very useful and are plagued with personal opinions instead of covering the material of the title. Or they cover the basic 101 level variants, or show the directory tree ( which looks identical to mine ) and say that it just works as is...
Maybe that's right - maybe Sublime Text does something differently - ie: I do know that the package is being added to sys.modules, and All of the nested ones are too - so I'm just lost....
Any help is appreciated. Thank you!