setup.py install and compile errors

D

David

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 beavailable, 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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top