#1539 closed enhancement (wontfix)

stop putting pkg_resources.require() into .tac files

Reported by: zooko Owned by: daira
Priority: major Milestone: 1.10.1
Component: code-nodeadmin Version: 1.9.0a1
Keywords: forward-compatibility appname tac packaging setuptools test-needed Cc:
Launchpad Bug:

Description (last modified by zooko)

Per comment:1:ticket:1159:

One thing that we can do right away to ease this is change create-node to stop putting the call to pkg_resources.require() in the tahoe-client.tac.

Attachments (1)

1539-smaller-tac.diff (1.1 KB) - added by warner at 2012-05-23T04:58:44Z.
remove pkg_resources calls from generated .tac files

Download all attachments as: .zip

Change History (19)

comment:1 Changed at 2011-09-24T00:13:12Z by davidsarah

  • Milestone changed from undecided to 1.10.0
  • Owner set to davidsarah
  • Status changed from new to assigned

Agreed.

comment:2 follow-up: Changed at 2011-09-24T03:06:12Z by zooko

There are two calls to pkg_resources.require() in the .tac files that we currently produce. According to 1aed9fcfa1c45538 the patch that added them, this was necessary to make them importable if they were installed in setuptools's "multiversion mode". I don't think we need to support that. We experimented with it (see #530) and removing multiversion mode from our setup.py did not break any of our unit tests, not even test-with-fake-pkg or test-with-fake-dists.

comment:3 in reply to: ↑ 2 Changed at 2011-09-24T03:48:24Z by davidsarah

Replying to zooko:

There are two calls to pkg_resources.require() in the .tac files that we currently produce. According to 1aed9fcfa1c45538 the patch that added them, this was necessary to make them importable if they were installed in setuptools's "multiversion mode".

Those calls should never have been necessary even for multiversion mode; I think the commit comment was wrong. pkg_resources.require() does not, despite the misleading name and documentation, make a package available that wouldn't already have been available. The set of packages available in the working set is determined at the point of first importing pkg_resources, which happens in the setuptools-generated support script, long before the .tac is executed.

So I guess I'm violently agreeing with your conclusion that these calls aren't necessary ;-)

comment:4 Changed at 2012-04-01T03:55:22Z by davidsarah

  • Milestone changed from 1.11.0 to 1.10.0

Changed at 2012-05-23T04:58:44Z by warner

remove pkg_resources calls from generated .tac files

comment:5 Changed at 2012-05-23T04:59:13Z by warner

  • Keywords needs-review added

something like that?

comment:6 Changed at 2012-05-23T15:43:43Z by davidsarah

  • Description modified (diff)
  • Keywords review-needed added; needs-review removed
  • Status changed from assigned to new

Will review.

Note that import pkg_resources has side effects on sys.path even if pkg_resources.require() is not used; so, removing the import might have an additional effect. I can't immediately remember whether that's desirable or not; need to page this stuff back into my brain.

comment:7 Changed at 2012-05-23T15:43:52Z by davidsarah

  • Status changed from new to assigned

comment:8 Changed at 2012-05-23T16:24:51Z by zooko

According to 1aed9fcfa1c45538, I added that so that it would find an allmydata and twisted package tht had been installed in "multi-version mode". I guess that mode of install offered by setuptools doesn't put the installed egg into the sys.path at *all* until a pkg_resources.require() with a matching version number has been invoked. We experimented with it at one point as a way to work around other problems, but I believe we gave up on using it.

Last edited at 2013-09-20T19:48:25Z by zooko (previous) (diff)

comment:9 Changed at 2012-09-04T16:11:13Z by davidsarah

Obsolete if we accept #1159.

comment:10 Changed at 2013-03-21T18:44:48Z by warner

  • Milestone changed from 1.10.0 to 1.11.0

I want this, but won't block 1.10 for it. Kicking it and its cousin #1159 into 1.11.

comment:11 Changed at 2013-08-28T15:58:55Z by zooko

  • Description modified (diff)
  • Milestone changed from soon to 1.11.0

comment:12 Changed at 2014-03-20T15:44:34Z by remyroy

  • Owner changed from davidsarah to remyroy
  • Status changed from assigned to new

I'll be doing the review on this one.

comment:13 Changed at 2014-03-20T15:44:41Z by remyroy

  • Status changed from new to assigned

comment:14 Changed at 2014-03-20T18:23:50Z by daira

I would prefer to keep the pkg_resources import just because:

  • removing it isn't necessary for the purpose of this patch;
  • importing pkg_resources can change sys.path, which can change where allmydata is imported from.

If the .tac file is run via tahoe start or tahoe run, then pkg_resources will already have been imported and therefore importing it again will have no effect -- but this is dependent on the current implementation of tahoe start/run. If the .tac were run directly via twistd or another Python application, then this could have an effect. It is never correct to import allmydata and then have the sys.path change as a result of importing pkg_resources, so it is safer to import it first. (When we switch to not using the contents of the .tac files, it won't matter either way, but we're not doing that yet.)

comment:15 Changed at 2014-03-21T18:40:03Z by remyroy

  • Keywords test-needed added; review-needed removed

Review of 1539-smaller-tac.diff​:

Everything is great except that it breaks the following test: allmydata.test.test_drop_upload.RealTest?.test_drop_upload . The patch should be changed so that no test is broken.

daira has an objection to this change so I'm not sure who I should reassign this to.

Last edited at 2014-03-21T18:55:51Z by remyroy (previous) (diff)

comment:16 Changed at 2014-03-21T18:42:18Z by remyroy

  • Owner changed from remyroy to zooko
  • Status changed from assigned to new

comment:17 Changed at 2014-09-02T18:03:14Z by daira

  • Owner changed from zooko to daira
  • Status changed from new to assigned

I will review this together with #1159.

comment:18 Changed at 2014-10-27T01:22:17Z by daira

  • Resolution set to wontfix
  • Status changed from assigned to closed

This is wontfix because we decided to stop using the contents of .tac files instead (#1159, fixed in 87a6894e6299148d639279fbd909110ba00d0080).

Last edited at 2014-10-27T01:22:40Z by daira (previous) (diff)
Note: See TracTickets for help on using tickets.