[Distutils] setup.cfg new format proposal

Tarek Ziadé ziade.tarek at gmail.com
Fri Sep 11 17:14:57 CEST 2009


2009/9/11  <exarkun at twistedmatrix.com>:
> On 02:33 pm, ziade.tarek at gmail.com wrote:
>>
>> Hello
>>
>> here's a detailed proposal for the setup.cfg format. I've included all
>> remarks,
>> and tried to make the syntax as simple as possible. I've dropped the
>> long_description
>> stuff and the template language stuff. (people can do it as a
>> post-release process)
>>
>>
>> A/ Config file structure:
>>
>> """
>> [setup]
>> foo: bar
>> conditional-sections: one, two
>>
>> [one]
>> condition: test
>>
>> [two]
>> condition: test
>> """
>
> The idea here is that the [setup] section includes everything in section
> [one] if all of the "condition" clauses in [one] are satisfied, and includes
> everything in section [two] if all of the "condition" clauses in [two] are
> satisfied?


yes, here's a concrete example :

"""
[setup]
name: distutils
version: 1.2
conditional-sections: py26, py3

[py26]
condition: python_version <= 2.6
install_requires = lxml

[py3]
condition: python_version >= 3
install_requires = foo
"""

>>
>> 2/ Execution environment:
>>
>>  python_version = '%s.%s' % (sys.version_info[0], sys.version_info[1])
>>  os_name = os.name
>>  platform = sys.platform
>>  uname = os.uname()
>>  python_version_info = sys.version_info
>>
>> 3/ Grammar:
>>
>> comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
>> comparison: expr (comp_op expr)*
>> expr:
>> 'python_version'|'python_version_info'|'os_name'|'uname'|'platform'|STRING
>> test: or_test
>> or_test: and_test ('or' and_test)*
>> and_test: not_test ('and' not_test)*
>> not_test: 'not' not_test | comparison
>
> What's "STRING"?  What's the precedence of and, or, and not?  What does this
> mean?

STRING is any string value that will be compared to one of the values
provided in the environment,

Also, I've just realized that uname() is a tuple, so I need to flatten
it in strings to restrict the grammar:

- os_sysname
- os_nodename
- os_release
- os_version
- os_machine


>
>   os_name > uname > 7
>
> What does "is" mean?

That can be dropped since we have '==' and it's all strings.

so:

comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'

>
> Is this all really Python, with lots of features thrown out?

I copy-pasted part of Python grammar and restricted to what we need yes,
but the idea is just to have string comparisons with ands and ors

>>
>> 4/ Process
>>
>> distutils will interpret [setup] and act upon, to fill the
>> Distribution object and its metadata attribute object.
>> It will look only for Metadata fields and ignores the others.
>>
>> In case an option is passed in setup.py, it overrides the one in
>> setup.cfg.
>>
>> Let me know if it's good enough. I won't write a PEP for this change,
>> and I will just push it for information at python-dev as soon as I get
>> enough +1 :)
>
> I'm a little skeptical about creating a new mini language (particularly one
> with branching) for setup.cfg, but I haven't really been paying close
> attention to this discussion.  Still, it might be good to give a brief
> summary of the justification for this someplace.  Maybe you were already
> planning to do that.

The idea is to be able to get with setup.cfg all the metadata without running
any code from the distribution, and without installing it.

Which is possible for most cases. (if not possible, setup.py  can still be used)

the mini-language is to be able to adapt these metadata depending on
the execution context. I'll add a doc somewhere.

Tarek


More information about the Distutils-SIG mailing list