Skip to content

Commit

Permalink
Merge setup-py3-6040-4
Browse files Browse the repository at this point in the history
Author: exarkun
Reviewer: itamarst
Fixes: twisted#6040

Add `setup3.py` script which can package and install a subset of Twisted on Python 3.


git-svn-id: svn://svn.twistedmatrix.com/svn/Twisted/trunk@36198 bbbe8e31-12d6-0310-92fd-ac37d47ddeeb
  • Loading branch information
exarkun committed Oct 16, 2012
1 parent e70dad2 commit 4e4b410
Show file tree
Hide file tree
Showing 6 changed files with 96 additions and 33 deletions.
18 changes: 18 additions & 0 deletions admin/_twistedpython3.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# conflicts, add new lines in alphabetical sort.
modules = [
"twisted",
"twisted.copyright",
"twisted.internet",
"twisted.internet.address",
"twisted.internet.base",
Expand Down Expand Up @@ -57,6 +58,7 @@
"twisted.names.hosts",
"twisted.names.resolve",
"twisted.names.test",
"twisted.names._version",
"twisted.protocols",
"twisted.protocols.basic",
"twisted.protocols.policies",
Expand Down Expand Up @@ -108,6 +110,7 @@
"twisted.web._responses",
"twisted.web.test",
"twisted.web.test.requesthelper",
"twisted.web._version",
]


Expand Down Expand Up @@ -182,3 +185,18 @@
"twisted.web.test.test_http_headers",
"twisted.web.test.test_resource",
]

# A list of any other modules which are needed by any of the modules in the
# other two lists, but which themselves have not actually been properly ported
# to Python 3. These modules might work well enough to satisfy some of the
# requirements of the modules that depend on them, but cannot be considered
# generally usable otherwise.
almostModules = [
"twisted.internet.abstract",
"twisted.names.root",
"twisted.python.dist",
"twisted.test.reflect_helper_IE",
"twisted.test.reflect_helper_VE",
"twisted.test.reflect_helper_ZDE",
"twisted.trial.reporter",
]
41 changes: 9 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,42 +23,19 @@ def main(args):
"""
if os.path.exists('twisted'):
sys.path.insert(0, '.')
from twisted import copyright
from twisted.python.dist import getDataFiles, getExtensions, getScripts, \
getPackages, setup, twisted_subprojects
from twisted.python.dist import (
STATIC_PACKAGE_METADATA, getDataFiles, getExtensions, getAllScripts,
getPackages, setup)

# "" is included because core scripts are directly in bin/
projects = [''] + [x for x in os.listdir('bin')
if os.path.isdir(os.path.join("bin", x))
and x in twisted_subprojects]

scripts = []
for i in projects:
scripts.extend(getScripts(i))
scripts = getAllScripts()

setup_args = dict(
# metadata
name="Twisted",
version=copyright.version,
description="An asynchronous networking framework written in Python",
author="Twisted Matrix Laboratories",
author_email="twisted-python@twistedmatrix.com",
maintainer="Glyph Lefkowitz",
maintainer_email="glyph@twistedmatrix.com",
url="http://twistedmatrix.com/",
license="MIT",
long_description="""\
An extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
""",
packages = getPackages('twisted'),
conditionalExtensions = getExtensions(),
scripts = scripts,
packages=getPackages('twisted'),
conditionalExtensions=getExtensions(),
scripts=scripts,
data_files=getDataFiles('twisted'),
classifiers=[
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
])
**STATIC_PACKAGE_METADATA
)

if 'setuptools' in sys.modules:
from pkg_resources import parse_requirements
Expand Down
31 changes: 31 additions & 0 deletions setup3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3.3

# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.

# This is a temporary helper to be able to build and install distributions of
# Twisted on/for Python 3. Once all of Twisted has been ported, it should go
# away and setup.py should work for either Python 2 or Python 3.

from __future__ import division, absolute_import

import sys, os.path

sys.path.insert(0, '.')

from distutils.core import setup

from twisted.python.dist import STATIC_PACKAGE_METADATA

args = STATIC_PACKAGE_METADATA.copy()
args['classifiers'] = ["Programming Language :: Python :: 3.3"]

ported = {}
exec(open("admin/_twistedpython3.py").read(), ported)
args['py_modules'] = ported['modules'] + ported['testModules'] + ported['almostModules']

if 'sdist' in sys.argv:
args['data_files'] = [
('admin', ['admin/_twistedpython3.py', 'admin/run-python3-tests'])]

setup(**args)
4 changes: 3 additions & 1 deletion twisted/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Copyright information for Twisted.
"""

from __future__ import division, absolute_import

from twisted import __version__ as version, version as longversion

longversion = str(longversion)
Expand Down Expand Up @@ -36,4 +38,4 @@
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
''' % copyright
''' % (copyright,)
34 changes: 34 additions & 0 deletions twisted/python/dist.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,29 @@
import platform
import sys

from twisted import copyright
from twisted.python.compat import execfile

STATIC_PACKAGE_METADATA = dict(
name="Twisted",
version=copyright.version,
description="An asynchronous networking framework written in Python",
author="Twisted Matrix Laboratories",
author_email="twisted-python@twistedmatrix.com",
maintainer="Glyph Lefkowitz",
maintainer_email="glyph@twistedmatrix.com",
url="http://twistedmatrix.com/",
license="MIT",
long_description="""\
An extensible framework for Python programming, with special focus
on event-based network programming and multiprotocol integration.
""",
classifiers=[
"Programming Language :: Python :: 2.6",
"Programming Language :: Python :: 2.7",
],
)


twisted_subprojects = ["conch", "lore", "mail", "names",
"news", "pair", "runner", "web",
Expand Down Expand Up @@ -263,6 +284,19 @@ def getPackages(dname, pkgname=None, results=None, ignore=None, parent=None):
return res



def getAllScripts():
# "" is included because core scripts are directly in bin/
projects = [''] + [x for x in os.listdir('bin')
if os.path.isdir(os.path.join("bin", x))
and x in twisted_subprojects]
scripts = []
for i in projects:
scripts.extend(getScripts(i))
return scripts



def getScripts(projname, basedir=''):
"""
Returns a list of scripts for a Twisted subproject; this works in
Expand Down
1 change: 1 addition & 0 deletions twisted/topfiles/6040.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The setup3.py script is now provided to provisionally support building and installing an experimental, incomplete version of Twisted in a Python 3 environment.

0 comments on commit 4e4b410

Please sign in to comment.