Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'importing': 0.04; 'interpreter': 0.04; 'processed': 0.05; 'startup': 0.05; 'frontend': 0.07; 'skip:/ 10': 0.07; 'scripts': 0.09; 'python': 0.09; 'app,': 0.09; 'filesystem': 0.09; 'imported': 0.09; 'libraries.': 0.09; 'module)': 0.09; 'subject:Why': 0.09; 'thread': 0.11; "wouldn't": 0.11; 'suggest': 0.11; 'cleanly': 0.16; 'complaints,': 0.16; 'duplicating': 0.16; 'libraries?': 0.16; 'modules,': 0.16; 'received:192.168.1.50': 0.16; 'reusable': 0.16; 'similarly,': 0.16; 'thread.': 0.16; 'uses,': 0.16; 'virtualenv.': 0.16; 'wrote:': 0.17; 'basically': 0.17; 'certainly': 0.17; 'directory.': 0.17; 'saying': 0.18; 'code,': 0.18; 'requests': 0.18; 'module': 0.19; 'causing': 0.20; 'import': 0.21; 'libraries': 0.22; 'option.': 0.22; "i'd": 0.22; 'for?': 0.23; 'purposes': 0.23; "python's": 0.23; 'third-party': 0.23; 'installed': 0.23; 'random': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'guess': 0.27; 'core': 0.27; 'library.': 0.27; 'actual': 0.28; 'environment': 0.29; '"who': 0.29; 'dan': 0.29; 'separated': 0.29; 'starts': 0.29; 'probably': 0.29; 'usually': 0.30; 'ends': 0.30; 'stuff': 0.30; 'code': 0.31; 'point': 0.31; '(and': 0.32; 'gets': 0.32; 'asking': 0.32; 'could': 0.32; "aren't": 0.33; 'to:addr:python-list': 0.33; 'point.': 0.33; 'another': 0.33; 'skip:d 20': 0.34; 'that,': 0.34; 'version': 0.34; 'done': 0.34; 'clear': 0.35; 'adds': 0.35; 'built-in': 0.35; 'consistent': 0.35; 'same.': 0.35; 'pm,': 0.35; 'subject:?': 0.35; 'something': 0.35; 'there': 0.35; 'but': 0.36; '(i.e.': 0.36; 'modules': 0.36; 'should': 0.36; 'does': 0.37; 'option': 0.37; 'two': 0.37; 'why': 0.37; 'virtual': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'things': 0.38; 'nothing': 0.38; 'sure': 0.38; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'little': 0.39; 'application': 0.40; 'received:192.168': 0.40; 'subject:-': 0.40; 'think': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'kind': 0.61; 'received:62': 0.62; 'worth': 0.63; 'different': 0.63; 'more': 0.63; 'making': 0.64; 'jul': 0.65; 'today': 0.67; 'advantages': 0.71; 'about,': 0.84; 'application?': 0.84; 'cuts': 0.84; 'from:addr:t': 0.84; 'irrelevant': 0.84; 'received:62.75': 0.84; 'site?': 0.84; 'thing,': 0.84 Date: Tue, 03 Jul 2012 23:58:30 +0200 From: Thomas Jollans User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:13.0) Gecko/20120615 Thunderbird/13.0.1 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Why site-packages? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 114 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1341352718 news.xs4all.nl 6946 [2001:888:2000:d::a6]:37053 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:24836 On 07/03/2012 11:34 PM, Dan Stromberg wrote: > On Tue, Jul 3, 2012 at 9:04 PM, Ian Kelly > wrote: > > On Tue, Jul 3, 2012 at 2:40 PM, Dan Stromberg > wrote: > > > > Why is it that so much 3rd party python code gets installed to > > site-packages? > > Because that's what site-packages is for? > > > Agh. But -why- is it because that's what it's for? > > "Who made this rule"? It's (reasonably) consistent with the way things are usually done on UNIX. Libraries go in /usr/lib. That's all libraries, not just core system libraries. Similarly, Python modules go in /usr/lib/python. That's all Python modules, not just the standard library. That means that you can use them in scripts without faffing around because the interpreter will find them, even if you're in a completely random directory. The point of site-packages then is to make sure that user-installed packages are cleanly separated from standard and distribution-installed packages, similarly to the way /usr/local/ is used in general (and can be used for Python packages, of course) > > > > Even for things that are almost certainly going to be used by a single > > application? > > > > Even for things you might only use once? > > > > Even for things that might require one version for one app, and > another > > version for another app? > > For these types of uses, I suggest using virtualenv if you don't want > to pollute your site-packages. Or Python 3.3 with the new built-in > virtual environment option. > > Virtualenv is worth thinking about, but it kind of does the same thing, > just less of it. > > > > Why not stash an application's python modules in > /usr/local/lib/[appname], > > and stash a little frontend in /usr/local/bin that adds > > /usr/local/lib/[appname] to sys.path? > > What if you then write an application that you find needs two of these > libraries? You write yet another frontend that adds both of them to > sys.path? > > If it was intended to be reusable code, I'd think it -should- go in > site-packages. > > But so much code in site-packages isn't intended to be reusable. > > And even for stuff that's reusable, there are advantages to just > duplicating them for the purposes of each application, because you never > know when one of them is going to need a different version from another. > > If we weren't stashing so much stuff in site-packages, there probably > wouldn't have been a desire for something like virtualenv. > > > > Here's a thread on stackoverflow today asking why python starts up so > > slowly, and making it clear that this is because so much stuff > ends up in > > site-packages: > > > http://stackoverflow.com/questions/11318028/is-it-safe-to-use-pythons-s-option > > I think you may be misunderstanding that thread. They're saying that > starting Python with the -S option (i.e. not automatically importing > the site module) significantly cuts down on Python's startup time. > > Yes... > > > The site module has to process any .pth files in the site-packages, > but apart from that, I think the actual amount of stuff in > site-packages should be irrelevant. > > Irrelevant to what? More stuff in site slowing things down? Are > .pth's not correlated with more stuff in site-packages? Aren't they > actually a thing In site? > > > Nothing in site-packages is > actually imported or otherwise processed until the application > requests it. > > Other than .pth's, apparently. > > > You could have a completely empty site-packages, or you > could have 20 gigs of third-party packages, and the time to import > site would be basically the same. > > Well, I'd guess that a large directory would slow things down before > causing filesystem complaints, but I see your point. > > >