mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 15:28:37 -05:00
Clean up the Cython build process.
This commit is contained in:
19
r2/Makefile
19
r2/Makefile
@@ -58,6 +58,7 @@ RTLCSS = $(CSSTARGETS:.css=-rtl.css)
|
||||
NAMES = $(static_dir)/names.json
|
||||
|
||||
PYX_FILES := $(shell find . -name \*.pyx)
|
||||
PYXC_FILES := $(PYX_FILES:.pyx=.c)
|
||||
PYXSO_FILES := $(PYX_FILES:.pyx=.so)
|
||||
|
||||
NAMED = $(JSOUTPUTS) $(CSSTARGETS) $(RTLCSS) $(SPRITES)
|
||||
@@ -78,7 +79,7 @@ endif
|
||||
|
||||
all: pyx static names $(INIS)
|
||||
|
||||
.PHONY: pyx js css rtl static names clean clean_static all
|
||||
.PHONY: pyx js css rtl static names clean clean_static clean_pyx all
|
||||
|
||||
$(NAMES): $(JSTARGETS) $(CSSTARGETS) $(RTLCSS) $(SPRITES)
|
||||
$(UPDATE_NAMES) $(NAMES) $(NAMED)
|
||||
@@ -101,12 +102,11 @@ $(RTLCSS): %-rtl.css : %.css
|
||||
-e "s/>####</right/g" \
|
||||
-e "s/\(margin\|padding\):\s*\([^; ]\+\)\s\+\([^; ]\+\)\s\+\([^; ]\+\)\s\+\([^; ]\+\)/\1:\2 \5 \4 \3/g" $< > $@
|
||||
|
||||
$(PYXSO_FILES): %.so : %.pyx
|
||||
rm -f $(<:.pyx=.pyc)
|
||||
%.c: %.pyx
|
||||
cython $<
|
||||
mkdir -p tmp
|
||||
PYTHONPATH=tmp $(PYTHON) pyx_setup.py develop -d tmp -b tmp $<
|
||||
rm -r tmp
|
||||
|
||||
$(PYXSO_FILES): $(PYXC_FILES)
|
||||
python setup.py build_ext --inplace
|
||||
|
||||
pyx: $(PYXSO_FILES)
|
||||
|
||||
@@ -120,8 +120,11 @@ rtl: $(RTLCSS)
|
||||
|
||||
names: $(NAMES)
|
||||
|
||||
clean: clean_static
|
||||
rm -f $(PYXSO_FILES) $(INIS)
|
||||
clean: clean_static clean_pyx
|
||||
rm -f $(INIS)
|
||||
|
||||
clean_pyx:
|
||||
rm -f $(PYXSO_FILES) $(PYXC_FILES)
|
||||
|
||||
clean_static: clean_names
|
||||
rm -f $(JSOUTPUTS) $(CSSTARGETS) $(RTLCSS) $(SPRITES)
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# The contents of this file are subject to the Common Public Attribution
|
||||
# License Version 1.0. (the "License"); you may not use this file except in
|
||||
# compliance with the License. You may obtain a copy of the License at
|
||||
# http://code.reddit.com/LICENSE. The License is based on the Mozilla Public
|
||||
# License Version 1.1, but Sections 14 and 15 have been added to cover use of
|
||||
# software over a computer network and provide for limited attribution for the
|
||||
# Original Developer. In addition, Exhibit A has been modified to be consistent
|
||||
# with Exhibit B.
|
||||
#
|
||||
# Software distributed under the License is distributed on an "AS IS" basis,
|
||||
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
|
||||
# the specific language governing rights and limitations under the License.
|
||||
#
|
||||
# The Original Code is Reddit.
|
||||
#
|
||||
# The Original Developer is the Initial Developer. The Initial Developer of the
|
||||
# Original Code is CondeNet, Inc.
|
||||
#
|
||||
# All portions of the code written by CondeNet are Copyright (c) 2006-2010
|
||||
# CondeNet, Inc. All Rights Reserved.
|
||||
################################################################################
|
||||
|
||||
from ez_setup import use_setuptools
|
||||
use_setuptools()
|
||||
from setuptools import find_packages#, setup
|
||||
from distutils.core import setup, Extension
|
||||
from Cython.Distutils import build_ext
|
||||
import os, sys
|
||||
import shutil
|
||||
|
||||
def build_so(pyx_file):
|
||||
if not pyx_file.endswith(".pyx"):
|
||||
raise ValueError, "expected a pyx file, got %s" % pyx_file
|
||||
if not os.path.exists(pyx_file):
|
||||
raise ValueError, "pyx file does not exist: %s" % pyx_file
|
||||
lib = pyx_file[:-4].replace('/', '.').lstrip(".")
|
||||
name = lib.split('.')[-1]
|
||||
ext_modules = [ Extension(lib, [pyx_file]) ]
|
||||
setup(
|
||||
name=name,
|
||||
version="",
|
||||
packages=find_packages(),
|
||||
include_package_data=True,
|
||||
test_suite = 'nose.collector',
|
||||
cmdclass = {'build_ext': build_ext},
|
||||
ext_modules = ext_modules,
|
||||
)
|
||||
shutil.rmtree(name + '.egg-info')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
build_so(sys.argv.pop())
|
||||
18
r2/setup.py
18
r2/setup.py
@@ -27,9 +27,11 @@ use_setuptools()
|
||||
|
||||
from setuptools import find_packages
|
||||
from distutils.core import setup, Extension
|
||||
from Cython.Distutils import build_ext
|
||||
import os
|
||||
import fnmatch
|
||||
|
||||
commands = {}
|
||||
commands = {"build_ext": build_ext}
|
||||
try:
|
||||
from babel.messages import frontend as babel
|
||||
commands.update({
|
||||
@@ -41,6 +43,18 @@ try:
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
|
||||
# add the cython modules
|
||||
pyx_extensions = []
|
||||
for root, directories, files in os.walk('.'):
|
||||
for f in fnmatch.filter(files, '*.pyx'):
|
||||
path = os.path.join(root, f)
|
||||
module_name, _ = os.path.splitext(path)
|
||||
module_name = os.path.normpath(module_name)
|
||||
module_name = module_name.replace(os.sep, '.')
|
||||
pyx_extensions.append(Extension(module_name, [path]))
|
||||
|
||||
|
||||
discount_path = "r2/lib/contrib/discount"
|
||||
|
||||
setup(
|
||||
@@ -72,7 +86,7 @@ setup(
|
||||
],
|
||||
packages=find_packages(exclude=["ez_setup"]),
|
||||
cmdclass=commands,
|
||||
ext_modules=[
|
||||
ext_modules=pyx_extensions + [
|
||||
Extension(
|
||||
"Cfilters",
|
||||
sources=[
|
||||
|
||||
Reference in New Issue
Block a user