-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pythran file #647
Closed
Closed
Pythran file #647
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#runas zero(10,20) | ||
#bench zero(6000,6000) | ||
def zero(n,m): return [[0 for row in xrange(n)] for col in xrange(m)] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This is a pythran file | ||
export zero(int, int) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -300,7 +300,7 @@ def compile_cxxcode(module_name, cxxcode, output_binary=None, keep_temp=False, | |
return output_binary | ||
|
||
|
||
def compile_pythrancode(module_name, pythrancode, specs=None, | ||
def compile_pythrancode(module_name, path_or_text, specs=None, | ||
opts=None, cpponly=False, output_file=None, | ||
**kwargs): | ||
'''Pythran code (string) -> c++ code -> native module | ||
|
@@ -309,9 +309,15 @@ def compile_pythrancode(module_name, pythrancode, specs=None, | |
''' | ||
|
||
# Autodetect the Pythran spec if not given as parameter | ||
from pythran.spec import spec_parser | ||
from pythran.spec import pyspec_parser | ||
if specs is None: | ||
specs = spec_parser(pythrancode) | ||
specs = pyspec_parser(path_or_text) | ||
|
||
if os.path.isfile(path_or_text): | ||
with open(path_or_text) as fd: | ||
pythrancode = fd.read() | ||
else: | ||
pythrancode = path_or_text | ||
|
||
# Generate C++, get a PythonModule object | ||
module = generate_cxx(module_name, pythrancode, specs, opts) | ||
|
@@ -354,7 +360,13 @@ def compile_pythranfile(file_path, output_file=None, module_name=None, | |
# Add compiled module path to search for imported modules | ||
sys.path.append(os.path.dirname(file_path)) | ||
|
||
output_file = compile_pythrancode(module_name, open(file_path).read(), | ||
specs = None | ||
spec_file = os.path.join(os.path.dirname(file_path), os.path.splitext(file_path)[0] + ".pythran") | ||
if os.path.isfile(spec_file): | ||
from pythran.spec import spec_parser | ||
specs = spec_parser(spec_file) | ||
|
||
output_file = compile_pythrancode(module_name, file_path, specs, | ||
output_file=output_file, | ||
cpponly=cpponly, | ||
**kwargs) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see a single test case :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. still no test case;-) |
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you do it here, maybe you can remove the file_or_path from the spec.py file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is to have the filepath inside spec.py in order to have the file path in the error message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, shouldn't we replace non #pythran line by empty line in order to avoid wrong line information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd say yes.