This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Implied __init__.py not copied
Type: Stage:
Components: Distutils Versions: Python 2.2
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: akuchling Nosy List: akuchling, facundobatista, loewis, tepperly
Priority: normal Keywords:

Created on 2002-09-11 20:13 by tepperly, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
setup.py tepperly, 2002-09-11 20:13 Example setup.py
Messages (8)
msg12367 - (view) Author: Tom Epperly (tepperly) Date: 2002-09-11 20:13
The setup method in distutils won't allow me to specify
packages and py_modules, and it doesn't correctly
deduce all of the directories that need __init__.py
files copied.  See the attached setup.py for an
example. This setup.py is automatically generated from
a cca.sidl file containing an interface description.

In my example, the directory structure is as follows:
gov/
gov/cca/
gov/cca/ports/
decaf/
decaf/ports
The problem is that gov/ only contains __init__.py.

If I specific packages and py_modules in my setup call,
I see the following:
[epperly@tux06 runPython]$ python2.2 setup.py
--include-dirs=`cd ../../../runtime/python && pwd`
--include-dirs=`cd ../../../runtime/sidl && pwd`
--include-dirs=`cd . && pwd` --library-dirs=`cd
../../../runtime/sidl/.libs && pwd` install
--prefix=/tmp/pytest
running install
running build
running build_py
error: build_py: supplying both 'packages' and
'py_modules' options is not allowed
[epperly@tux06 runPython]$ 

If I comment out the "packages = []" part and do a
"python setup.py install", it doesn't copy 
gov/__init__.py, decaf/__init__.py and
decaf/ports/__init__.py to the installation directory.

From this data, it appears that distutils isn't
deducing the package list correctly from py_modules and
ext_modules. For each element of py_modules, it should
add all the parent modules. For an py_modules entry,
a.b.c.d.e.f, distutils should add a, a.b, a.b.c,
a.b.c.d, and a.b.c.d.e to the package list.

distutils should also glean package names from the
ext_modules list.
msg12368 - (view) Author: Tom Epperly (tepperly) Date: 2002-09-11 20:22
Logged In: YES 
user_id=94539

I am surprised that sourceforge let me assign this to someone.
msg12369 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2002-09-12 07:04
Logged In: YES 
user_id=21627

It appears that you are misunderstanding the meaning of the
py_modules argument. See

http://www.python.org/doc/current/dist/setup-script.html#SECTION000320000000000000000

It says "specially the case of a single module that goes in
the ``root package'' "

All py_modules modules are in a single package, irrespective
of their source location.
msg12370 - (view) Author: Tom Epperly (tepperly) Date: 2002-09-12 17:19
Logged In: YES 
user_id=94539

I read the section loewis linked me to, and the example
given there has 'mod1' in the "root package" and "pkg.mod2"
in the pkg/ package. This leads me to believe that
py_modules do not go into a single package as loewis suggests.

In addition, distutils should copy __init__.py files implied
by the list of C extension modules.
msg12371 - (view) Author: Tom Epperly (tepperly) Date: 2002-09-12 17:28
Logged In: YES 
user_id=94539

I can fix my particular problem by using packages and not
py_modules.
msg12372 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2002-11-06 15:01
Logged In: YES 
user_id=11375

Actually, it looks like there's code in build_py.py that does add the 
__init__.py file; see the find_modules() method.  It must be broken in some way.  I'll look into it.
msg12373 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2004-12-01 23:56
Logged In: YES 
user_id=752496

Please, could you verify if this problem persists in Python 2.3.4
or 2.4?

If yes, in which version? Can you provide a test case?

If the problem is solved, from which version?

Note that if you fail to answer in one month, I'll close this bug
as "Won't fix".

Thank you! 

.    Facundo
msg12374 - (view) Author: Facundo Batista (facundobatista) * (Python committer) Date: 2005-03-22 21:25
Logged In: YES 
user_id=752496

Deprecated. Reopen only if still happens in 2.3 or newer. 

.    Facundo
History
Date User Action Args
2022-04-10 16:05:40adminsetgithub: 37169
2002-09-11 20:13:16tepperlycreate