It seems that there is no support for using environment markers to enable installation of a package only inside a virtual environment, avoiding installing it when not using a virtualenv.
In case someone wonders why this would be needed, I will give a clear example: selinux. Major linux distributions which include python also provide the selinux-python-bindings library as a (separate/optional) package. This package is needed by big number of python libraries.
Still, the default behavior of virtualenv is to create isolated virtual enviroments, which means that the selinux library would not be available to the environment. Alternative is to either create the environments with --site-packages or to manually copy the few binary files from the system to the virtualenv (very hacky, likely to break on python or selinux upgrades,… but common approach).
As the selinux python library is quite simple, I come up with another approach: creating a shim pure-python selinux library, with the same name which loads the real library from its system location.
To my surprise it worked on most linux distros I tested with and also when installed at user or system level (outside virtualenv) – as the binaries happen not to be installed in a folder.
While I can still install the shim version it would really be nice to ablet make its installtion conditional and install it only when inside virtualenvs.