Skip to content
  • Gregory Szorc's avatar
    setup: properly package distutils in py2exe virtualenv builds · 71d8b4d91616
    Gregory Szorc authored
    Our in-repo py2exe packaging code uses virtualenvs for managing
    dependencies. An advantage of this is that packaging is more
    deterministic and reproducible. Without virtualenvs, we need to
    install packages in the system Python install. Packages installed
    by other consumers of the system Python could leak into the Mercurial
    package.
    
    A regression from this change was that py2exe packages contained
    the virtualenv's hacked distutils modules instead of the original
    distutils modules. (virtualenv installs a hacked distutils module
    because distutils uses relative path lookups that fail when running
    from a virtualenv.)
    
    This commit introduces a workaround so py2exe packaging uses the
    original distutils modules when running from a virtualenv.
    
    With this change, `import distutils` no longer fails from py2exe
    builds produced from a virtualenv. This fixes the regression.
    Furthermore, we now include all distutils modules. Before, py2exe's
    module finding would only find modules there were explicitly
    referenced in code. So, we now package a complete copy of distutils
    instead of a partial one. This is even better than before.
    
    # no-check-commit foo_bar function name
    71d8b4d91616