User Tools

Site Tools


python

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
python [2015/01/01 13:48] – [xdress 사용하기] dongheepython [2018/07/18 14:10] (current) – external edit 127.0.0.1
Line 57: Line 57:
  
 Dockerfile Dockerfile
 +<code>
 FROM debian:sid FROM debian:sid
 MAINTAINER Donghee Park <dongheepark@gmail.com> MAINTAINER Donghee Park <dongheepark@gmail.com>
Line 74: Line 74:
  
  
 +</code>
  
 Makefile Makefile
  
 +<code>
 cython helloworld.pyx cython helloworld.pyx
 gcc -g -O2 -fpic `python-config --cflags` -c helloworld.c -o helloworld.o   gcc -g -O2 -fpic `python-config --cflags` -c helloworld.c -o helloworld.o  
 gcc -shared -o helloworld.so helloworld.o `python-config --libs` gcc -shared -o helloworld.so helloworld.o `python-config --libs`
  
-+</code>
  
 mycode.c mycode.c
  
-```+<code>
 #include <stdio.h> #include <stdio.h>
  
Line 93: Line 95:
  return a+b;  return a+b;
 } }
-```+</code>
  
 mycode.h mycode.h
  
-```+<code>
 #ifndef __MYCODE_H__ #ifndef __MYCODE_H__
 #define __MYCODE_H__ #define __MYCODE_H__
 extern int myfunc (int, int); extern int myfunc (int, int);
 #endif __MYCODE_H__ #endif __MYCODE_H__
-```+</code>
  
 mycodecpy.pyx mycodecpy.pyx
  
-```+<code>
 cdef extern from "mycode.h" cdef extern from "mycode.h"
  cdef int myfunc (int, int)  cdef int myfunc (int, int)
Line 112: Line 114:
 def callCfunc (): def callCfunc ():
  print myfunc (1,2)  print myfunc (1,2)
-``` +</code>
  
 +<code>
 cython mycodecpy.pyx cython mycodecpy.pyx
 gcc -g -O2 -fpic -c mycode.c -o mycode.o gcc -g -O2 -fpic -c mycode.c -o mycode.o
 gcc -g -O2 -fpic -c mycodecpy.c -o mycodecpy `python-config --cflags` gcc -g -O2 -fpic -c mycodecpy.c -o mycodecpy `python-config --cflags`
 gcc -shared -o mycodecpy.so mycode.o mycodecpy.o `python-config --libs`  gcc -shared -o mycodecpy.so mycode.o mycodecpy.o `python-config --libs` 
 +</code>
  
 +----
 +===== xdress install =====
 +llvm 3.4.2 in macos x 10.9
  
 +<code>
 +wget http://llvm.org/releases/3.4.2/clang+llvm-3.4.2-x86_64-apple-darwin10.9.xz
 +#wget http://llvm.org/releases/3.4.2/clang+llvm-3.4.2-x86_64-linux-gnu-ubuntu-14.04.xz
  
 +tar xvfz clang+llvm-3.4.2-x86_64-apple-darwin10.9.xz
 +mv clang+llvm-3.4.2-x86_64-apple-darwin10.9 llvm-3.4.2-build
 +
 +export LLVM_CONFIG=llvm-3.4.2-build/bin/llvm-config
 +
 +git clone git://github.com/xdress/xdress.git
 +
 +cd xdress
 +
 +python setup.py build_ext --inplace
 +sudo python setup.py install
 +</code>
 +
 +
 +
 +<code>
 +xdress --debug -p clang
 +
 +</code>
 ---- ----
 ===== xdress 사용하기 ===== ===== xdress 사용하기 =====
Line 149: Line 177:
   int i = 1;   int i = 1;
   double val = a;   double val = a;
-  while (i < n){val *= a;};+  while (i < n){val *= a; i++;};
     return val;     return val;
 }; };
Line 167: Line 195:
 </code> </code>
  
 +jeh_setup.py
 <code> <code>
-xdress --rc jeh_xdressrc.py +import os 
-python3 jeh_setup.py build > /dev/null 2>&1+from distutils.core import setup 
 +from distutils.extension import Extension 
 +from Cython.Distutils import build_ext 
 + 
 +import numpy as np 
 + 
 +cwd = os.getcwd() 
 +incdirs = [cwd, os.path.join(cwd, 'jehsrc'), np.get_include()] 
 + 
 +ext_modules = [ 
 +    Extension("jedgar.hoover", ['jehsrc/hoover.cpp', "jedgar/hoover.pyx", ], 
 +    include_dirs=incdirs, language="c++"
 +    ] 
 + 
 +setup(   
 +  name = 'jedgar', 
 +  cmdclass = {'build_ext': build_ext}, 
 +  ext_modules = ext_modules, 
 +  packages = ['jedgar'
 +
 +</code> 
 + 
 +Makefile 
 + 
 +<code> 
 +all: 
 +        xdress --rc jeh_xdressrc.py 
 +        python jeh_setup.py build > /dev/null 2>&1 
 +clean: 
 +        rm -rf build 
 +        rm -rf jehbuild 
 +        
 </code> </code>
  
Line 182: Line 242:
 a.power(42) a.power(42)
 </code> </code>
- 
python.1420120091.txt.gz · Last modified: 2018/07/18 14:09 (external edit)