Best way to package a python module which is "private" with exposed calling script

2017-02-06 Thread Thomas Nyberg

Hello,

What I would like to do is to package a private python package without 
exposing it's internals. Here is the setup:


* module - This is a module that contains the main code
* script - This is a python script which handles some argument parsing 
stuff and then imports the module code to do main parts of the work


For example a minimal package example might look like this:

package/
├── module/
│   └── __init__.py
├── scripts/
│   └── script
└── setup.py

I know how to package this so that everything is installed to the normal 
places in the system. However, this allows the user to import it 
directly from the system interpreter. What I would ideally like is for 
the module code to be put somewhere off the regular system path and then 
have the binary "know" how to find it. I know how to hack this sort of 
thing together (say by hard-coding things using e.g. sys.path), but what 
I was wondering if there was any "standard" way of doing this that I am 
unaware of.


If this is the wrong list, then please direct me to a better place. 
Thanks for any help!


Cheers,
Thomas



Re: Best way to package a python module which is "private" with exposed calling script

2017-02-07 Thread Thomas Nyberg

Hi Simon,

Thank you very much for the response!

I've been looking at the offlineimap package on my system (jessie), but 
in my case `/usr/bin/offlineimap` is _not_ a symlink. Also the python 
code is not installed to `/usr/share/offlineimap` and instead to 
`/usr/share/pyshared/offlineimap/` and so if I start a normal 
interpreter `import offlineimap` does work (which I'd rather it not). Am 
I completely missing something here or did you possibly mean another 
example package?


Cheers,
Thomas

P.S. I forgot to subscribe to the list before sending the last email and 
had to hack in the `In-reply-to` value this time. For any readers, in 
case I got this wrong this is the post I'm replying to:


https://lists.debian.org/debian-python/2017/02/msg00018.html



Re: Best way to package a python module which is "private" with exposed calling script

2017-02-07 Thread Thomas Nyberg

On 02/07/2017 08:54 AM, Andrey Rahmatullin wrote:

On Tue, Feb 07, 2017 at 08:50:02AM -0500, Thomas Nyberg wrote:
You should look at the sid package version, it's different there.



Thanks a lot! (Should have been an obvious first step...)

And thanks a lot everyone else!

Also I figure I might as well mention on this list that I went through 
and put together a bare-bones example for myself. There are always minor 
finicky things with this (at least for me) so I figure I might as well 
link it in this thread for any future internet travelers. Might save 
them a little hassle...


https://github.com/ApproximateIdentity/debian-private-package