SpanishBoy
SpanishBoy

Reputation: 2205

Error during building setup script in Python

I have next case:

  1. Desktop application with Python + PySide
  2. Want to use PYD-file (mycore.pyd) in my application
  3. There is one dependency in mycore.pyx file to Padding module
    • this Padding module already installed to the system
  4. I build Setup.py and get converted PYX-file to PYD-file, that I use in application

What I got:

Example of setup.py file:

from distutils.core import setup
from Cython.Build import cythonize


extensions = ["mycore.pyx"]

setup(
    name='mycore',
    version='1.0',
    ext_modules=cythonize(extensions),
    #packages=['Padding'], - once tried => "error: package directory 'Padding' does not exist"
)

Any ideas or advises would be great!

UPDATE

Also tried variant with setup_tools, also without success:

from Cython.Build import cythonize
from setuptools import setup, find_packages, Extension, Command


setup(name='mycore',
      packages = find_packages(),
      version=1.0,
      include_package_data=True,
      platforms=['all'],
      ext_modules=[Extension("mycore", ['mycore.c'])],
      #extra_require = {"Padding"} - also nothing
      )

Upvotes: 4

Views: 1132

Answers (3)

Yoel
Yoel

Reputation: 9614

Ask PyInstaller to include the required module during the build process. It seems that the easiest way to do so is with the --hidden-import argument:

--hidden-import=modulename
Name an imported Python module that is not visible in your code. The module will be included as if it was named in an import statement. This option can be given more than once.

Thus, please add the following argument when building the application:

--hidden-import=Padding


EDIT:

Try importing all required modules (that trigger an error) in a separate *.py file, rather than in a *.pyx \ *.pyd file. It's an ugly workaround but might solve the issue nonetheless.

Consider using an __init__.py file for this scenario.

Upvotes: 3

Chris Barker
Chris Barker

Reputation: 595

I'm guessing that the problem is that PyInstaller doesn't see packages imported by cython code, so it doesn't include it with the bundles applications.

There must be a way to tell PyInstaller to include the Padding package.

I can't tell you how -- never used it, but this is how you deal with it with py2exe and py2app.

Upvotes: 1

nixdaemon
nixdaemon

Reputation: 121

Here is a setup.py (https://github.com/robintiwari/django-me/blob/master/setup.py) file that i recently created that works and was having similar issue and I would agree with @Sanju to use setuptools.find_packages(). It fixed the issue for me.

Upvotes: 1

Related Questions