[Twisted-Python] "twistd" in Twisted 16.4.0 can't import modules/packages from current working directory

Jean-Paul Calderone exarkun at twistedmatrix.com
Mon Jan 2 07:10:46 MST 2017


On Thu, Sep 1, 2016 at 11:36 AM, Amber "Hawkie" Brown <
hawkowl at atleastfornow.net> wrote:

>
> > On 1 Sep 2016, at 21:42, Yuri <yuri_abzyanov at fastmail.fm> wrote:
> >
> > Hi all
> >
> > I couldn't find Twisted-specific group, so posting here.
> >
> > Recently Twisted 16.4.0 got released. Yesterday I've tried to upgrade it
> for my apps and got an error.
> >
> > ...
> >
> > The errors comes down to this: twistd script does not add current
> working directory to python path (or removes it, I don't know what exactly
> happens), so it fails to import any packages/modules from it. The issue
> does not appear in previous version (Twisted 16.3.2).
> >
> > Any ideas what caused it?
>
> Yes -- we moved to using setuptools console scripts, and these console
> scripts don't add "." to the PYTHONPATH. We realised this in prerelease but
> decided against fixing it, as it adding the current working dir to the PATH
> has lead to a lot of  subtle bugs in the past and this is a good chance to
> make a break from them.
>
> So, in short, this is expected behaviour -- we generally want people to be
> running twistd, trial, etc on *installed* Python packages -- testing or
> running from checkouts often hides many bugs about what is or isn't
> included in the installed package by accident. If you rely on this
> behaviour, though, set the PYTHONPATH environment variable to "." -- e.g.
> `env PYTHONPATH=. twistd -n myplugin`.
>
>
FWIW, as a user, it would have been nice to have a NEWS entry for this.  It
would have been easier to discover there than searching through the mail
archives.

Thanks,
Jean-Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20170102/e8cb6909/attachment.html>


More information about the Twisted-Python mailing list