Python library
Library on windows pyd
Taken from https://www.youtube.com/watch?v=pjYq6p42QTc
Library on windows pyd
Taken from https://www.youtube.com/watch?v=pjYq6p42QTc
- Install windows visual studio, including the feature Desktop development with C++ with the options:
- MSVC ....
- Windows 10 SDK
- Install cython
- pip install cython
- Config system environment
- On PATH variable add:
- C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.24.28314\bin\Hostx64\x64
- C:\Users\erodvel\AppData\Local\Programs\Python\Python37
- C:\Users\erodvel\AppData\Local\Programs\Python\Python37\Scripts
- Create your python program
- Create a second file with extension .pyx
- Create a file setup.py
- this file do the transformation
computations.pyx is your main program
from distutils.core import setup
from Cython.Build import cythonize
directives = {'linetrace':False, 'language_level':3}
setup(ext_modules=cythonize('computations.pyx'))
- Execute
- python setup.py build_ext --inplace
- Start using, importing the library. The import is the file.c
- import file
*******************************************************
Option of setup to convert many files
Option of setup to convert many files
try:
from setuptools import setup
from setuptools import Extension
except ImportError:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
ext_modules = [Extension("my_code_cython",["my_code_cython.pyx"]),
Extension("another_code_cython",["another_code_cython.pyx"])]
setup(
name= 'Generic model class',
cmdclass = {'build_ext': build_ext},
include_dirs = [np.get_include()],
ext_modules = ext_modules)
Comentarios
Publicar un comentario