[Biopython-dev] Need guidance.

Adil Iqbal aiqbal85 at gmail.com
Thu Jun 15 04:43:28 UTC 2017

Hey, though I managed to solve the importing issue, in my conversation with
Peter, I realized I made a rather large decision without consulting the

In my current build, I am omitting all modules that are not part of the Bio
package from executing doctests in version 2.7.

My reason for doing that is copy-pasted below this message. Please read it
for context.

I realize that 'testseq' is the only module this change effects but is it
something that we should extend to future modules?


That method will certainly succeed in importing the ['testseq'] module. The
issue is that once the importing is complete, the doctests are run. And the
doctest *also* contain an import statement. The doctests cause an error in
2.7 <https://travis-ci.org/biopython/biopython/jobs/242258938> because they
are subject to the same importing limitations as "run_tests.py". I will now
describe these limitations below:

Prior to 3.3, hierarchical importing (with "dot" notation) required a
directory to be initialized with a "__init__.py" file. With the
introduction of 3.3, hierarchical importing was generalized to all
directories, regardless of initialization. This is why my commits were
passing all tests except 2.7.

Since we can't initialize folders carelessly, its best to remove the non-Bio
modules from the "run_tests.py" file just prior to version 3.3. All
versions of python after-and-including 3.3 don't require an extra
"__init__.py" file, so the doctests will run fine on 3.3, 3.4, 3.5, and
3.6. That's why the most recent build passed the Travis CI test.

I agree that my import methods were becoming overly-complicated. In the
most recent build, I've eliminated the complicated code in favor of just
deleting non-Bio files.
only complicated code left is limited to *just* the unit test

Thankfully, the unit test for 'testseq' runs all of the same tests that are
in the doctests, so we can be confident that 'testseq' is compatible with
all versions of python. In the future, if "biopython" decides to stop
supporting python 2.7, I would be happy to remove the last bit of
complicated code.

TL:DR - In 2.7 only: Modules outside 'Bio' package *can* be imported from
"run_tests.py", however, their doctests will likely fail because they must
also contain import statements. It's best to remove them from doctesting in
earlier versions of python and allow the unit tests to confirm
compatibility. (Only for non-Bio files in only 2.7).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.open-bio.org/pipermail/biopython-dev/attachments/20170614/0e1a03a9/attachment.html>

More information about the Biopython-dev mailing list