How does a setup script conditionally change what modules are installed based 
on version?


Background:

  I have a python2.x/3.x module that puts 3.3-only code in submodules.  When 
the module imports those submodules using an older python version, the compiler 
raises SyntaxErrors in the submodule which show as import errors in the module, 
get caught and ignored.  The features in the submodule won't be available, but 
they wont stop the module from functioning.  The problem syntax to be masked is 
the 'yield from' expression.

Problem:

  Thie above works, resulting in a functioning module under a range of python 
versions, but older versions want to compile all .py modules as part of 
setup.py install, and that produces ugly install messages, with stack-traces.  
I would like to avoid the ugliness.

  I can add python code to setup.py, before the setup(...) call, but it is 
unclear what will be available to that code, at that time.  I can test for 
whether setup.py is being run in install mode using "if 'install' in 
sys.argv:", and delete the offending .py submodules, but can I assume that the 
dir holding setup.py is the current dir during install?  Does the MANIFEST need 
to be altered, also, to match the changed file collection?

Alternatively, I could alter the MANIFEST.in to add 'prune..' statements, but 
is that file even used as part of install?

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to