-
Notifications
You must be signed in to change notification settings - Fork 34
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
[RFE] Allow to filter tox environment for system python #128
Comments
That's an interesting use case. I think the first thing I'd need to see is how we'd determine that the current Python matches the system Python (does it actually need to be the system Python, or just the have the version match?). Once we see how to implement such a check, then I'd want to figure out how tox-travis could be of assistance in making use of that. I'm not opposed to such a feature, but that this stage I'm not sure what it would look like. |
My initial idea for detection is to check if The specific use case it to be able to use selinux in tox on Travis, the challenge is that the selinux module is a binary module that is not available in pypi (there is only a shim that tries to load the system python module: https://github.com/ssbarnea/selinux/pull/3). So therefore the module cannot be compiled by pip for the running python version. Here is my tox config that I created for this:
|
Out of curiosity, is there anything that is Travis-specific? Or is it more:
|
This sounds like a problem similar to many other modules which are distro/system libraries not usually packaged on pypi, and often have a shim for them. And most of these system libraries are loosing their py2 version as py2 EOL approaches, and only have py3 versions. If I understand correctly, the selinux shim setup.py does fail if it is run on the wrong version, and something is needed to help prevent that. One I have worked with recently, and is not quite perfect yet for my own distro, but works on others, is rpm. https://github.com/junaruga/rpm-py-installer This isnt too different to the problem at #126 , where there are system problems with a dependency on a linux distro version (xenial vs trusty) rather than linux distro python version (2 vs 3). Some solutions there may be helpful. Another approach which is more applicable for this issue, but could also work for Django, is for tox-travis to be able to inspect
|
On my normal Fedora system (which provides a variety of Python 3 versions but only one version with system modules) the tox.ini works with
The Python 3.5 requirement comes from Travis because the newest image is using Python 3.5 as the system python version. So it should be something like |
The special case is that I only need to run the tox environment once per travis build (or job?) and not for every python version. Also I do not care about the specific python version except that it should be the system python 3 version. |
Interesting enough, I do not neccesarily expect that any Python version will be the Travis version. I'd rather expect that all of the Python versions you might choose from would be install using pyenv or something similar under the hood, likely even creating a new virtualenv to go with it. If you do identify the system Python somehow, and you can use it, and if you want that Python to run that specific job, I suspect that the cleanest approach will be to add a job to the |
Providing a specific way to get the system python for a testenv sounds very useful. I recall that being commonly done in Travis precise days, when precise was still a reasonable platform that users/servers might be using. That become less sensible as Travis images become outdated and very unlikely to be what real users would be using. I havent seen system python on Travis done in combination with tox -- usually a rather raw approach is used. If there was a tox plugin solution for this, I suspect automatically setting 'sitepackages=true' for that testenv would be desirable to make it automatically have all of the packages installed via iirc, it is possible to ask pyenv to switch to the It might be that the solution to this problem is https://pypi.org/project/tox-pyenv/ (or an enhancement to it), and then maybe some extra glue in tox-travis to work with nicely tox-pyenv
|
@tyll, I have a solution which should work for you , and something I think that tox-travis and/or tox-pyenv can be enhanced to simplify, or potentially a new tox plugin My currently challenge is getting tox-travis running smoothly when even when the Travis language is not 'python'. e.g. matrix at https://travis-ci.org/jayvdb/coala-bears/builds/536638517 . The problem is the Travis languages have various https://github.com/doloopwhile/pyenv-register can add system pythons. https://github.com/doloopwhile/pyenv-register/issues/2 means it doesnt work with Python 3.6+ , but that should be easy to fix, and cloning https://github.com/garyp/pyenv-register works as a temporary fix at least. After registering the system pythons, the following activates them.
Then install tox-pyenv and you should have roughly what you are looking for to make tox's From what you've written, I guess you also want to have both I am still working on my setup, so this is a bit ugly, but copied here so you can avoid some of the problems I've bypassed so far. script:
# ...
# Must use `source` due to exports in the script
- source the_script_below_which_forces_27_and_36.sh
# ... Where the_script_below_which_forces_27_and_36.sh is set -e -x
if [ -z "$(which pyenv)" ]; then
git clone https://github.com/pyenv/pyenv.git ~/.pyenv;
export PYENV_ROOT="$HOME/.pyenv";
export PATH="$PYENV_ROOT/bin:$PATH";
fi
# https://github.com/doloopwhile/pyenv-register/pull/3
git clone https://github.com/garyp/pyenv-register.git \
$(pyenv root)/plugins/pyenv-register
SYSTEM_PYTHONS=$(ls /usr/bin/python[23] \
/usr/bin/python[23].[0-9] \
/usr/bin/python[23].[0-9].[0-9] 2>/dev/null || true)
for pybin in $SYSTEM_PYTHONS $(which python2.7) $(which python3.6); do
pyenv register -f $pybin || true
done
if [ -z "$(pyenv versions | fgrep '3.6' --max-count 1)" ]; then
git clone https://github.com/s1341/pyenv-alias.git \
$(pyenv root)/plugins/pyenv-alias;
VERSION_ALIAS=3.6 pyenv install 3.6.3;
fi
set +x
|
The selinux python module is not available on pypi, only a shim to load the system python module is. To run something in tox on Travis it would be nice to let this only run if the python version matches the system python version. Currently the user needs to keep track of the python version and update the tox travis config accordingly afaiu.
The text was updated successfully, but these errors were encountered: