Fixes TypeError when installing without freetype #3414

Merged
merged 1 commit into from Aug 30, 2014

Projects

None yet

5 participants

@remram44
Contributor

When freetype-config is missing, setup.py crashes with TypeError. This fixes it and allows the "required packages" info to be printed.

Log of the error installing 1.4.0:

(venv-mpl)remram@vebian:~$ pip install -U matplotlib
Downloading/unpacking matplotlib
  Downloading matplotlib-1.4.0.tar.gz (51.2MB): 51.2MB downloaded
  Running setup.py (path:/tmp/venv-mpl/build/matplotlib/setup.py) egg_info for package matplotlib
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [1.4.0]
                    python: yes [2.7.8 (default, Aug 10 2014, 16:19:34)  [GCC
                            4.9.1]]
                  platform: yes [linux2]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [not found. pip may install it below.]
                       six: yes [six was not found.]
                  dateutil: yes [dateutil was not found. It is required for date
                            axis support. pip/easy_install may attempt to
                            install it after matplotlib.]
                   tornado: yes [tornado was not found. It is required for the
                            WebAgg backend. pip/easy_install may attempt to
                            install it after matplotlib.]
                 pyparsing: yes [pyparsing was not found. It is required for
                            mathtext support. pip/easy_install may attempt to
                            install it after matplotlib.]
                     pycxx: yes [Couldn't import.  Using local copy.]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
    Traceback (most recent call last):
      File "<string>", line 17, in <module>
      File "/tmp/venv-mpl/build/matplotlib/setup.py", line 154, in <module>
        result = package.check()
      File "setupext.py", line 940, in check
        if 'No such file or directory\ngrep:' in version:
    TypeError: argument of type 'NoneType' is not iterable
    Complete output from command python setup.py egg_info:
    ============================================================================

Edit setup.cfg to change the build options



BUILDING MATPLOTLIB

            matplotlib: yes [1.4.0]

                python: yes [2.7.8 (default, Aug 10 2014, 16:19:34)  [GCC

                        4.9.1]]

              platform: yes [linux2]



REQUIRED DEPENDENCIES AND EXTENSIONS

                 numpy: yes [not found. pip may install it below.]

                   six: yes [six was not found.]

              dateutil: yes [dateutil was not found. It is required for date

                        axis support. pip/easy_install may attempt to

                        install it after matplotlib.]

               tornado: yes [tornado was not found. It is required for the

                        WebAgg backend. pip/easy_install may attempt to

                        install it after matplotlib.]

             pyparsing: yes [pyparsing was not found. It is required for

                        mathtext support. pip/easy_install may attempt to

                        install it after matplotlib.]

                 pycxx: yes [Couldn't import.  Using local copy.]

                libagg: yes [pkg-config information for 'libagg' could not

                        be found. Using local copy.]

Traceback (most recent call last):

  File "<string>", line 17, in <module>

  File "/tmp/venv-mpl/build/matplotlib/setup.py", line 154, in <module>

    result = package.check()

  File "setupext.py", line 940, in check

    if 'No such file or directory\ngrep:' in version:

TypeError: argument of type 'NoneType' is not iterable

----------------------------------------
Cleaning up...
@tacaswell tacaswell added this to the v1.4.x milestone Aug 26, 2014
@tacaswell tacaswell commented on the diff Aug 26, 2014
setupext.py
@@ -937,7 +937,7 @@ def check(self):
# Early versions of freetype grep badly inside freetype-config,
# so catch those cases. (tested with 2.5.3).
- if 'No such file or directory\ngrep:' in version:
+ if version is None or 'No such file or directory\ngrep:' in version:
@tacaswell
tacaswell Aug 26, 2014 Member

should this be if version is not None and ... ?

@remram44
remram44 Aug 26, 2014 Contributor

No, this is what I meant. The next line gets version another way.

@tacaswell
tacaswell Aug 26, 2014 Member

It is not obvious to me that what ever makes the call fail should be handled the same as the case this if statement is supposed to catch (where the call succeeds (returns 0), but does not work).

@remram44
remram44 Aug 26, 2014 Contributor

Original pull request: #3363.

I think handling an invalid return value (the text "No such file or directory...") the same as an error code (status != 0) from freetype-config makes sense. The original PR really works around the fact that freetype-config exits with 0 on error here.

@tacaswell
Member

@pelson Can you take a look at this?

@tacaswell
Member
@jperras
jperras commented Aug 26, 2014

I ran into this exact issue moments ago. Applied the given pull request to the current HEAD, installed manually via python setup.py install, and it installed as expected.

@pelson
Member
pelson commented Aug 30, 2014

👍 - thanks for this.

@pelson pelson merged commit 08c41b1 into matplotlib:v1.4.x Aug 30, 2014

1 check passed

continuous-integration/travis-ci The Travis CI build passed
Details
@remram44 remram44 deleted the unknown repository branch Aug 30, 2014
@QuLogic QuLogic removed the needs_review label Nov 24, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment