[Python-Dev] Setting project home path the best way

2012-11-11 Thread Christian Tismer
Hi friends,

I have a project that has its root somewhere on my machine. 
This project has many folders and contains quite some modules. 

There is a common root of the module tree, and I want to use
- either absolute imports
- relative imports with '.'

Problem:

- I want to run any module inside the heirarchy from the command-line

- this should work, regardless what my 'cwd' is

- this should work with or without virtualenv. 

So far, things work fine with virtualenv, because sys.executable is in the 
project module tree. 

Without virtualenv, this is not so. But I hate to make settings like 
PYTHONPATH, because these are not permanent. .  

Question:

How should I define my project root dir in a unique way, without setting an 
environment variable?
What is the lest intrusive way to spell that?

Reason:

I'd like to make things work correctly and unambigously when I call a script
inside the module heirarchy. Things are not fixed: there exist many checkouts
In the file system, and each should know where to search its home/root in the 
tree. 

Is this elegantly possible to deduce from the actually executed script file?

Cheers - chris

Sent from my Ei4Steve
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Relatwd: py3 import strategy (was: Setting project home path the best way(

2012-11-11 Thread Christian Tismer
Once again on this:

With the introduction of module folders
without __init__, it has become even harder to deduce a sensible project root
Dir without relying on a global settings file. Abd as you probably agree, such 
files are a bad idea. Any global is bad, also in the file system. 

Guido, this is another reason why I dislike the absence of __init__. :

Rhere is no longer an indicator that pretty clearly defines the root of my 
module heirarchy. 

Cheers, hoping for enlightment - chris

Sent from my Ei4Steve

On Nov 11, 2012, at 21:31, Christian Tismer  wrote:

> Hi friends,
> 
> I have a project that has its root somewhere on my machine. 
> This project has many folders and contains quite some modules. 
> 
> There is a common root of the module tree, and I want to use
> - either absolute imports
> - relative imports with '.'
> 
> Problem:
> 
> - I want to run any module inside the heirarchy from the command-line
> 
> - this should work, regardless what my 'cwd' is
> 
> - this should work with or without virtualenv. 
> 
> So far, things work fine with virtualenv, because sys.executable is in the 
> project module tree. 
> 
> Without virtualenv, this is not so. But I hate to make settings like 
> PYTHONPATH, because these are not permanent. .  
> 
> Question:
> 
> How should I define my project root dir in a unique way, without setting an 
> environment variable?
> What is the lest intrusive way to spell that?
> 
> Reason:
> 
> I'd like to make things work correctly and unambigously when I call a script
> inside the module heirarchy. Things are not fixed: there exist many checkouts
> In the file system, and each should know where to search its home/root in the 
> tree. 
> 
> Is this elegantly possible to deduce from the actually executed script file?
> 
> Cheers - chris
> 
> Sent from my Ei4Steve
> ___
> Python-Dev mailing list
> Python-Dev@python.org
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/tismer%40stackless.com
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Relatwd: py3 import strategy (was: Setting project home path the best way(

2012-11-11 Thread Eric Snow
On Sun, Nov 11, 2012 at 1:53 PM, Christian Tismer wrote:

> Once again on this:
>
> With the introduction of module folders
> without __init__, it has become even harder to deduce a sensible project
> root
> Dir without relying on a global settings file. Abd as you probably agree,
> such files are a bad idea. Any global is bad, also in the file system.
>
> Guido, this is another reason why I dislike the absence of __init__. :
>
> Rhere is no longer an indicator that pretty clearly defines the root of my
> module heirarchy.
>

 This came up during the discussions leading up to PEP 420, particularly
regarding the impact on PEP 395.  My thoughts at the time on addressing the
problem:

http://mail.python.org/pipermail/import-sig/2012-March/000438.html

-eric
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Relatwd: py3 import strategy

2012-11-11 Thread Christian Tismer

Hi Eric,

On 11.11.12 22:45, Eric Snow wrote:
On Sun, Nov 11, 2012 at 1:53 PM, Christian Tismer 
mailto:tis...@stackless.com>> wrote:


Once again on this:

With the introduction of module folders
without __init__, it has become even harder to deduce a sensible
project root
Dir without relying on a global settings file. Abd as you probably
agree, such files are a bad idea. Any global is bad, also in the
file system.

Guido, this is another reason why I dislike the absence of __init__. :

Rhere is no longer an indicator that pretty clearly defines the
root of my module heirarchy.


 This came up during the discussions leading up to PEP 420, 
particularly regarding the impact on PEP 395.  My thoughts at the time 
on addressing the problem:


http://mail.python.org/pipermail/import-sig/2012-March/000438.html



I do not quite understand what you want to propose:

"""

* there is no __init__.py in the current directory (in the case where
there was one adjacent to the original module)
* current directory is on sys.path
* setup.py is in the current directory

"""

Are you saying that this is a way for me to get at the project root?
And can this be done with a one-liner, or would I need a module for that,
where the cat would bite its tail, because that module would not be found,
easily?

Please tell me in a simpler way what you think  ;-)

ciao - Chris

--
Christian Tismer :^)   
Software Consulting  : Have a break! Take a ride on Python's
Karl-Liebknecht-Str. 121 :*Starship* http://starship.python.net/
14482 Potsdam: PGP key -> http://pgp.uni-mainz.de
phone +49 173 24 18 776  fax +49 (30) 700143-0023
PGP 0x57F3BF04   9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
  whom do you want to sponsor today?   http://www.stackless.com/

___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Setting project home path the best way

2012-11-11 Thread Nick Coghlan
The only way I know how to do it is to have my cwd set to the directory I
want on sys.path, then use -m for script execution (using a separate shell
session for anything where I want a different working directory).

I don't know of any way to handle a varying cwd without manipulating the
path directly through either virtualenv or PYTHONPATH.

Cheers,
Nick.

--
Sent from my phone, thus the relative brevity :)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com