Py2 + PY3 transform a project (git submodule) to a clean package (with setup.py)

Gelonida N gelonida at gmail.com
Fri Jan 15 06:52:24 EST 2016


Hi,

I'm having a git project which contains functionality, that I use in 
many of my projects.

For this posts sake let's call it mylib.

if mylib is in the python path, it can be used for quite some 
convenience function in many of my projects.

Examples:
from mylib.logging import setupLoggingForMyProjects

The directory structure of my git project is at the moment:

mylib/               # base directory of the git repository
mylib/.git           # all git related information
mylib/__init__.py    # file to mark the directory as a pkg
mylib/logging.py     # helper for logging to import as mylib.logging
mylib/collections.py # MY custom collections
mylib/helper1.py     # helper1 to import as mylib.helper1
. . .


Many of my projects use the git repository of mylib as a git submodule 
and everything works as expected.  All changes in this repository are 
backwards compatible, so that I can update the submodule at any time and 
put it to the new head of the master branch

Now I'd like to change my project such, that it can be installed with 
pip install

However I'd like to perform the changes such, that none of my old 
projects will be broken even if I update the sub module.


The normal approach would be to change the directory structure to:

mylib/ # the base directory of the git repository
mylib/setup.py    # the setup script as intended one level up
mylib/.git
mylib/mylib/__init__.py
mylib/mylib/logging.py
mylib/mylib/collections.py
mylib/mylib/helper1.py
. . .


This would however break all of my currently existing projects if I 
update the submodule mylib.
So what I think  need is something like:
mylib/ #
mylib/setpup.py   # setup script in same level as module
mylib/.git
mylib/__init__.py
mylib/logging.py
mylib/collections.py
mylib/helper1.py
. . .


Is this possible?
The problem seems to be, that setup.py wants to import logging and 
collections, but imports mylib.collections.
Any tips / tricks?

I thought about changing the python path and the current wrokig 
directory in the head of the setup.py script but am not sure, this will 
work without any trouble.

Thanks in advance for any suggestions









More information about the Python-list mailing list