Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80671

Python: package root, root-node, __init__.py in the package root

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Veek M <vek.m1234@gmail.com>
Newsgroups comp.lang.python
Subject Python: package root, root-node, __init__.py in the package root
Followup-To comp.lang.python
Date Thu, 13 Nov 2014 13:33:27 +0630
Organization Home
Lines 36
Message-ID <m41ok6$re3$1@dont-email.me> (permalink)
Mime-Version 1.0
Content-Type text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding 8Bit
Injection-Date Thu, 13 Nov 2014 08:03:19 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="a310e1856247c4861c71fe3e56810acd"; logging-data="28099"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/QxBC6uwOKARF/IDU2+UyY"
User-Agent KNode/4.4.11
Cancel-Lock sha1:XhimSpZY0aFV2NaIIeceb6Bgm6Q=
Xref csiph.com comp.lang.python:80671

Followups directed to: comp.lang.python

Show key headers only | View raw


I have a package structured like so on the file system:
PKG LIBS are stored here: /usr/lib/python3.2/
Pkg-name: foo-1.0.0

1. What is the root directory, or root-node or 'root' of my package? My 
understanding is that it's: /usr/lib/python3.2/foo-1.0.0/ on the file-system 
and this is referred to the root of the pkg.

2. Can, foo-1.0.0 contain __init__.py or do i have to do:
foo-1.0.0/foo/__init__.py ?


Take a look at what this guy is saying on his blog:
http://blog.habnab.it/blog/2013/07/21/python-packages-and-you/

-------------------
(bottom of the page)
"Your project root should contain a python package, not be a package itself. 
If you do this, your setup.py will be very confusing (or not work at all) 
and it will be very difficult to run your code."

(top of the page)
passacre/__init__.py
passacre/__main__.py

3. Could someone elucidate, explain what it is he's talking about?
-----------------------------
Don?t directly run modules inside packages

"What I mean specifically is doing python passacre/__main__.py, or python 
passacre/test/test_application.py, or anything else that starts with python 
passacre/. This will prevent python from knowing where the root of your 
package is, and so absolute imports and explicit relative imports will fail, 
or not import the code you think it should be importing."

4. In this particular case, how does the interpreter determine pkg-root?

Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Python: package root, root-node, __init__.py in the package root Veek M <vek.m1234@gmail.com> - 2014-11-13 13:33 +0630
  Re: Python: package root, root-node, __init__.py in the package root dieter <dieter@handshake.de> - 2014-11-14 08:09 +0100

csiph-web