Re: Python: Conditional dependencies (environment markers)
Thomas Leonard <[email protected]> Tue, 7 Mar 2017 13:15:20 +0000
| Newsgroups | gmane.comp.file-systems.zero-install.devel |
|---|---|
| Message-ID | <CAG4opy9HQ145+LYo5JdnmWfm7HrTJu7Mc0FbB4iHejHLGoi1UQ@mail.gmail.com> |
On 4 March 2017 at 14:04, Tim Diels <[email protected]> wrote: > Dear all, > > Could support be added for conditional dependencies as available in Python > packages? See https://www.python.org/dev/peps/pep-0508/#environment-markers > for how it works in Python. I need this to convert Python packages with > conditional dependencies to Zero Install feeds. It's not necessary to follow > the spec exactly, just so long as I can convert to it. > > If you are open to adding this feature to ZI, consider the initial design > below. I would love to hear about better approaches/naming for supporting > conditional dependencies. The design should be extensible as more special > cases will likely arise when converting other package types (e.g. conda) in > the future. > > First, I would make the following interfaces: > > - cpython.xml: CPython > - jython.xml: Jython > - ... > - python.xml: any python. This includes cpython.xml, jython.xml, ... > > Then for python_version, python_full_version, > platform_python_implementation. I would convert to: > > <if selected='jython.xml' version='{constraint}'> > <requires ...> > > platform_machine could perhaps be expressed as: > > <if arch={converted_platform_machine}> > <requires ...> > > where arch refers to the arch of the actual system, not the implementation. > E.g. its value is never '*-*', always something concrete. > > sys_platform (e.g. java1.8.0_51) could be handled like: > > <if selected='java.xml' version='1.8.0_51'> > <requires ...> > > Something more special would be required for platform_version as its value > depends on the runtime environment (number of cores, which kernel, ...): > > <if python:platform-version=...> > > Or instead of trying to generalise, we could add each environment marker > variable as `<if python:{environment_variable_name} >`; but likely there is > interest for conditional dependencies in other languages as well. > > I look forward to hearing your suggestions. Could you just mark the dependencies as importance="recommended"? The add conflicts for the cases that aren't supported. 0install will select the dependency whenever possible. -- talex5 (GitHub/Twitter) http://roscidus.com/blog/ GPG: 5DD5 8D70 899C 454A 966D 6A51 7513 3C8F 94F6 E0CC GPG: DA98 25AE CAD0 8975 7CDA BD8E 0713 3F96 CA74 D8BA ------------------------------------------------------------------------------ Announcing the Oxford Dictionaries API! The API offers world-renowned dictionary content that is easy and intuitive to access. Sign up for an account today to start using our lexical data to power your apps and projects. Get started today and enter our developer competition. http://sdm.link/oxford