NOTE: this replicates a previous pull request from a deleted repo.
Here is my modern command line interface, which performs a little slower if compared to old custom code, but is clear and easily extensible. It supports both argparse and optparse, though the "legacy" version has some 10 HACKs . Additionally, argparse performs better with complicated command lines (like those generated by autotools &co.) - especially if source files are not at the end of the argument list - and allows "read arguments from file" syntax.
This pull includes some changes to surrounding code (specifically, Cython.Compiler.Main), either for integration or performance issues.
The only potential issue is with --embed argument, since it allows its value to be implied:
cython --embed myfile
is ok, but:
cython --embed=mymain myfile
is correctly understood only by argparse. Secondly,
cython --embed mymain myfile
is ambigous. Since the parser is greedy for source files, mymain will be considered a source file, actually breaking the case above with a "more than one file" error. If anyone liked that syntax, it may use:
cython --embed mymain -- myfile
This syntax also allows for explicit main() name specification in optparse version.
This is hard to be fixed. At least, I could have optparse to ignore it and parse --embed form manually, but that would be a huge HACK.
NOTE: my branch has passed all tests from testsuite, including a purposedly written one (see Cython.Compiler.Tests.TestCommandLine) but, please, double check this ;)
Add Entry.cf_used attribute
Set entry.cf_used to False when argument is unused
Mark unused cdef-function args with CYTHON_UNUSED
Don't initialize unused cdef-function optional args
Add generic python args test
Add runtime test with unused arguments
Don't remove optional args when function is overridable
Only mark skip_dispatch arg as unused if function has OverrideCheckNode
Mark unused vars with CYTHON_UNUSED qualifier
Mark unused METH_O arguments
Merge pull request #50 from vitek/_unused_args
Silence warning about unused args
Some Python 2.3 cleanup.
Refuse to compile for Python < 2.4
More Py2.3 cleanup.
AttributeNode.as_cython_attribute(): make method return value explicit
test case for ticket #653
fix type inheritance check for builtin types
fix support for redeclaring builtin types as external extension types…
…, add a big FIXME to mark for eventual removal
implement may_be_none() for CloneNode
fix ticket #653
- generate correct code for optimised override calls to methods of builtin types in subtypes
- optimise calls for 'final' subtypes
- disable optimised C-API calls for non-final subtypes
drop unused import
Command line parsing now uses argparse module. Still a work in progre…
Turned flags structure into a readable dictionary.
Completed transition to argparse module. Start adding optparse compat…
Added optparse fallback.
Added complete test case for Cython.Compiler.CmdLine module.
Completed test case for debug options & directives.
Completed -X and --debug parsing options. Partial regression for optp…
Small functional adds (to reflect changes in the CmdLine module)
Fixed small error in alternate Parser() implementation
Now default options are no more overridden in Option
Removed deprecated internal functions.
Corrected other lack in alternate implementation (optparse)
Turned c-style booleans (0 as False, 1 as True) into real python bools.
Fixed bug in optparse's --embed recognition
Replaced conditional import of argparse with a try: catch: block
Replaced failUnlessEqual with assertEqual wherever possible.
Adequated some tests to new CmdLine.py internals.
Now dictionaries and lists belonging to Options are no more overridden.
Added a HACK to prevent unwanted behaviour of --embed in some test ca…
Updated tests for Cython.Compiler.CmdLine
Added secure list for options to insert into Options module (so that …
change is applied if a duplicate - but indipendent - variable will be added)
Added cleanup code to avoid a long series of nasty errors. BIG TODO: …
Modified optparse code to support variable length --embed flag
Removed a test case, added a remark in error messages.
Added one more hack for optparse, now both versions passed all the te…
Removed fake import to force optparse version
Modified debug flags syntax.
Removed obsoleted code.
Updated copyright line.
Actually, I rewrote this file from scratches, but I've updated the copyright line to Pyrex&Cython team. This is because there is no Cython Foundation to enforce our rights.
Fixing small typo.
Ok, I figured out a small HACK for --embed... I'll sketch it as soon as I'm back, and I'll commit :)
Small fixes, tuples for all menu dictionary keys.
Removed "check if option key is a string".
Polishing code. Added quick --embed form recognition.
Any change to the licensing wording should be discussed on the list, not slipped into an unrelated pull request such as this. The top-level license and copying files have been sufficient without the need for per-file boilerplate.
This seems to add a lot of complexity, e.g. spanning optparse/argparse, without any clear benefit (and perhaps a regression, or a lot of hackery, regarding --embed). Also, the current omission of certain flags in usage was intentional. The current setup works fine.