Man, global system-wide installations that require admin rights by default? That's certainly something! Quite the stark comparison to Node.js and npm, where everything is installed locally into the current directory (under node_modules) by default, and "global" installation is actually a per-user installation. Tricking pip with virtualenv seems to get you pretty close to what you get by default with npm, albeit still…
npm's default for -g is to install to Node's prefix, which is usually /usr or /usr/local. If you want it to install to your home directory, you can set the prefix to somewhere appropriate in your ~/.npmrc, which gives roughly the same behavior as pip's --user flag. Edit: perhaps you changed your .npmrc or set the option via npm and forgot about it? I just checked on a fresh user, and 'npm install -g' definitely tries…
A non-magical introduction to pip and virtualenv for Python beginners
61–70 of 86 posts
Re: A non-magical introduction to pip and virtualenv for Python beginners
#62Re: A non-magical introduction to pip and virtualenv for Python beginners
#63Re: A non-magical introduction to pip and virtualenv for Python beginners
#64For Mac, am I better off with Homebrew? http://docs.python-guide.org/en/latest/starting/install/osx/... https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
In the real world, a typical pip requirements.txt file will have a mix of package names (which pip looks for and downloads from an index like pypi), git repo urls (eggs installed directly from a git server, eg from github) and bleeding edge track the latest changes -e git-repo#egg=eggname urls. That you can switch between these with ease is important, eg to switch to using your fork of some package rather than the last official release.
Re: A non-magical introduction to pip and virtualenv for Python beginners
#65I'd like to know what the best practices with regards to security are for using pip, or installing packages in general. How do you verify package integrity? Do you simply pray that PyPI isn't compromised at the moment, or do you download your packages from Github instead, because the main repositories have more eyeballs on them? How do you do security updates with pip? I'm using apt-get at the moment which gives me s…
You might also like to check out wheel, which allows you to compile signed binary distributions that you can install using pip.
Re: A non-magical introduction to pip and virtualenv for Python beginners
#66For Mac, am I better off with Homebrew? http://docs.python-guide.org/en/latest/starting/install/osx/... https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
I'd never have believed a day would come where something like Homebrew would ever gain the traction it has.
Re: A non-magical introduction to pip and virtualenv for Python beginners
#67When you create the virtualenv, the current package you're working on doesn't get added to site-packages, so you're forced to be at the repository root to import the package.
The best approach is to have a proper setup.py file so you can do `python setup.py develop`, which will link the package you're working on into the virtualenv site-packages. This way it acts as it's installed and you can import anyway you like.
If you define your requirements on the setup.py (I think you should), you can even skip the `pip install -r requirements.txt` step.
I've cooked up a package template that can help getting this working:
Re: A non-magical introduction to pip and virtualenv for Python beginners
#68> Python actually has another, more primitive, package manager called easy_install, which is installed automatically when you install Python itself. It's actually not, it's part of setuptools/distribute, though some Python distributions (actually just brew that I know of) include distribute alongside Python. Also, while the quick skim of the rest of this looks mostly good, there's some unnecessary advice which compli…
I recently learned the lesson about global packages. I thought it would be so nice to have all packages readily on hand, but now startup time is about 15 seconds of crawling the filesystem looking for files (over NFS). Go is looking more attractive day by day.....
"Well, stop doing it then..."
Jests aside - Go is appealing for many reasons but your self-inflicted pain is not necessarily one of them. ;-)
Re: A non-magical introduction to pip and virtualenv for Python beginners
#69For Mac, am I better off with Homebrew? http://docs.python-guide.org/en/latest/starting/install/osx/... https://github.com/mxcl/homebrew/wiki/Homebrew-and-Python
Think that virtualenv is way to package a complete Python environment together with the package you need or are working on.
Re: A non-magical introduction to pip and virtualenv for Python beginners
#70Man, global system-wide installations that require admin rights by default? That's certainly something! Quite the stark comparison to Node.js and npm, where everything is installed locally into the current directory (under node_modules) by default, and "global" installation is actually a per-user installation. Tricking pip with virtualenv seems to get you pretty close to what you get by default with npm, albeit still…
The primary use case of npm is quite different. No one installs system-wide npm packages.
Virtualenv solves a different problem (create a complete Python environment inside a directory) so you can replicate the various production setups in your machine and develop. It's not a way to avoid admin-privileges to install system software, for that you can just pip install --user, use homebrew, whatever.