question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Potential incorrect sys.path munging inside tasks

See original GitHub issue

Description

Problem:

  • sys.path at fabfile module level seems to be fine
  • However, inside fabfile tasks/functions, sometimes sys.path appears to lose the first element, possibly only when that element is the empty string (i.e. when your cwd is in sys.path)
  • This does not appear reproducible all the time, but was noticed by an IRC user and confirmed by (IIRC) Morgan shortly thereafter.
  • The only place in the code Fabric modifies or mentions sys.path is fabric.main.load_fabfile.

To do:

  • Test load_fabfile (right now, seems best way is to use dependency injection so we don’t have to try mocking eg __import__ [which doesn’t appear to work anyway]) to try and nail down the edge case
  • If bug is found, fix it!

Originally submitted by Jeff Forcier (bitprophet) on 2010-11-12 at 09:18pm EST


Closed as Worksforme on 2011-03-10 at 01:08pm EST

Issue Analytics

  • State:closed
  • Created 12 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
anentropiccommented, Dec 4, 2013

ok found one:

from fabric.api import task
from fabric.contrib import django

django.settings_module('myapp.settings')
from django.conf import settings
_ = settings.INSTALLED_APPS

@task
def mytask():
    # can now use settings.WHATEVER here
0reactions
anentropiccommented, Dec 4, 2013

In the meantime is there a workaround to make fabric.contrib.django.settings_module() actually work as per the docs?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to prepend a path to sys.path in Python? - Stack Overflow
by prepending the path to Ubuntu's Python package (for my machine, this happens in usr/local/lib/python2. 7/dist-packages/easy-install.
Read more >
With Enum34 installed on python3.6+, pip picks up ... - GitHub
The reason is that __main__.py has code which changes sys.path in case we are running pip from a wheel. That code appears to...
Read more >
PEP 587 "Python Initialization Configuration": 3rd version
of the configuration: configure where Python looks for modules (sys.path). I added PyWideStringList_Insert() to allow to prepend a path in ...
Read more >
Configuration Reference - Puppet
Valid values are true (autosigns all certificate requests; not recommended), false (disables autosigning certificates), or the absolute path to a file. The file ......
Read more >
PEP 302 – New Import Hooks - Python Enhancement Proposals
It has very complex semantics and responsibilities. __import__ gets called even for modules that are already in sys.modules , which is ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found