Repository: pypa/setuptools

Issue:
AttributeError: 'module' object has no attribute 'chdir' in 25.0.1
The new `setuptools == 25.0.1` just failed on our CI with `AttributeError: 'module' object has no attribute 'chdir'`.

The new expression [`here and os.path.chdir(here)`](https://github.com/pypa/setuptools/blob/21ab99e53f0c263a2210cf51525d6edcae1ae9a7/setup.py#L194) in `setup.py` was probably meant to use `os.chdir()`, since `os.path` has no `chdir()`.

_(Note: Lots of buildout related noise in the traceback, but I didn't want to truncate it and risk omitting relevant info)_

```
Getting distribution for 'setuptools'.
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/command/easy_install.py", line 2245, in main
    distclass=DistributionWithoutHelpCommands, **kw
  File "/usr/local/python/2.7.10/lib/python2.7/distutils/core.py", line 151, in setup
    dist.run_commands()
  File "/usr/local/python/2.7.10/lib/python2.7/distutils/dist.py", line 953, in run_commands
    self.run_command(cmd)
  File "/usr/local/python/2.7.10/lib/python2.7/distutils/dist.py", line 972, in run_command
    cmd_obj.run()
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/command/easy_install.py", line 380, in run
    self.easy_install(spec, not self.no_deps)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/command/easy_install.py", line 610, in easy_install
    return self.install_item(None, spec, tmpdir, deps, True)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/command/easy_install.py", line 659, in install_item
    dists = self.install_eggs(spec, download, tmpdir)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/command/easy_install.py", line 842, in install_eggs
    return self.build_and_install(setup_script, setup_base)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/command/easy_install.py", line 1070, in build_and_install
    self.run_setup(setup_script, setup_base, args)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/command/easy_install.py", line 1056, in run_setup
    run_setup(setup_script, args)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 240, in run_setup
    raise
  File "/usr/local/python/2.7.10/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 193, in setup_context
    yield
  File "/usr/local/python/2.7.10/lib/python2.7/contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 164, in save_modules
    saved_exc.resume()
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 139, in resume
    compat.reraise(type, exc, self._tb)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 152, in save_modules
    yield saved
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 193, in setup_context
    yield
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 237, in run_setup
    DirectorySandbox(setup_dir).run(runner)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 267, in run
    return func()
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 236, in runner
    _execfile(setup_script, ns)
  File "/var/lib/jenkins/zope/eggs/setuptools-18.2-py2.7.egg/setuptools/sandbox.py", line 46, in _execfile
    exec(code, globals, locals)
  File "/tmp/easy_install-6d2nJI/setuptools-25.0.1/setup.py", line 194, in <module>

AttributeError: 'module' object has no attribute 'chdir'
```



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -191,6 +191,6 @@ def pypi_link(pkg_filename):
 
 if __name__ == '__main__':
     # allow setup.py to run from another directory
-    here and os.path.chdir(here)
+    here and os.chdir(here)
     require_metadata()
     dist = setuptools.setup(**setup_params)


Test patch: