From 947eb6f00954ce607d865d6e43847b775fc3367b Mon Sep 17 00:00:00 2001
From: Gary Furnish <gfurnish@gfurnish.net>
Date: Fri, 25 Apr 2008 19:36:52 -0600
Subject: [PATCH] -w

---
 Cython/Compiler/CmdLine.py | 5 +++++
 Cython/Compiler/Main.py    | 5 ++++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Cython/Compiler/CmdLine.py b/Cython/Compiler/CmdLine.py
index 05a607a4a..1aa55d705 100644
--- a/Cython/Compiler/CmdLine.py
+++ b/Cython/Compiler/CmdLine.py
@@ -27,6 +27,9 @@ Options:
                                  performing any binary operations.
   --cleanup <level>              Release interned objects on python exit, for memory debugging. 
                                  Level indicates aggressiveness, default 0 releases nothing. 
+  -w, --working <directory>      Sets the working directory for Cython (the directory modules 
+                                 are searched from)
+
   -D, --no-docstrings            Remove docstrings.
   -a, --annotate                 Produce an colorized version of the source.
   --convert-range                Convert for loops using range() function to for...from loops. 
@@ -104,6 +107,8 @@ def parse_command_line(args):
                 options.include_path.append(get_param(option))
             elif option == "--include-dir":
                 options.include_path.append(pop_arg())
+            elif option in ("-w", "--working"):
+                options.working_path = pop_arg()
             elif option in ("-o", "--output-file"):
                 options.output_file = pop_arg()
             elif option in ("-p", "--embed-positions"):
diff --git a/Cython/Compiler/Main.py b/Cython/Compiler/Main.py
index ca8dc88d7..5d7f4207b 100644
--- a/Cython/Compiler/Main.py
+++ b/Cython/Compiler/Main.py
@@ -320,6 +320,8 @@ def main(command_line = 0):
         sources = args
     if options.show_version:
         print >>sys.stderr, "Cython version %s" % Version.version
+    if options.working_path!="":
+        os.chdir(options.working_path)
     context = Context(options.include_path)
     for source in sources:
         try:
@@ -347,7 +349,8 @@ default_options = dict(
     cplus = 0,
     output_file = None,
     generate_pxi = 0,
-    transforms = Transform.TransformSet())
+    transforms = Transform.TransformSet(),
+    working_path = "")
     
 if sys.platform == "mac":
     from Cython.Mac.MacSystem import c_compile, c_link, CCompilerError
-- 
2.30.9