Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Gwenaël Samain
cython
Commits
a8404cbd
Commit
a8404cbd
authored
Sep 12, 2010
by
Robert Bradshaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Test of new build mechanism.
parent
9452c45f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
23 deletions
+41
-23
Cython/Compiler/Dependencies.py
Cython/Compiler/Dependencies.py
+18
-17
runtests.py
runtests.py
+7
-6
tests/build/basic_cythonize.srctree
tests/build/basic_cythonize.srctree
+16
-0
No files found.
Cython/Compiler/Dependencies.py
View file @
a8404cbd
from
glob
import
glob
from
glob
import
glob
import
re
import
re
,
os
,
sys
from
distutils.extension
import
Extension
from
distutils.extension
import
Extension
...
@@ -220,60 +220,61 @@ class DependencyTree(object):
...
@@ -220,60 +220,61 @@ class DependencyTree(object):
del
stack
[
node
]
del
stack
[
node
]
_dep_tree
=
None
_dep_tree
=
None
def
create_dependency_tree
(
ctx
):
def
create_dependency_tree
(
ctx
=
None
):
global
_dep_tree
global
_dep_tree
if
_dep_tree
is
None
:
if
_dep_tree
is
None
:
if
ctx
is
None
:
from
Cython.Compiler.Main
import
Context
,
CompilationOptions
ctx
=
Context
([
"."
],
CompilationOptions
())
_dep_tree
=
DependencyTree
(
ctx
)
_dep_tree
=
DependencyTree
(
ctx
)
return
_dep_tree
return
_dep_tree
def
create_extension_list
(
filepatterns
,
ctx
=
None
):
def
create_extension_list
(
filepatterns
,
ctx
=
None
):
if
ctx
is
None
:
from
Cython.Compiler.Main
import
Context
ctx
=
Context
([
"."
])
deps
=
create_dependency_tree
(
ctx
)
deps
=
create_dependency_tree
(
ctx
)
if
isinstance
(
filepatterns
,
str
):
if
isinstance
(
filepatterns
,
str
):
filepatterns
=
[
filepatterns
]
filepatterns
=
[
filepatterns
]
module_list
=
[]
for
pattern
in
filepatterns
:
for
pattern
in
filepatterns
:
for
file
in
glob
(
pattern
):
for
file
in
glob
(
pattern
):
pkg
=
deps
.
package
(
file
)
pkg
=
deps
.
package
(
file
)
name
=
fully_qualifeid_name
(
file
)
name
=
deps
.
fully_qualifeid_name
(
file
)
return
Extension
(
name
=
name
,
sources
=
[
file
])
module_list
.
append
(
Extension
(
name
=
name
,
sources
=
[
file
]))
return
module_list
def
cythonize
(
module_list
):
def
cythonize
(
module_list
,
ctx
=
None
):
deps
=
create_dependency_tree
(
ctx
)
deps
=
create_dependency_tree
(
ctx
)
to_compile
=
[]
to_compile
=
[]
for
m
in
module_list
:
for
m
in
module_list
:
new_sources
=
[]
new_sources
=
[]
for
source
in
m
.
sources
:
for
source
in
m
.
sources
:
base
,
ext
=
os
.
path
.
splitext
(
source
)
base
,
ext
=
os
.
path
.
splitext
(
source
)
if
ext
in
(
'
pyx'
,
'
py'
):
if
ext
in
(
'
.pyx'
,
'.
py'
):
if
m
.
language
==
'c++'
:
if
m
.
language
==
'c++'
:
c_file
=
base
+
'.cpp'
c_file
=
base
+
'.cpp'
else
:
else
:
c_file
=
base
+
'.c'
c_file
=
base
+
'.c'
if
os
.
path
.
exists
(
c_file
):
if
os
.
path
.
exists
(
c_file
):
c_timestamp
=
os
.
path
.
getmtime
(
out
file
)
c_timestamp
=
os
.
path
.
getmtime
(
c_
file
)
else
:
else
:
c_timestamp
=
-
1
c_timestamp
=
-
1
if
c_timestamp
<
deps
.
timestamp
(
source
):
if
c_timestamp
<
deps
.
timestamp
(
source
):
dep
,
dep_timestam
p
=
deps
.
timestamp
(
source
),
source
dep
_timestamp
,
de
p
=
deps
.
timestamp
(
source
),
source
priority
=
0
priority
=
0
else
:
else
:
dep
,
dep_timestam
p
=
deps
.
newest_dependency
(
source
)
dep
_timestamp
,
de
p
=
deps
.
newest_dependency
(
source
)
priority
=
2
-
(
dep
in
deps
.
immediate_dependencies
(
source
))
priority
=
2
-
(
dep
in
deps
.
immediate_dependencies
(
source
))
if
c_timestamp
<
dep_timestamp
:
if
c_timestamp
<
dep_timestamp
:
print
(
"Compiling"
,
source
,
"because it depends on "
,
dep
)
print
"Compiling"
,
source
,
"because it depends on"
,
dep
if
dep
==
source
:
to_compile
.
append
((
priority
,
source
,
c_file
))
to_compile
.
append
((
priority
,
source
,
c_file
))
new_sources
.
append
(
out
file
)
new_sources
.
append
(
c_
file
)
else
:
else
:
new_sources
.
append
(
source
)
new_sources
.
append
(
source
)
m
.
sources
=
new_sources
m
.
sources
=
new_sources
to_compile
.
sort
()
to_compile
.
sort
()
# TODO: invoke directly
# TODO: invoke directly
cython_py
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__
FILE
__
),
'../../cython.py'
)
cython_py
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__
file
__
),
'../../cython.py'
)
for
priority
,
pyx_file
,
c_file
in
to_compile
:
for
priority
,
pyx_file
,
c_file
in
to_compile
:
cmd
=
"
python %s %s -o %s"
%
(
p
ython_py
,
pyx_file
,
c_file
)
cmd
=
"
%s %s %s -o %s"
%
(
sys
.
executable
,
c
ython_py
,
pyx_file
,
c_file
)
print
cmd
print
cmd
os
.
system
(
cmd
)
os
.
system
(
cmd
)
return
module_list
return
module_list
runtests.py
View file @
a8404cbd
...
@@ -163,6 +163,8 @@ class TestBuilder(object):
...
@@ -163,6 +163,8 @@ class TestBuilder(object):
filenames
.
sort
()
filenames
.
sort
()
for
filename
in
filenames
:
for
filename
in
filenames
:
if
context
==
"build"
and
filename
.
endswith
(
".srctree"
):
if
context
==
"build"
and
filename
.
endswith
(
".srctree"
):
if
not
[
1
for
match
in
self
.
selectors
if
match
(
filename
)
]:
continue
suite
.
addTest
(
EndToEndTest
(
filename
,
workdir
,
self
.
cleanup_workdir
))
suite
.
addTest
(
EndToEndTest
(
filename
,
workdir
,
self
.
cleanup_workdir
))
continue
continue
if
not
(
filename
.
endswith
(
".pyx"
)
or
filename
.
endswith
(
".py"
)):
if
not
(
filename
.
endswith
(
".pyx"
)
or
filename
.
endswith
(
".py"
)):
...
@@ -645,25 +647,24 @@ class EndToEndTest(unittest.TestCase):
...
@@ -645,25 +647,24 @@ class EndToEndTest(unittest.TestCase):
from
Cython.TestUtils
import
unpack_source_tree
from
Cython.TestUtils
import
unpack_source_tree
_
,
self
.
commands
=
unpack_source_tree
(
os
.
path
.
join
(
'tests'
,
'build'
,
self
.
treefile
),
self
.
workdir
)
_
,
self
.
commands
=
unpack_source_tree
(
os
.
path
.
join
(
'tests'
,
'build'
,
self
.
treefile
),
self
.
workdir
)
self
.
old_dir
=
os
.
getcwd
()
self
.
old_dir
=
os
.
getcwd
()
if
not
os
.
path
.
exists
(
self
.
workdir
):
os
.
makedirs
(
self
.
workdir
)
os
.
chdir
(
self
.
workdir
)
os
.
chdir
(
self
.
workdir
)
if
self
.
workdir
not
in
sys
.
path
:
if
self
.
workdir
not
in
sys
.
path
:
sys
.
path
.
insert
(
0
,
self
.
workdir
)
sys
.
path
.
insert
(
0
,
self
.
workdir
)
def
tearDown
(
self
):
def
tearDown
(
self
):
try
:
sys
.
path
.
remove
(
self
.
workdir
)
except
ValueError
:
pass
if
self
.
cleanup_workdir
:
if
self
.
cleanup_workdir
:
shutil
.
rmtree
(
self
.
workdir
)
shutil
.
rmtree
(
self
.
workdir
)
os
.
chdir
(
self
.
old_dir
)
os
.
chdir
(
self
.
old_dir
)
def
runTest
(
self
):
def
runTest
(
self
):
# Assumes old_dir is root of the cython directory...
commands
=
(
self
.
commands
commands
=
(
self
.
commands
.
replace
(
"CYTHON"
,
"PYTHON %s"
%
os
.
path
.
join
(
self
.
old_dir
,
'cython.py'
))
.
replace
(
"CYTHON"
,
"PYTHON %s"
%
os
.
path
.
join
(
self
.
old_dir
,
'cython.py'
))
.
replace
(
"PYTHON"
,
sys
.
executable
))
.
replace
(
"PYTHON"
,
sys
.
executable
))
commands
=
"""
PYTHONPATH="%s%s$PYTHONPATH"
%s
"""
%
(
self
.
old_dir
,
os
.
pathsep
,
commands
)
self
.
assertEqual
(
0
,
os
.
system
(
commands
))
self
.
assertEqual
(
0
,
os
.
system
(
commands
))
...
...
tests/build/basic_cythonize.srctree
0 → 100644
View file @
a8404cbd
PYTHON setup.py build_ext --inplace
PYTHON -c "import a"
######## setup.py ########
# TODO: Better interface...
from Cython.Compiler.Dependencies import create_extension_list, cythonize
from distutils.core import setup
setup(
ext_modules = cythonize(create_extension_list("*.pyx")),
)
######## a.pyx ########
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment