Python support on Windows


#1

Thank you for supporting Windows. As you know Python is a very popular language and is cross-platform. I would love to see Python supported in the Windows Build Environment.


#2

For Travis’s support for Python on Windows to be worth the bother, it would need:

  • Correct version of Visual Studio installed for the Python version (https://wiki.python.org/moin/WindowsCompilers)
  • Visual Studio’s environment is already set up in the Git Bash session that pre_install and install scripts run in i.e., Travis takes care of running vcvarsall.bat or whatever it’s called. This would require translating the bat code to bash, and Travis would really earn their fees by taking care of that for me.
  • pip install source packages that require a compiler Just Works (e.g., small projects such as ecos or scs can be installed with pip instal ecos or pip install scs and nothing else)
  • No being forced to use non-standard package managers such as conda (yes I know conda is common in the scientific community, but it’s not in the larger Python community. Pip is bundled with Python. Pip is the standard.)

Additional wish list:

  • MS Office is available for Python code that interacts with Excel (e.g., via xlwings)
  • Chrome and Firefox are available for projects that run Selenium tests.
  • Common packages on Linux/macOS are preinstalled on Windows, since you can’t just apt-get or brew install things like, I don’t know, say, BLAS or LAPACK (maybe not great examples, but hopefully you see what I’m driving at).

#3

This is something I’m definitely interested in seeing happen. Unlike @wkschwartz, I think even if Travis doesn’t provide a works out-the-box compiler setup, it’ll still be good enough for my use cases, where wheels and pure Python sdists are good enough.

For widespread usage, however, would require the compiler setup to be done properly.


#4

First of all …

Thank you for your interest in bringing Python support to Windows! We very much appreciate your enthusiasm.

I will describe how Python support works on Linux right now. Do keep in mind that Windows is a new game, and it would not have to happen in the same way as it does in the other two OSes. (Though, obviously, similar tooling may reduce the amount of work it would take to make it happen.)

How PHP support works now on Linux

Much of what we would call “Windows support” on Travis CI is described in https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/script/python.rb.

  1. It assumes that there is a usable virtualenv installed on the system.
  2. Look for the applicable activate file. If it’s not there, fetch the applicable Python archive from our S3 bucket and expand it. The archive contains the activate file.
  3. source .../activate

Creating pre-compiled Python archives

https://github.com/travis-ci/cpython-builder/ is responsible for compiling and creating new Python archives. It sets up (if necessary) a Python building environment, compiles Python using python-build, and uploads the archives to the right place so that travis-build can find it at the run time.

How should Python support on Travis look?

This is an open question. As I said earlier, I might be less work to make it look a lot like Linux. Maybe not. My understanding of the Windows ecosystem is very limited.

Option 1: Leverage current tooling

In this case, I reckon the first thing to do would be to create a base set of Python archives for use by Windows VMs. This would start with a language: sh job on Windows, use python-build to compile, archive and upload to the remote file storage. I do not know if python-build, written in bash, is compatible with “git bash”. If it’s not, it could be some work to make it so.

This would also mean that we ensure that the Windows image has a reasonable C/C++ toolchain that we can use.

Option 2: Use Windows-native tooling

It might be more intuitive for Windows developers to use the Windows-native tools. For example, https://www.python.org/downloads/windows/ has many archives that might be usable. Or, alternatively, Chocolatey archive(s) might be more in tune with what we need.


I hope all of this makes some sense, and helps you get started.


#5

If you don’t need working compiler setup it’s quite easy to test Python code right now, see https://github.com/WeblateOrg/translation-finder/blob/master/.travis.yml#L20-L26


#6

https://staging.travis-ci.com/ifduyue/test-travis/jobs/235583/config

Python.3.6.7-amd64.exe /quiet install will hang for more than 10 minutes and then build job will get terminated


#7

I tried to duplicate this, but it either times out installing Python 3 or (if I skip that step, Python 3 is supposed to already be installed) can’t find Python. Any thoughts on what I’m doing different than you?


#8

Sigh… it seems to be a known issue with secrets.


#9

Hi,

I’d love Windows Python3 support in Travis too - Happy to test + help. Here would be my dream .travis.yml:
Today: https://github.com/pypa/bandersnatch/blob/master/.travis.yml
Diff: https://pastebin.com/zmNFKqnP

Is there any way third parties can help with making the support happen?