0

i'm trying to create a simple python package, which includes two .pyd files. I'm new to package creation. The package structures is as follow :

\my_package
--- my_package.py
--- __init__.py
--- __version__.py
--- setup.py
--- \lib  
--- --- mylib1.pyd
--- --- mylib2.pyd

in my_package.py, the two libraries are imported using pylibimport as follow :

import os
import pylibimport

decode1 = pylibimport.import_module(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib', 'mylib1.pyd')
decode2 = pylibimport.import_module(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'lib', 'mylib2.pyd')

my setup.py is written as :

from setuptools import setup
from __version__ import __version__

setup(name = "my_package",
      version = __version__,
      description = 'package description',
      author = 'me'
      install_requires = ['numpy', 'pylibimport'],
      zip_safe = False)

Using the python setup.py sdist command, the package is compressed into .tar.gz archive and installed using pip. However, the .pyd files are not copied to the env 'site-package' folder, resulting in an AttributeError when trying to load the modules. Any help would be greatly appreciated !

I've tried to :

  • add package_data = {'my_package':['lib/*.pyd],} or package_data = {'':['lib/*.pyd],} to setup.py
  • add a MANIFEST.in file into my_package folder, writting : recursive-include lib/*.pyd and include_package_data = True in setup.py, as suggested here.
sinoroc
  • 18,409
  • 2
  • 39
  • 70
  • Having the `setup.py` script in the same directory as an `__init__.py` is a red flag. I recommend you check resources for the correct way of building a Python project directory structure, for example: https://packaging.python.org/en/latest/tutorials/packaging-projects/ or https://setuptools.pypa.io/en/latest/userguide/quickstart.html – sinoroc Apr 13 '23 at 08:30

0 Answers0