Skip to content
Browse files

[svn r2800] switch to Cython completely, currently requires fake Pyre…

…x to satisfy setuptools

--HG--
branch : trunk
  • Loading branch information...
1 parent 5f72cd8 commit 9e68316bc8bd721c8058bbde79bc59d28bc1a843 scoder committed Aug 31, 2007
Showing with 26 additions and 24 deletions.
  1. +1 −0 MANIFEST.in
  2. +1 −0 fake_pyrex/Pyrex/Distutils/__init__.py
  3. +1 −0 fake_pyrex/Pyrex/Distutils/build_ext.py
  4. +1 −0 fake_pyrex/Pyrex/__init__.py
  5. +16 −10 setup.py
  6. +6 −14 setupinfo.py
View
1 MANIFEST.in
@@ -9,5 +9,6 @@ recursive-include src/lxml etree.c objectify.c pyclasslookup.c etree.h etree_def
recursive-include src/lxml/tests *.rng *.xslt *.xml *.dtd
recursive-include benchmark *.py
recursive-include doc *.txt *.html *.css *.xml *.mgp pubkey.asc tagpython.png
+recursive-include fake_pyrex *.py
include doc/mkhtml.py doc/rest2html.py
exclude doc/pyrex.txt src/lxml/etree.pxi
View
1 fake_pyrex/Pyrex/Distutils/__init__.py
@@ -0,0 +1 @@
+# work around broken setuptools monkey patching
View
1 fake_pyrex/Pyrex/Distutils/build_ext.py
@@ -0,0 +1 @@
+build_ext = "yes, it's there!"
View
1 fake_pyrex/Pyrex/__init__.py
@@ -0,0 +1 @@
+# work around broken setuptools monkey patching
View
26 setup.py
@@ -1,25 +1,28 @@
import sys, os
+extra_options = {}
+
+try:
+ import Cython
+ # may need to work around setuptools bug by providing a fake Pyrex
+ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "fake_pyrex"))
+except ImportError:
+ pass
+
try:
import pkg_resources
try:
pkg_resources.require("setuptools>=0.6c5")
- except pkg_resources.VersionConflict, e:
+ except pkg_resources.VersionConflict:
from ez_setup import use_setuptools
use_setuptools(version="0.6c5")
#pkg_resources.require("Cython==0.9.6.5")
from setuptools import setup
+ extra_options["zip_safe"] = False
except ImportError:
# no setuptools installed
from distutils.core import setup
-try:
- import Cython
-except ImportError:
- # need to insert this to python path so we're sure we can import versioninfo,
- # setupinfo and Cython/Pyrex (!) even if we start setup.py from another location
- # (such as a buildout)
- sys.path.insert(0, os.path.dirname(__file__))
import versioninfo
import setupinfo
@@ -31,11 +34,15 @@
STATIC_LIBRARY_DIRS = []
STATIC_CFLAGS = []
+
# create lxml-version.h file
svn_version = versioninfo.svn_version()
versioninfo.create_version_h(svn_version)
print "Building lxml version", svn_version
+
+extra_options.update(setupinfo.extra_setup_args())
+
setup(
name = "lxml",
version = versioninfo.version(),
@@ -86,8 +93,7 @@
package_dir = {'': 'src'},
packages = ['lxml', 'lxml.html'],
- zip_safe = False,
ext_modules = setupinfo.ext_modules(
STATIC_INCLUDE_DIRS, STATIC_LIBRARY_DIRS, STATIC_CFLAGS),
- **setupinfo.extra_setup_args()
+ **extra_options
)
View
20 setupinfo.py
@@ -1,20 +1,12 @@
import sys, os
-try:
- from setuptools.extension import Extension
-except ImportError:
- from distutils.extension import Extension
+from distutils.core import Extension
try:
from Cython.Distutils import build_ext as build_pyx
print "Building with Cython."
- PYREX_INSTALLED = True
+ CYTHON_INSTALLED = True
except ImportError:
- try:
- from Pyrex.Distutils import build_ext as build_pyx
- print "Trying to build with Pyrex."
- PYREX_INSTALLED = True
- except ImportError:
- PYREX_INSTALLED = False
+ CYTHON_INSTALLED = False
EXT_MODULES = [
("etree", "lxml.etree"),
@@ -27,10 +19,10 @@ def env_var(name):
return value.split(os.pathsep)
def ext_modules(static_include_dirs, static_library_dirs, static_cflags):
- if PYREX_INSTALLED:
+ if CYTHON_INSTALLED:
source_extension = ".pyx"
else:
- print ("NOTE: Trying to build without Pyrex, pre-generated "
+ print ("NOTE: Trying to build without Cython, pre-generated "
"'src/lxml/etree.c' needs to be available.")
source_extension = ".c"
@@ -67,7 +59,7 @@ def ext_modules(static_include_dirs, static_library_dirs, static_cflags):
def extra_setup_args():
result = {}
- if PYREX_INSTALLED:
+ if CYTHON_INSTALLED:
result['cmdclass'] = {'build_ext': build_pyx}
return result

0 comments on commit 9e68316

Please sign in to comment.
Something went wrong with that request. Please try again.