Ignore explicitly relative 'from' imports when scanning for dependencies

Bug #746565 reported by Michael Terry
40
This bug affects 8 people
Affects Status Importance Assigned to Milestone
python-distutils-extra
Fix Released
Undecided
Unassigned
python-distutils-extra (Ubuntu)
Fix Released
Undecided
Unassigned
Natty
Fix Released
Undecided
Unassigned

Bug Description

===== SRU Justification =====

This causes a bad bug in Quickly (bug 775217). Basically, "quickly package" shows errors and suggests to the user that continuing is not safe. It is a bad user experience and a regression from past releases.

I wrote this patch here during natty's development to fix it, but it didn't make it in.

The attached debdiff will backport the upstream commit to natty's version of python-distutils-extra. I've uploaded it to natty-proposed as well.

To reproduce:
1) cd /tmp
2) quickly create ubuntu-application test-project
3) cd test-project
4) quickly package

What you see:
"""
----------------------------------
Command returned some ERRORS:
----------------------------------
ERROR: Python module test_projectconfig not found
ERROR: Python module Builder not found
ERROR: Python module helpers not found
ERROR: Python module preferences not found
ERROR: Python module Window not found
----------------------------------
Do you want to continue (this is not safe!)? y/[n]:
"""

What you should see:
"""Ubuntu package has been successfully created in ../test-project_0.1_all.deb"""

=============================

Submodules of a program may use relative imports. These should not be treated as dependency-generating imports that cause either printed errors if they're not defined or bogus dependencies.

So when scanning, we should ignore explicitly defined relative 'from' imports (they look like "from . sibling import foo" or "from .. uncle import bar").

Branch coming.

Revision history for this message
Martin Pitt (pitti) wrote :

Committed to trunk, thanks!

Changed in python-distutils-extra:
status: New → Fix Released
Revision history for this message
Martin Pitt (pitti) wrote :

Note that in the followup commit I rewrote the function to actually catch all relative imports (case 2 in the merge proposal). That allowed me to revert the node.level workaround again.

Revision history for this message
Michael Terry (mterry) wrote :

Ah, bummer, this never made it into natty. I really kind of needed it to, as it causes bad user experience in quickly.

I'll craft an SRU for it.

Michael Terry (mterry)
description: updated
Revision history for this message
Michael Terry (mterry) wrote :
Revision history for this message
Martin Pitt (pitti) wrote : Please test proposed package

Accepted python-distutils-extra into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in python-distutils-extra (Ubuntu Natty):
status: New → Fix Committed
tags: added: verification-needed
Revision history for this message
Martin Pitt (pitti) wrote :

I uploaded 2.27-1 to Debian unstable, which fixes this. We'll get it into oneiric in the next days through auto-syncs.

Changed in python-distutils-extra (Ubuntu):
status: New → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-distutils-extra - 2.27-1

---------------
python-distutils-extra (2.27-1) unstable; urgency=low

  * auto.py: Cleaner approach to determine whether a module is locally
    provided. This now catches all relative imports. (LP: #746565)
  * Fix installation of symlinks in data/ dir (LP: #770566):
    - test/auto.py: Add test for installing a symlink which points to a
      nonexisting target directory/file. This reproduces the gist of the
      problem.
    - test/auto.py: Preserve symlinks in copytree() calls, so that we can
      actually verify that symlinks are preserved properly.
    - test/auto.py: Drop requirement that diff throws no error messages, as it
      will complain about the broken symlink.
    - DistUtilsExtra/auto.py, install_auto: Use os.walk() instead of
      distutils.filelist.findall() to pick out symlinks, as the latter fails
      badly with broken symlinks.
    - DistUtilsExtra/command/build_icons.py: Ignore symbolic links. distutils
      breaks on them when they point to a nonexisting target, and we handle
      them in auto.py.
  * DistUtilsExtra/auto.py: Put back "except .. as" syntax, now that we
    dropped Python 2.5. Drop 2to3 from debian/rules for good now.
  * debian/control: Bump minimal Python version to >= 2.6.
 -- Ubuntu Archive Auto-Sync <email address hidden> Sun, 22 May 2011 13:55:08 +0000

Changed in python-distutils-extra (Ubuntu):
status: Fix Committed → Fix Released
Revision history for this message
Michael Terry (mterry) wrote :

This is another call for any interested parties to test and verify the fix in natty-proposed.

Revision history for this message
marmuta (marmuta) wrote :

Revision 248 breaks the package build for Onboard in Oneiric and according to Francesco Fumanti also in Natty.

setup.py: error: no such option: --build-base

The reason is apparently, that importing certain files triggers Onboards own command line processing, which obviously doesn't know or care about setup.py options.
I could work around this, but I wonder if it is safe to assume for DistUtilsExtra that importing files out of context doesn't have any adverse side effects.

Revision history for this message
Martin Pitt (pitti) wrote :

Marking as v-failed for now to prevent this from going into -updates. I'll investigate this more closely tomorrow.

tags: added: verification-failed
removed: verification-needed
Revision history for this message
Martin Pitt (pitti) wrote :

I confirmed the regression in onboard, and I also just happened to stumble over it in xdiagnose (where a module import throws an exception). I now added test cases for both variants (onboard and xdiagnose), and committed a fix:

  http://bazaar.launchpad.net/~python-distutils-extra-hackers/python-distutils-extra/debian/revision/256

I'll upload 2.28 now.

Changed in python-distutils-extra (Ubuntu Natty):
status: Fix Committed → Triaged
Revision history for this message
Michael Terry (mterry) wrote :

I've uploaded a new natty-proposed version with your latest upstream changes mentioned in comment #11. I'd really like to see this land in natty.

Revision history for this message
Chris Halse Rogers (raof) wrote :

Hello Michael, or anyone else affected,

Accepted python-distutils-extra into natty-proposed, the package will build now and be available in a few hours. Please test and give feedback here. See https://wiki.ubuntu.com/Testing/EnableProposed for documentation how to enable and use -proposed. Thank you in advance!

Changed in python-distutils-extra (Ubuntu Natty):
status: Triaged → Fix Committed
tags: removed: verification-failed
tags: added: verification-needed
Revision history for this message
Paolo Sammicheli (xdatap1) wrote :

Hello,

I just checked the 2.26-2ubuntu0.2 version available in proposed and it solve the problem.

Thanks!

tags: added: verification-done
removed: verification-needed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-distutils-extra - 2.26-2ubuntu0.2

---------------
python-distutils-extra (2.26-2ubuntu0.2) natty-proposed; urgency=low

  * debian/patches/ignore-relative-imports.patch:
    - Update with a further fix from trunk to fix a couple regressions

python-distutils-extra (2.26-2ubuntu0.1) natty-proposed; urgency=low

  * debian/patches/ignore-relative-imports.patch:
    - Backport from trunk to ignore relative imports in source packages.
      This prevents Quickly from treating its own relative imports as
      errors. LP: #746565
 -- Michael Terry <email address hidden> Thu, 18 Aug 2011 14:27:05 -0400

Changed in python-distutils-extra (Ubuntu Natty):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.