Skip to content
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

WIP: Port bash script naveen521kk to .travis.yml #1

Closed
68 changes: 49 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,33 @@ matrix:
- os: windows
language: sh
python: 3.6
name: Build on Python 3.6.8 in Windows
env: PYVER="3.6.8" CAIRO_VERSION=1.17.2
name: Build on x64 Python 3.6.8 in Windows
env: ARCH=x64 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=python PYTHON_VERSION="3.6.8"
- os: windows
language: sh
python: 3.7
name: Build on Python 3.7.7 in Windows
env: PYVER="3.7.7" CAIRO_VERSION=1.17.2
name: Build on x64 Python 3.7.7 in Windows
env: ARCH=x64 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=python PYTHON_VERSION="3.7.7"
- os: windows
language: sh
python: 3.8
name: Build on Python 3.8.3 in Windows
env: PYVER="3.8.3" CAIRO_VERSION=1.17.2
name: Build on x64 Python 3.8.3 in Windows
env: ARCH=x64 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=python PYTHON_VERSION="3.8.3"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be updated to 3.8.5 as it is released now.

Suggested change
env: ARCH=x64 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=python PYTHON_VERSION="3.8.3"
env: ARCH=x64 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=python PYTHON_VERSION="3.8.5"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good spot...

We can automate this, I spoke to dependencies.io who gave me an account for open source stuff + that can generate diffs and PRs for this sort of thing.

It's annoying nuget doesn't accept a query like 3.7.x and give the highest match, I wonder if chocolatey can do it?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use a query like 3.7 I think.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I just found that choco and nuget are one and the same thing in structure. Choco uses nugets structure.

Copy link
Collaborator Author

@stuaxo stuaxo Aug 20, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chocolatey has some extensions, I'm inclined to switch back to it, as it has some advantages.
Native support in Travis: one less thing to install, and Travis' cache support seems to include it.

You can force it to install for 32 or 64 bit as needed.

Semver: not supported now, but they have a ticket.
chocolatey/choco#1610

In the meantime I think we might be able to do semver support with a combination of powershell and the output of choco search or hit their API directly with cURL.

This would be good as we could specify the python version with 2 digit versions, not 3, so one less thing to support and patch.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can pass - -x86 to install 32 bit versions, I haven't tried it yet.

Copy link
Owner

@naveen521kk naveen521kk Aug 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That doesn't help much. Nuget python is build for CI ,but choco is using default py installer which may be troublesome. So better to use nuget for x86.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough, will stay on nuget, if there are questions around chocolatey.

Do you know what the issues with the default installer are?

I haven't used windows as my default OS for a while, well aware windows + python + C extensions can get pretty painful.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kinda use windows as my default one. Maybe because I don't know C or something. I just know quite a few basic of python and got to know about this because of manim. Some video tool which use pycairo as it's base. I don't even have C compilers in my PC and that made me do this. But yeah Nuget x86 py build should be used or we should use something kinada docker or something but not required.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be easily fixed if we were to use GitHub Actions.

- os: windows
language: sh
python: 3.6
name: Build on x86 Python 3.6.8 in Windows
env: ARCH=x86 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=pythonx86 PYTHON_VERSION="3.6.8"
- os: windows
language: sh
python: 3.7
name: Build on x86 Python 3.7.7 in Windows
env: ARCH=x86 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=pythonx86 PYTHON_VERSION="3.7.7"
- os: windows
language: sh
python: 3.8
name: Build on x86 Python 3.8.3 in Windows
env: ARCH=x86 CAIRO_VERSION=1.17.2 PYTHON_PACKAGE=pythonx86 PYTHON_VERSION="3.8.3"
stuaxo marked this conversation as resolved.
Show resolved Hide resolved
- os: linux
dist: trusty
language: python
Expand Down Expand Up @@ -44,6 +59,8 @@ matrix:
language: generic
name: Build on Python 3.8 in Mac OSX xcode11.3
env: CFLAGS="-Werror -coverage"


install:
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then travis_retry sudo apt-get update -q; fi
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then travis_retry sudo apt-get install -y libcairo2-dev; fi
Expand All @@ -56,20 +73,33 @@ install:
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then python3 -m pip install virtualenv; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then virtualenv ../venv -p python3; fi
- if [ "$TRAVIS_OS_NAME" == "osx" ]; then source ../venv/bin/activate; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python -m pip install --upgrade setuptools; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python -m pip install --upgrade pytest flake8 "sphinx<3" sphinx_rtd_theme coverage codecov hypothesis attrs; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python -m pip install --upgrade mypy || true; fi
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then curl -sS -L https://aka.ms/nugetclidl -o $TMP/nuget.exe; fi
stuaxo marked this conversation as resolved.
Show resolved Hide resolved
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then curl -sS -L https://github.com/preshing/cairo-windows/releases/download/$CAIRO_VERSION/cairo-windows-$CAIRO_VERSION.zip -o $TMP/cairo-windows-$CAIRO_VERSION.zip; fi
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then 7z x $TMP/cairo-windows-$CAIRO_VERSION.zip -o$TMP; fi
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then $TMP/nuget install python -Version $PYTHON_VERSION -OutputDirectory $TMP/nuget-$ARCH; fi
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then export INCLUDE="$TMP/cairo-windows-$CAIRO_VERSION/include"; fi
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then export LIB=$TMP/cairo-windows-$CAIRO_VERSION/lib/$ARCH; fi
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then export PATH=$TMP/nuget-$ARCH/python.$PYTHON_VERSION/tools/:$TMP/nuget-$ARCH/python.$PYTHON_VERSION/tools/Scripts:$PATH; fi
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found why it fails. Because the nuget package pythonx86 contains x86 build of python and it does pull x64 python and then later tries to build for x86 which makes is fail. :( Check my shell script.

- python -m pip install --upgrade wheel
- python -m pip install --upgrade setuptools
- python -m pip install --upgrade pytest flake8 "sphinx<3" sphinx_rtd_theme coverage codecov hypothesis attrs
- python -m pip install --upgrade mypy || true
- if [[ "$TRAVIS_OS_NAME" != "osx" ]] && [[ "$TRAVIS_PYTHON_VERSION" != "3.8" ]] && [[ "${TRAVIS_PYTHON_VERSION:0:4}" != "pypy" ]]; then python -m pip install --upgrade pygame; fi

script:
#windows build
- if [ "$TRAVIS_OS_NAME" == "windows" ]; then source .travis/runPycairo.sh; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python setup.py sdist; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python setup.py bdist; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python setup.py install --root=_root; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python setup.py install --root="$(pwd)"/_root_abs; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python setup.py bdist_wheel; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python setup.py install --root=_root_setup; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then if [[ "${TRAVIS_PYTHON_VERSION:0:4}" != "pypy" ]] ; then python -m pip install .; fi; fi
- if [ "$TRAVIS_OS_NAME" != "windows" ]; then python -m sphinx -W -a -E -b html -n docs docs/_build; fi
- if [[ "$TRAVIS_OS_NAME" == "windows" ]] ; then cp $TMP/cairo-windows-$CAIRO_VERSION/lib/$ARCH/cairo.dll cairo/cairo.dll; fi
- python -m coverage run --branch setup.py test
- python -m codecov --required || true
stuaxo marked this conversation as resolved.
Show resolved Hide resolved
- python -m flake8 .
- python setup.py sdist
- python setup.py bdist
- python setup.py install --root=_root
- python setup.py install --root="$(pwd)"/_root_abs
- python setup.py bdist_wheel
- python setup.py install --root=_root_setup
- if [[ "${TRAVIS_PYTHON_VERSION:0:4}" != "pypy" ]] ; then python -m pip install .; fi
- python -m sphinx -W -a -E -b html -n docs docs/_build


deploy:
if: TRAVIS_OS_NAME = windows
Expand Down
3 changes: 3 additions & 0 deletions tests/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
sys.version_info[:2] < (3, 6), reason="Py3.6 only")
pytestmark

skipwindows = pytest.mark.skipif(sys.platform == "win32", reason="Is not a valid test on windows")


def test_mypy():
out, err, status = mypy.run([os.path.dirname(cairo.__path__[0])])
if status != 0:
raise Exception("\n" + "\n".join([out, err]))


@skipwindows
def test_typing():
mod = types.ModuleType("cairo")
stub = os.path.join(cairo.__path__[0], "__init__.pyi")
Expand Down