Skip to content

Commit

Permalink
Update setup.py.
Browse files Browse the repository at this point in the history
  • Loading branch information
adiroiban committed Aug 19, 2016
1 parent 2d12213 commit c4ac6ba
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
10 changes: 6 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
setuptools._TWISTED_NO_CHECK_REQUIREMENTS = True

if __name__ == "__main__":
from twisted.python._setup import get_setup_args
# Make sure we can import the setup helpers.
if os.path.exists('src/twisted/'):
sys.path.insert(0, 'src')

from twisted.python._setup import getSetupArgs
try:
if os.path.exists('src/twisted/'):
sys.path.insert(0, 'src')
setuptools.setup(**get_setup_args())
setuptools.setup(**getSetupArgs())
except KeyboardInterrupt:
sys.exit(1)
6 changes: 3 additions & 3 deletions src/twisted/python/_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,13 @@ def __init__(self, *args, **kwargs):



def get_setup_args():
def getSetupArgs(extensions=_EXTENSIONS):
"""
@return: The keyword arguments to be used the the setup method.
@rtype: L{dict}
"""
arguments = STATIC_PACKAGE_METADATA.copy()

extensions = _EXTENSIONS
# This is a workaround for distutils behavior; ext_modules isn't
# actually used by our custom builder. distutils deep-down checks
# to see if there are any ext_modules defined before invoking
Expand All @@ -218,7 +217,7 @@ class my_build_ext(build_ext_twisted):
requirements.append("constantly >= 15.1")

arguments.update(dict(
packages=find_packages(),
packages=find_packages("src"),
install_requires=requirements,
entry_points={
'console_scripts': _CONSOLE_SCRIPTS
Expand All @@ -227,6 +226,7 @@ class my_build_ext(build_ext_twisted):
include_package_data=True,
zip_safe=False,
extras_require=_EXTRAS_REQUIRE,
package_dir={"": "src"},
))

return arguments
Expand Down
18 changes: 10 additions & 8 deletions src/twisted/python/test/test_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from twisted.python.compat import _PY3
from twisted.python._setup import (
BuildPy3,
get_setup_args,
getSetupArgs,
ConditionalExtension,
_EXTRAS_REQUIRE,
)
Expand All @@ -26,7 +26,7 @@

class SetupTests(TestCase):
"""
Tests for L{get_setup_args}.
Tests for L{getSetupArgs}.
"""

def test_conditionalExtensions(self):
Expand All @@ -38,10 +38,11 @@ def test_conditionalExtensions(self):
condition=lambda b: True)
bad_ext = ConditionalExtension("whatever", ["whatever.c"],
condition=lambda b: False)
self.patch(_setup, '_EXTENSIONS', [good_ext, bad_ext])
args = get_setup_args()

args = getSetupArgs(extensions=[good_ext, bad_ext])

# ext_modules should be set even though it's not used. See comment
# in get_setup_args
# in getSetupArgs
self.assertEqual(args["ext_modules"], [good_ext, bad_ext])
cmdclass = args["cmdclass"]
build_ext = cmdclass["build_ext"]
Expand All @@ -57,8 +58,9 @@ def test_win32Definition(self):
"""
ext = ConditionalExtension("whatever", ["whatever.c"],
define_macros=[("whatever", 2)])
self.patch(_setup, '_EXTENSIONS', [ext])
args = get_setup_args()

args = getSetupArgs(extensions=[ext])

builder = args["cmdclass"]["build_ext"](Distribution())
self.patch(os, "name", "nt")
builder.prepare_extensions()
Expand Down Expand Up @@ -331,7 +333,7 @@ def test_find_package_modules(self):
basePath = os.environ.get('PWD', '../')
# Overwrite the path if we are running with tox.
basePath = os.environ.get('TOX_INI_DIR', basePath)
packageDir = os.path.join(basePath, 'twisted', 'test')
packageDir = os.path.join(basePath, 'src', 'twisted', 'test')

result = builder.find_package_modules('twisted.test', packageDir)

Expand Down
1 change: 0 additions & 1 deletion src/twisted/topfiles/8556.misc

This file was deleted.

0 comments on commit c4ac6ba

Please sign in to comment.