# Python support on Windows

**URL:** <https://travis-ci.community/t/python-support-on-windows/241>\
**Category:** Windows\
**Created:** [October 11, 2018, 2:20pm UTC](https://travis-ci.community/t/python-support-on-windows/241 "2018-10-11T14:20:49Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![NoCode](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/nocode/32/290_2.png) [@NoCode](https://travis-ci.community/u/NoCode)\
**Post date:** [October 11, 2018, 2:20pm UTC](https://travis-ci.community/t/python-support-on-windows/241/1 "2018-10-11T14:20:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![wkschwartz](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/wkschwartz/32/157_2.png) [@wkschwartz](https://travis-ci.community/u/wkschwartz)\
**Post date:** [October 12, 2018, 5:21pm UTC](https://travis-ci.community/t/python-support-on-windows/241/2 "2018-10-12T17:21:16Z")

</div>

**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](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).

---

<div class="post-metadata">

**Author:** ![pradyunsg](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/pradyunsg/32/170_2.png) [@pradyunsg](https://travis-ci.community/u/pradyunsg)\
**Post date:** [October 13, 2018, 7:54am UTC](https://travis-ci.community/t/python-support-on-windows/241/3 "2018-10-13T07:54:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![BanzaiMan](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/banzaiman/32/67_2.png) [@BanzaiMan](https://travis-ci.community/u/BanzaiMan)\
**Post date:** [October 18, 2018, 7:02pm UTC](https://travis-ci.community/t/python-support-on-windows/241/4 "2018-10-18T19:02:45Z")

</div>

# 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](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/](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](https://github.com/pyenv/pyenv/tree/master/plugins/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/](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.

---

<div class="post-metadata">

**Author:** ![nijel](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/nijel/32/235_2.png) [@nijel](https://travis-ci.community/u/nijel)\
**Post date:** [October 19, 2018, 1:59pm UTC](https://travis-ci.community/t/python-support-on-windows/241/5 "2018-10-19T13:59:45Z")

</div>

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](https://github.com/WeblateOrg/translation-finder/blob/master/.travis.yml#L20-L26)

---

<div class="post-metadata">

**Author:** ![duyue](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/duyue/32/251_2.png) [@duyue](https://travis-ci.community/u/duyue)\
**Post date:** [October 24, 2018, 4:09am UTC](https://travis-ci.community/t/python-support-on-windows/241/6 "2018-10-24T04:09:08Z")

</div>

[https://staging.travis-ci.com/ifduyue/test-travis/jobs/235583/config](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

---

<div class="post-metadata">

**Author:** ![MinchinWeb](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/minchinweb/32/286_2.png) [@MinchinWeb](https://travis-ci.community/u/MinchinWeb)\
**Post date:** [October 26, 2018, 12:28am UTC](https://travis-ci.community/t/python-support-on-windows/241/7 "2018-10-26T00:28:33Z")

</div>

I tried to duplicate this, but it either [times out installing Python 3](https://travis-ci.org/MinchinWeb/minchinweb.github.io/jobs/446444299) or (if I skip that step, Python 3 is supposed to already be installed) [can’t find Python](https://travis-ci.org/MinchinWeb/minchinweb.github.io/builds/446445774). Any thoughts on what I’m doing different than you?

---

<div class="post-metadata">

**Author:** ![MinchinWeb](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/minchinweb/32/286_2.png) [@MinchinWeb](https://travis-ci.community/u/MinchinWeb)\
**Post date:** [October 26, 2018, 12:49am UTC](https://travis-ci.community/t/python-support-on-windows/241/8 "2018-10-26T00:49:03Z")

</div>

Sigh… it seems to be a [known issue with secrets](https://travis-ci.community/t/current-known-issues-please-read-this-before-posting-a-new-topic/264).

---

<div class="post-metadata">

**Author:** ![cooperlees](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cooperlees/32/331_2.png) [@cooperlees](https://travis-ci.community/u/cooperlees)\
**Post date:** [November 1, 2018, 5:33pm UTC](https://travis-ci.community/t/python-support-on-windows/241/9 "2018-11-01T17:33:02Z")

</div>

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](https://github.com/pypa/bandersnatch/blob/master/.travis.yml)  
Diff: [https://pastebin.com/zmNFKqnP](https://pastebin.com/zmNFKqnP)

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

---

<div class="post-metadata">

**Author:** ![kangwonlee](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/kangwonlee/32/811_2.png) [@kangwonlee](https://travis-ci.community/u/kangwonlee)\
**Post date:** [December 1, 2018, 3:24am UTC](https://travis-ci.community/t/python-support-on-windows/241/10 "2018-12-01T03:24:47Z")

</div>

Hi

Thanks for supporting Windows. 8)

If I may suggest : I would be happier with python3 + conda support.

> <https://github.com/kangwonlee/travis-yml-conda-posix-nt/blob/master/.travis.yml>

Hope this helps all & I welcome any comments and/or suggestions.

KW

---

<div class="post-metadata">

**Author:** ![native-api](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/native-api/32/430_2.png) [@native-api](https://travis-ci.community/u/native-api)\
**Post date:** [December 1, 2018, 6:04am UTC](https://travis-ci.community/t/python-support-on-windows/241/11 "2018-12-01T06:04:31Z")

</div>

> [@wkschwartz](#):
>
> 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.

Python’s `distutils`/`setuptools` build system takes care of detecting a VS compiler and setting up build environment (up to and including running `vcvars*.bat` and extracting envvars from the result), so you don’t really need that.

> [@wkschwartz](#):
>
> 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.)

Ditto.

---

<div class="post-metadata">

**Author:** ![kangwonlee](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/kangwonlee/32/811_2.png) [@kangwonlee](https://travis-ci.community/u/kangwonlee)\
**Post date:** [December 1, 2018, 9:32am UTC](https://travis-ci.community/t/python-support-on-windows/241/12 "2018-12-01T09:32:25Z")

</div>

BTW, the Windows of Travis-CI, if I am correct, is not supporting python yet either.

Let me think about using pip later (excuse me for not making changes immediately)

KW

---

<div class="post-metadata">

**Author:** ![kangwonlee](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/kangwonlee/32/811_2.png) [@kangwonlee](https://travis-ci.community/u/kangwonlee)\
**Post date:** [December 2, 2018, 3:42am UTC](https://travis-ci.community/t/python-support-on-windows/241/13 "2018-12-02T03:42:40Z")

</div>

Also, I noticed that the conda build is taking some time.

To save the resources, is it desirable to utilize [cache](https://docs.travis-ci.com/user/caching/)?

How would I be able to check if the cache content is relevant before a build breaks?

Best Wishes,

KW

---

<div class="post-metadata">

**Author:** ![mgiaco](https://avatars.discourse-cdn.com/v4/letter/m/9e8a1a/32.png) [@mgiaco](https://travis-ci.community/u/mgiaco)\
**Post date:** [December 13, 2018, 3:06pm UTC](https://travis-ci.community/t/python-support-on-windows/241/14 "2018-12-13T15:06:20Z")

</div>

So I can use conda but is there any way to use a plain python 3.6 or 3.7 and install some packages with pip?

---

<div class="post-metadata">

**Author:** ![cclauss](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cclauss/32/912_2.png) [@cclauss](https://travis-ci.community/u/cclauss)\
**Post date:** [January 9, 2019, 10:23am UTC](https://travis-ci.community/t/python-support-on-windows/241/15 "2019-01-09T10:23:14Z")

</div>

@mgiaco See [https://github.com/cclauss/itinerant-tester-windows](https://github.com/cclauss/itinerant-tester-windows)

---

<div class="post-metadata">

**Author:** ![senakafdo](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/senakafdo/32/1156_2.png) [@senakafdo](https://travis-ci.community/u/senakafdo)\
**Post date:** [February 12, 2019, 11:25pm UTC](https://travis-ci.community/t/python-support-on-windows/241/16 "2019-02-12T23:25:13Z")

</div>

See [https://github.com/ove/ove-install](https://github.com/ove/ove-install). As long as you don’t have secure environment variables, like I do, it should build perfectly well and do whatever you like.

---

<div class="post-metadata">

**Author:** ![ben-spiller](https://avatars.discourse-cdn.com/v4/letter/b/a3d4f5/32.png) [@ben-spiller](https://travis-ci.community/u/ben-spiller)\
**Post date:** [February 20, 2019, 4:13pm UTC](https://travis-ci.community/t/python-support-on-windows/241/17 "2019-02-20T16:13:42Z")

</div>

FWIW the presence of python (and pip) would on its own be hugely valuable for many projects, so is worth doing even if it takes a bit longer to solve the harder problems around native building. A huge number of python projects don’t have any native/C++ component.

Also if it speeds things up, supporting even just one python version (e.g. python 3 not python 2) would be a great first step, and enough for many projects.

Using the pre-built binaries from [https://www.python.org/downloads/windows/](https://www.python.org/downloads/windows/) or choco would be more idiomatic (and probably a lot simpler to implement) than trying to build python from source, since that’s what most end-users of python applications/modules will be doing, so is what people running tests from Travis would find most useful.

---

<div class="post-metadata">

**Author:** ![cclauss](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cclauss/32/912_2.png) [@cclauss](https://travis-ci.community/u/cclauss)\
**Post date:** [April 2, 2019, 9:41am UTC](https://travis-ci.community/t/python-support-on-windows/241/18 "2019-04-02T09:41:38Z")

</div>

Why can’t the following intuitive approach work and be fast??

```
language: python
python: 3.7
os:
  - linux
  - osx
  - windows
install: pip3 install --upgrade pip
script: python3 platform-info.py

```

The [minimal .travis.yml](https://github.com/cclauss/Travis-CI-Python-on-three-OSes) file required to run Python 3.7 on Linux, macOS, and Windows is unnecessary complex, fragile, and slow. Would it at least be possible to have **choco install python** done on the Windows base image to save a 1 min 30 sec startup time?

[https://docs.travis-ci.com/user/languages/python/#running-python-tests-on-multiple-operating-systems](https://docs.travis-ci.com/user/languages/python/#running-python-tests-on-multiple-operating-systems)

> **[cclauss/Travis-CI-Python-on-three-OSes](https://github.com/cclauss/Travis-CI-Python-on-three-OSes)**
>
> Minimal .travis.yml file to run the current Python 3.7 on Linux, macOS, and Windows - cclauss/Travis-CI-Python-on-three-OSes

---

<div class="post-metadata">

**Author:** ![moonshoes87](https://avatars.discourse-cdn.com/v4/letter/m/5daacb/32.png) [@moonshoes87](https://travis-ci.community/u/moonshoes87)\
**Post date:** [April 18, 2019, 9:56pm UTC](https://travis-ci.community/t/python-support-on-windows/241/19 "2019-04-18T21:56:32Z")

</div>

I haven’t been able to figure out how to install miniconda with the Travis CI windows environment, although I gather that it is possible based on other people’s comments. Could anyone point me towards the documentation on this?

---

<div class="post-metadata">

**Author:** ![cclauss](https://sea1.discourse-cdn.com/flex015/user_avatar/travis-ci.community/cclauss/32/912_2.png) [@cclauss](https://travis-ci.community/u/cclauss)\
**Post date:** [May 14, 2019, 12:27pm UTC](https://travis-ci.community/t/python-support-on-windows/241/20 "2019-05-14T12:27:16Z")

</div>

> <https://github.com/kangwonlee/travis-yml-conda-posix-nt/blob/master/.travis.yml>

[Next page](https://travis-ci.community/t/python-support-on-windows/241.md?page=2)
