-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Structured Sources #9339
Structured Sources #9339
Conversation
@rgommers I'd like to have this work for cython too before it's merged, but I'm struggling to write a test case so that I can get started. Do you think you could at least help point me in the right direction? |
Codecov Report
@@ Coverage Diff @@
## master #9339 +/- ##
==========================================
- Coverage 64.66% 61.85% -2.81%
==========================================
Files 402 202 -200
Lines 85729 42858 -42871
Branches 18909 9374 -9535
==========================================
- Hits 55433 26509 -28924
+ Misses 25934 14229 -11705
+ Partials 4362 2120 -2242
Continue to review full report at Codecov.
|
6ede98f
to
a5213cd
Compare
Yes of course. There are three file types that matter:
# Needed to trick Cython, it won't do a relative import outside a package.
# Every Cython extension built from a generated `.pyx` file needs to rely on this,
# as well as on the `__init__.py` files in subdirs between the root one we're copying
# here and the subdir it's in.
_cython_tree = custom_target('_cython_tree',
output : [
'__init__.py',
'linalg.pxd',
'special.pxd',
],
input : [
'__init__.py',
'linalg.pxd',
'special.pxd',
],
command : ['cp', '@INPUT@', '@OUTDIR@'],
) Codegen in cython_special = custom_target('cython_special',
output : [...
'_ufuncs.pyi',
'cython_special.pyx',
'cython_special.pxd'
],
input : ['_generate_pyx.py', 'functions.json', 'add_newdocs.py'],
command : [py3, '@INPUT0@', '-o', '@OUTDIR@'],
)
# Relies on cython_special, which ends up in the build dir. Hence we need ` '-I', '@BUILD_ROOT@'` here.
# (note: I need to double check if this `custom_target` is still needed, may have to do with the now
# solved bug about `cython_special` not being indexable when passed to `extension_module`.
# Either that, or to allow using `@BUILD_ROOT@` here.)
_stats_c = custom_target('_stats_c',
output: '_stats.c',
input: [
'_stats.pyx',
_cython_tree,
cython_special,
],
command: [cython, '-3', '--fast-fail',
'@INPUT0@', '-o', '@OUTPUT@', '-I', '@BUILD_ROOT@'],
)
_stats = py3.extension_module('_stats',
_stats_c,
dependencies : [py3_dep],
install : true,
subdir : 'scipy/stats'
) The I believe the above covers most/all of what is relevant. Please let me know if it's not clear or if I should try and turn this into a self-contained test case. EDIT: the bug in gh-8961 is relevant to this. |
a5213cd
to
e720ff4
Compare
fb451e7
to
2f60a57
Compare
f33f1a2
to
9893416
Compare
9893416
to
f4fc2c8
Compare
@rgommers: I've added a cython test, and it compiles but doesn't run. Maybe you can help me, I'm bashing my head against the wall, the merge window closes Sunday, and I'd really like to get this in before that. |
You have created:
Then you add builddir to the PYTHONPATH, run a script that imports It seems like the problem is that the structured source is being treated as a file layout for compiling |
f4fc2c8
to
54837ab
Compare
So, for the moment I've dropped cython support, and I'll go at that again in a follow up, as it's going to require some thought on how it's going to work, and I'm not sure what that needs to look like. |
54837ab
to
5c37f14
Compare
eb5fbfc
to
eef70a3
Compare
As this is a notable feature that has been long underway, I'll grant an exception so that this can be merged after the actual DL in case it can't get reviewed in time. |
docs/markdown/Rust.md
Outdated
*Note* This feature was added in 0.60 | ||
|
||
You can use a "structured source" for this. Structured sources are a dictionary | ||
mapping a string of the directory ('' means root), to a source or list of sources. |
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.
Please explain what "root" means here, specifically. It is a term with many potential meanings.
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.
Oops, that's more leftover old implementation, ''
is not allowed in the dictionary. I've fixed that and updated the 0.60 comment.
Featurewise this seems like a useful addition so approval on that front. I have not looked too deeply in the implementation yet, but it seems that there should be a failing test case when using two different structured sources that define the same file in two different structured sources. Something like: executable(...,
structured_sources({'subdir': 'clashing.rs'}),
structured_sources({'subdir': 'other/clashing.rs'})
) Either there can only be one structured sources per target (which seems a bit limiting) or it should validate all the files upfront. |
Actually, that's interesting, yeah. I can fix that. |
eef70a3
to
cc54294
Compare
This is useful when creating an exception with a node option, with less typing.
I noticed by inspection
The declaration is `EnvInitValueType`, but when it's used it's `EnvValueType`.
And teach the interpreter how to use it
This is hardly complete, but it's a start.
cc54294
to
ff4c283
Compare
@jpakkane I've added the validation and tests you wanted |
This is a reworked version of #8775, with the main complaints resolved.
The purpose of this series is to provide a mechanism for languages in which filesystem layout is relevant to ensure that generated sources end up in the right place. To do this, one describes the layout they want to a
structrued_sources
object, which the backend converts (if necessary) into a series of copy commands, to build the correct directory structure in the build directory. This structure is placed in the private directory of the target, to eliminate collisions. Then the actual compile is done on the copied sources rather than on the original sources. This is done at build time to avoid reconfiguration when any of the structured sources are changed.