Commits

Peter Sagerson committed cdf684e

Working distutils integration.

virtualenv-sh.zwc has to be compiled manually.

  • Participants
  • Parent commits d570ad8

Comments (0)

Files changed (6)

-^build/
+^_build/
+^scripts/
 ^doc/_build/
 ^dist/
 ^MANIFEST$
 recursive-include bin *
 recursive-include functions *
 recursive-include test *
+recusrive-include doc *
+
+include scripts/virtualenv-sh.*sh
 
 include README LICENSE Makefile setup.py
+
+global-exclude .DS_Store
 VPATH = functions
+BUILD = _build
+SCRIPTS = scripts
 
 base_functions = \
 	autoworkon \
 
 all: sh bash zsh
 
-sh: build/virtualenv-sh.sh
-build/virtualenv-sh.sh: $(base_functions)
-	@mkdir -p build/sh
-	cp $^ build/sh
-	sh bin/build-monolithic.sh build/sh/* > build/virtualenv-sh.sh
-	@rm -r build/sh
+sh: build-prep $(SCRIPTS)/virtualenv-sh.sh
+$(SCRIPTS)/virtualenv-sh.sh: $(base_functions)
+	rm $(BUILD)/* || true
+	cp $^ $(BUILD)
+	sh bin/build-monolithic.sh $(BUILD)/* > $(SCRIPTS)/virtualenv-sh.sh
 	@echo
 
-bash: build/virtualenv-sh.bash
-build/virtualenv-sh.bash: $(base_functions) $(bash_functions)
-	@mkdir -p build/bash
-	cp $^ build/bash
-	sh bin/build-monolithic.sh build/bash/* > build/virtualenv-sh.bash
-	@rm -r build/bash
+bash: build-prep $(SCRIPTS)/virtualenv-sh.bash
+$(SCRIPTS)/virtualenv-sh.bash: $(base_functions) $(bash_functions)
+	rm $(BUILD)/* || true
+	cp $^ $(BUILD)
+	sh bin/build-monolithic.sh $(BUILD)/* > $(SCRIPTS)/virtualenv-sh.bash
 	@echo
 
-zsh: build/virtualenv-sh.zsh build/virtualenv-sh.zwc
-build/virtualenv-sh.zsh build/virtualenv-sh.zwc: $(base_functions) $(zsh_functions)
-	@mkdir -p build/zsh
-	cp $^ build/zsh
-	sh bin/build-monolithic.sh build/zsh/* > build/virtualenv-sh.zsh
-	if [ $$(which zsh) ]; then zsh bin/compile-all.zsh build/zsh/*; fi
-	@rm -r build/zsh
+zsh: build-prep $(SCRIPTS)/virtualenv-sh.zsh $(SCRIPTS)/virtualenv-sh.zwc
+$(SCRIPTS)/virtualenv-sh.zsh $(SCRIPTS)/virtualenv-sh.zwc: $(base_functions) $(zsh_functions)
+	rm $(BUILD)/* || true
+	cp $^ $(BUILD)
+	sh bin/build-monolithic.sh $(BUILD)/* > $(SCRIPTS)/virtualenv-sh.zsh
+	if [ $$(which zsh) ]; then zsh -c "zcompile -U $(SCRIPTS)/virtualenv-sh.zwc $(BUILD)/*"; fi
 	@echo
 
+build-prep:
+	mkdir -p $(SCRIPTS)
+	mkdir -p $(BUILD)
+
 
 install: install-sh install-bash install-zsh
 
 install-sh: sh
-	cp build/virtualenv-sh.sh /usr/local/bin
+	cp $(SCRIPTS)/virtualenv-sh.sh /usr/local/bin
 
 install-bash: bash
-	cp build/virtualenv-sh.bash /usr/local/bin
+	cp $(SCRIPTS)/virtualenv-sh.bash /usr/local/bin
 
 install-zsh: zsh
-	cp build/virtualenv-sh.zsh /usr/local/bin
-	if [ -e build/virtualenv-sh.zwc ]; then cp build/virtualenv-sh.zwc /usr/local/bin; fi
+	cp $(SCRIPTS)/virtualenv-sh.zsh /usr/local/bin
+	if [ -e $(SCRIPTS)/virtualenv-sh.zwc ]; then cp $(SCRIPTS)/virtualenv-sh.zwc /usr/local/bin; fi
 
 
 clean:
-	rm -rf build/*
+	rm -rf $(BUILD)/* || true
+	rm -rf $(SCRIPTS)/* || true
 
 
 test: test-sh test-bash test-ksh test-zsh
 
 test-sh: sh
 	@echo Testing with $$(which sh)
-	@cd test; if [ $$(which sh) ]; then sh ./test.sh ../build/virtualenv-sh.sh; else echo "sh is not in the path"; fi
+	@cd test; if [ $$(which sh) ]; then sh ./test.sh ../$(SCRIPTS)/virtualenv-sh.sh; else echo "sh is not in the path"; fi
 	@echo
 
 test-bash: bash
 	@echo Testing with $$(which bash)
-	@cd test; if [ $$(which bash) ]; then bash ./test.sh ../build/virtualenv-sh.bash; else echo "bash is not in the path"; fi
+	@cd test; if [ $$(which bash) ]; then bash ./test.sh ../$(SCRIPTS)/virtualenv-sh.bash; else echo "bash is not in the path"; fi
 	@echo
 
 test-ksh: sh
 	@echo Testing with $$(which ksh)
-	@cd test; if [ $$(which ksh) ]; then ksh ./test.sh ../build/virtualenv-sh.sh; else echo "ksh is not in the path"; fi
+	@cd test; if [ $$(which ksh) ]; then ksh ./test.sh ../$(SCRIPTS)/virtualenv-sh.sh; else echo "ksh is not in the path"; fi
 	@echo
 
 # The current version of shunit2 doesn't seem to play well with zsh, but here
 # it is.
 test-zsh: zsh
 	@echo Testing with $$(which zsh)
-	@cd test; if [ $$(which zsh) ]; then zsh ./test.sh ../build/virtualenv-sh.zsh; else echo "zsh is not in the path"; fi
+	@cd test; if [ $$(which zsh) ]; then zsh ./test.sh ../$(SCRIPTS)/virtualenv-sh.zsh; else echo "zsh is not in the path"; fi
 	@echo

bin/compile-all.zsh

-#!/bin/zsh
-
-zcompile -U build/virtualenv-sh.zwc "$@"
 Installing
 ==========
 
-At present, this can't be installed by pip or easy_install, so it takes a
-couple of steps::
-
-    > pip install --no-install virtualenv-sh
-    > cd build/virtualenv-sh
-    > sudo python setup.py install
-
-Building this project generates a file of shell functions that must be sourced
-in your shell environment; it will be installed to /usr/local/bin. If you're
-using bash or zsh, you should import the shell-specific script; otherwise, you
-can try the generic one. Add *one* of the following to your shell's init
-script (.bashrc, .zshrc, etc.)::
+virtualenv-sh can be installed with pip or easy_install. To use it, you need
+to source a single shell script in your shell environment. By default, pip or
+easy_install should install it to /usr/local/bin. If you're using bash or zsh,
+you should import the shell-specific script; otherwise, you can try the
+generic one. Add *one* of the following to your shell's init script (.bashrc,
+.zshrc, etc.)::
 
     . /usr/local/bin/virtualenv-sh.bash
 
 
     . /usr/local/bin/virtualenv-sh.sh
 
-If you're using zsh, you can instead use the precompiled function archive for
-optimal performance. You may want to refer to the section on function
-autoloading in the zsh manual if you're not familiar with this process::
-
-    # Configure all virtualenv-sh functions for autoloading
-    fpath=(/usr/local/bin/virtualenv-sh $fpath)
-    autoload -w /usr/local/bin/virtualenv-sh
-
-    # Call the main initialization function
-    virtualenv_sh_init
-
 Nothing else is required. There's only one environment variable that you can
 use for configuration, which is WORKON_HOME. This is a path to your collection
 of virutalenvs; you can leave it blank to accept the default of
     WORKON_HOME=${HOME}/.virtualenvs
 
 
+zsh
+---
+
+If you're using zsh, you can instead use the precompiled function archive for
+optimal performance, although this needs to be compiled from source on your
+machine. You can download the source directly or try::
+
+    > pip install --upgrade --no-install virtualenv-sh
+    > cd build/virtualenv-sh
+    > sudo make install
+
+This will find zsh in your path, use it to compile virtualenv-sh.zwc, and
+install it to /usr/local/bin. You can now autoload these functions and
+initialize virtualenv-sh. You may want to refer to the section on function
+autoloading in the zsh manual if you're not familiar with this process::
+
+    # Configure all virtualenv-sh functions for autoloading
+    fpath=(/usr/local/bin/virtualenv-sh $fpath)
+    autoload -w /usr/local/bin/virtualenv-sh
+
+    # Call the main initialization function
+    virtualenv_sh_init
+
+
 Using
 =====
 
-import subprocess
-
-from distutils.command.build import build
-from distutils.command.install import install
 from distutils.core import setup
 
 
-class VirtualenvSHBuild(build):
-    def run(self):
-        subprocess.call(['make'])
-
-
-class VirtualenvSHInstall(install):
-    def run(self):
-        subprocess.call(['make', 'install'])
-
-
 setup(
     name='virtualenv-sh',
     version='0.1',
     author_email='psagers.pypi@ignorare.net',
     license='BSD, Public Domain',
     packages=[],
+    scripts=[
+        'scripts/virtualenv-sh.sh',
+        'scripts/virtualenv-sh.bash',
+        'scripts/virtualenv-sh.zsh',
+    ],
     classifiers=[
         'Programming Language :: Unix Shell',
         'Environment :: Console',
         'License :: Public Domain',
     ],
     keywords=['virtualenv'],
-    cmdclass={'build': VirtualenvSHBuild, 'install': VirtualenvSHInstall},
 )