[prev in list] [next in list] [prev in thread] [next in thread] 

List:       python-distutils-sig
Subject:    Re: [Distutils] namespace_package
From:       Zvezdan Petkovic <zvezdanpetkovic () gmail ! com>
Date:       2015-12-05 6:02:27
Message-ID: 516C22F4-281A-44FF-B19C-32132F56CEBC () gmail ! com
[Download RAW message or body]

Hi Lele,

I experimented with your GitHub demo project.

First, let's state that the custom distclass I sent previously on this thread \
definitely helps Kevin (KP, the original poster) with the editable packages in a \
namespace.

Unfortunately, the fundamental problem and the reason why it doesn't help you is as \
follows:

- The solution relies on the presence of a *.pth file for the namespace that extends \
the path to include the editable package which has only the *.egg-link file

- When you install a package, it gets the correct file structure in site-packages as \
bugex/foo/__init__.py and you have a *.pth file so everything works fine (no need for \
custom distclass)

- When python imports such a package it follows the file-structure in site-packages \
and succeeds.

- When you install it as an editable package, there's no *.pth file, only *.egg-link \
that leads to your source  
- However, the source code does not have a directory for bugex (the namespace) and it \
fails to import

In essence, the Python importer expects a directory for each part separated with dot. \
Thus, if there's import bugex.foo it expects a directory for bugex which contains a \
foo directory.

I'm afraid your editable package must follow the file structure that gets installed \
into site-packages or you'll have to write a custom importer for such packages.

In conclusion:

1. The solution I sent helps with regularly structured packages installed editable as \
a part of a namespace.  (the pip issue #3)

2. I don't see the way to use the flatten file structure as editable. (the issue \
#3160 that you opened)

Sorry for not being of too much help for your issue. Maybe someone else might help.

Honestly, I do not have a compelling motive for not keeping the packages and \
namespaces hierarchically structured even with Python 3. We usually do not nest our \
namespaces deeper than 2 anyway (e.g., zope.app.session).

In Java development it's quite common to see file structure like this:

    src/java/main/com/somecompany/x/y/z/SomeClass.java
    src/java/test/com/somecompany/x/y/z/TestSomeClass.java
    src/scala/main/….

You get the idea. And all the directories until z would have no code in them.
At least we don't need to do that much nesting.
> -)

All the best,

Zvezdan


> On Dec 4, 2015, at 12:19 PM, Lele Gaifax <lele@metapensiero.it> wrote:
> 
> Zvezdan Petkovic <zvezdanpetkovic@gmail.com> writes:
> 
> > Did you try that?
> 
> Yes, indeed that way it works, an all my packages do that. But, as explained
> by the https://github.com/pypa/pip/issues/3160 issue, I would like to use a
> shallower tree for some of them.
> 
> Thanks for taking a look!
> 
> ciao, lele.
> -- 
> nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
> real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
> lele@metapensiero.it  |                 -- Fortunato Depero, 1929.
> 
> _______________________________________________
> Distutils-SIG maillist  -  Distutils-SIG@python.org
> https://mail.python.org/mailman/listinfo/distutils-sig

_______________________________________________
Distutils-SIG maillist  -  Distutils-SIG@python.org
https://mail.python.org/mailman/listinfo/distutils-sig


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic