This repository has been archived by the owner on Oct 16, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BUG: move monkey_patch to avoid some weird distutils auto-imports.
- Loading branch information
Showing
6 changed files
with
55 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +0,0 @@ | ||
import sys | ||
|
||
def monkey_patch(): | ||
# XXX: keep the import here to avoid any side-effects from mere import of | ||
# bento.distutils | ||
from bento.distutils.utils \ | ||
import \ | ||
_is_setuptools_activated | ||
import bento.distutils.dist | ||
|
||
# Install it throughout the distutils | ||
_MODULES = [] | ||
if _is_setuptools_activated(): | ||
import setuptools.dist | ||
_MODULES.append(setuptools.dist) | ||
import distutils.dist, distutils.core, distutils.cmd | ||
_MODULES.extend([distutils.dist, distutils.core, distutils.cmd]) | ||
for module in _MODULES: | ||
module.Distribution = bento.distutils.dist.BentoDistribution | ||
|
||
def setup(mode=None): | ||
"""Call setup after monkey-patching with the given mode. | ||
Parameters | ||
---------- | ||
mode: None/str | ||
'distutils' or 'setuptools' for now | ||
""" | ||
if mode is None: | ||
if "setuptools" in sys.modules: | ||
mode = "setuptools" | ||
else: | ||
mode = "distutils" | ||
if not mode in ("distutils", "setuptools"): | ||
raise ValueError("Only 'setuptools' and 'distutils' are supported modes") | ||
__import__(mode) | ||
monkey_patch() | ||
from distutils.core import setup as _setup | ||
return _setup() | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import sys | ||
|
||
def monkey_patch(): | ||
# XXX: keep the import here to avoid any side-effects from mere import of | ||
# bento.distutils | ||
from bento.distutils.utils \ | ||
import \ | ||
_is_setuptools_activated | ||
import bento.distutils.dist | ||
|
||
# Install it throughout the distutils | ||
_MODULES = [] | ||
if _is_setuptools_activated(): | ||
import setuptools.dist | ||
_MODULES.append(setuptools.dist) | ||
import distutils.dist, distutils.core, distutils.cmd | ||
_MODULES.extend([distutils.dist, distutils.core, distutils.cmd]) | ||
for module in _MODULES: | ||
module.Distribution = bento.distutils.dist.BentoDistribution | ||
|
||
def setup(mode=None): | ||
"""Call setup after monkey-patching with the given mode. | ||
Parameters | ||
---------- | ||
mode: None/str | ||
'distutils' or 'setuptools' for now | ||
""" | ||
import traceback | ||
traceback.print_stack() | ||
This comment has been minimized.
Sorry, something went wrong. |
||
if mode is None: | ||
if "setuptools" in sys.modules: | ||
mode = "setuptools" | ||
else: | ||
mode = "distutils" | ||
if not mode in ("distutils", "setuptools"): | ||
raise ValueError("Only 'setuptools' and 'distutils' are supported modes") | ||
__import__(mode) | ||
monkey_patch() | ||
from distutils.core import setup as _setup | ||
return _setup() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from bento.distutils import setup | ||
from bento.distutils.monkey_patch import setup | ||
setup() |
@cournape Hmm. Do you want this print_stack() here?