1717print ('home_dir:' , home_dir )
1818
1919cython_present = False
20- from Cython .Build import cythonize
21- cython_present = True
20+ # from Cython.Build import cythonize
21+ # cython_present = True
2222
2323jinja_present = False
24- import jinja2
25- jinja_present = True
26-
27- # first generate cython pyx from jinja template...
28- from jinja2 import Environment , PackageLoader , Template
29- env = Environment (loader = jinja2 .FileSystemLoader ('.' ))
30- templateNames = [
31- 'src/PyTorch.jinja2.pyx' , 'src/Storage.jinja2.pyx' , 'src/PyTorch.jinja2.pxd' , 'src/nnWrapper.jinja2.cpp' , 'src/nnWrapper.jinja2.h' ,
32- 'test/jinja2.test_pytorch.py' , 'src/Storage.jinja2.pxd' , 'src/nnWrapper.jinja2.pxd' , 'src/lua.jinja2.pxd' , 'src/lua.jinja2.pyx' ]
33- for templateName in templateNames :
34- template = env .get_template (templateName )
35- pyx = template .render (
36- header = 'GENERATED FILE, do not edit by hand, ' +
37- 'Source: ' + templateName ,
38- header1 = 'GENERATED FILE, do not edit by hand' ,
39- header2 = 'Source: ' + templateName )
40- outFilename = templateName .replace ('.jinja2' , '' ).replace ('jinja2.' , '' )
41- print ('outfilename' , outFilename )
42- isUpdate = True
43- if os .path .isfile (outFilename ):
44- # read existing file, see if anything changed
45- f = open (outFilename , 'rb' ) # binary, so get linux line endings, even on Windows
46- pyx_current = f .read ()
47- f .close ()
48- if pyx_current == pyx :
49- isUpdate = False
50- if isUpdate :
51- print (outFilename + ' (changed)' )
52- f = open (outFilename , 'wb' )
53- f .write (pyx .encode ('utf-8' ))
54- f .close ()
24+ #jinja_present = True
5525
26+ running_cython = False
5627for arg in sys .argv :
5728 if arg in ('cython_only' ):
58- print ('cython finished, exiting' )
59- sys .exit (0 )
29+ running_cython = True
30+ break
31+
32+ if running_cython :
33+ print ('Cythonizing...' )
34+ from Cython .Build import cythonize
35+ import jinja2
36+ # first generate cython pyx from jinja template...
37+ from jinja2 import Environment , PackageLoader , Template
38+ env = Environment (loader = jinja2 .FileSystemLoader ('.' ))
39+ templateNames = [
40+ 'src/PyTorch.jinja2.pyx' , 'src/Storage.jinja2.pyx' , 'src/PyTorch.jinja2.pxd' , 'src/nnWrapper.jinja2.cpp' , 'src/nnWrapper.jinja2.h' ,
41+ 'test/jinja2.test_pytorch.py' , 'src/Storage.jinja2.pxd' , 'src/nnWrapper.jinja2.pxd' , 'src/lua.jinja2.pxd' , 'src/lua.jinja2.pyx' ]
42+ for templateName in templateNames :
43+ template = env .get_template (templateName )
44+ pyx = template .render (
45+ header = 'GENERATED FILE, do not edit by hand, ' +
46+ 'Source: ' + templateName ,
47+ header1 = 'GENERATED FILE, do not edit by hand' ,
48+ header2 = 'Source: ' + templateName )
49+ outFilename = templateName .replace ('.jinja2' , '' ).replace ('jinja2.' , '' )
50+ print ('outfilename' , outFilename )
51+ isUpdate = True
52+ if os .path .isfile (outFilename ):
53+ # read existing file, see if anything changed
54+ f = open (outFilename , 'rb' ) # binary, so get linux line endings, even on Windows
55+ pyx_current = f .read ()
56+ f .close ()
57+ if pyx_current == pyx :
58+ isUpdate = False
59+ if isUpdate :
60+ print (outFilename + ' (changed)' )
61+ f = open (outFilename , 'wb' )
62+ f .write (pyx .encode ('utf-8' ))
63+ f .close ()
64+ print ('cython finished, exiting' )
65+ sys .exit (0 )
6066
6167building_dist = False
6268for arg in sys .argv :
@@ -121,11 +127,11 @@ def get_file_datetime(filepath):
121127 language = "c++" )
122128 )
123129
124- ext_modules = cythonize (ext_modules )
130+ # ext_modules = cythonize(ext_modules)
125131
126132setup (
127133 name = 'PyTorch' ,
128- version = '2.2.0-SNAPSHOT ' ,
134+ version = '' ,
129135 author = 'Hugh Perkins' ,
130136 author_email = 'hughperkins@gmail.com' ,
131137 description = (
@@ -135,7 +141,7 @@ def get_file_datetime(filepath):
135141 long_description = 'Python wrappers for torch and nn' ,
136142 classifiers = [
137143 ],
138- install_requires = ['Cython' , ' numpy' , 'Jinja2 ' ],
144+ install_requires = ['numpy' ],
139145 scripts = [],
140146 ext_modules = ext_modules ,
141147 py_modules = ['floattensor' , 'PyTorchAug' ],
0 commit comments