0

I am trying to upload an app to the Mac app store. I have used py2app to create an application bundle, code signed the frameworks and executables, created a .pkg using productbuild and signed that too. Everything seems fine until I use application loader. Here is the error message I get:

Package Summary:

1 package(s) were not uploaded because they had problems:
    /var/folders/0n/tcm_mnqx7xz7x4z87_96y88r0000gn/T/2202BA63-472B-4357-9F4C-4127EA0E2E25/1050509510.itmsp - Error Messages:
        ERROR ITMS-90135: "The executable could not be re-signed for submission to the App Store. The app may have been built or signed with non-compliant or pre-release tools."

After much trial and error, I narrowed down the possible problems to one module. My app uses matplotlib to create graphs. Because I use matplotlib, I must include the numpy module (it's a dependency). I get the error above only when numpy is included in the app. As soon as I delete it's folder from appName/Contents/Resources/lib/python3.4/numpy, the error is gone and the app begins to upload. However, because numpy is now removed, my app no longer works.

My Questions

  1. Can I remove matplotlib's dependencies on numpy so I can remove numpy altogether? Or is there a version of matplotlib that does not need numpy?
  2. Is there a way to keep numpy in the package and still use application loader?

I have tried tricking matplotlib into thinking numpy is still there by adding 'empty' files (Ex: making the __init__.py in numpy an empty document), but with no success.

Here is a list of the modules I have imported for matplotlib:

from matplotlib import pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
from matplotlib.figure import Figure
from matplotlib import style

I am using:

Python 3.4, OSX 10.10.5, Application Loader 3.2 (also tried 3.0)

Camon
  • 1,003
  • 1
  • 10
  • 22
  • 1
    From my recollection, when looking at the source, numpy is quite deeply embedded. However, you could probably write a mock library for numpy that does everything that matplotlib needs from numpy but without any actual compilation. It would just make matplotlib slower. – breeden Oct 21 '15 at 18:39
  • That's what I noticed when trying to remove all of the module imports from matplotlib, too many of them to count. How would you go about creating a mock library for numpy? – Camon Oct 21 '15 at 18:42
  • Honestly, if that's what I wanted to do, I would just grep for all uses of numpy in matplotlib and write those functions in pure python. Most of them aren't difficult, but just slower in python than using compiled libraries. – breeden Oct 21 '15 at 18:44
  • i did a grep to see what it would take and got this (at least): http://paste.ubuntu.com/12887692/. Doesn't look like an easy task to be honest. – breeden Oct 21 '15 at 18:55
  • Replacing numpy as a dependency would, amongst other things, involve implementing your own version of `np.ndarray`. This is a very non-trivial amount of work, even if you didn't care at all about performance. – ali_m Oct 21 '15 at 18:59
  • The funny thing is I don't need 98% of those. Most of the items on that list are math functions that I can easily access from other modules (like python's math module). Any idea why Apple's application loader won't accept numpy's resources? – Camon Oct 21 '15 at 18:59
  • *"Most of the items on that list are math functions that I can easily access from other modules (like python's math module)"*. It's not that simple when you consider that even basic operations on numpy arrays are vectorized. `np.array([1, 2, 3]) * 3` is *very* different to `[1, 2, 3] * 3`. What about multidimensional arrays? Broadcasting? Linear algebra? – ali_m Oct 21 '15 at 19:05
  • Is there a way to tell matplotlib to only use the parts of numpy that are responsible for plotting? Then remove all of the extra files that are not used? – Camon Oct 21 '15 at 19:11
  • Adding to the question, is there a way to find out what part of numpy is causing application loader to throw the error above and re-write or remove that part? – Camon Oct 21 '15 at 19:25
  • 1
    matplotlib uses `np.ndarray` objects pretty much everywhere. Just to give you some idea of what that entails, [here's the C source code just for numpy's core array type](https://github.com/numpy/numpy/tree/master/numpy/core/src/multiarray). If I were you I would focus on whether there is a workaround for the code signing issue rather than trying to remove numpy as a dependency. I'm not an app developer, but you might find some useful information [here](http://stackoverflow.com/q/4733847/1461210) or in one of the related questions. – ali_m Oct 21 '15 at 19:32

1 Answers1

0

I managed to solve the issue with Apple's application loader. As mentioned in some of the responses to my original question, numpy is too deeply integrated into matplotlib. There is no easy way to rewrite, substitute, or remove numpy. To resolve the error message from application loader, you need to remove one particular file from numpy. The file in question is libnpymath.a and can be found in the folder appName/Contents/Resources/lib/python3.4/numpy/core/lib. Once you delete it, application loader doesn't scream at you anymore (at least for that particular issue).

My app seems to work just fine without the removed file as it did before.

Camon
  • 1,003
  • 1
  • 10
  • 22