2

I'm unable to add dll files using package_data in setup.py file. Here's a look at directory structure:

my_project
├── key
│    ├── 1_0
│    │    ├── sub_dir
│    │    │      ├── _required.dll
│    │    │      └── __init__.py
│    │    ├── get_key.py
│    │    └── __init__.py
│    ├── 1_1
│    │    ├── sub_dir
│    │    │      ├── _required.dll
│    │    │      └── __init__.py
│    │    ├── get_key.py
│    │    └── __init__.py
│    ├── 1_2
│    │    ├── sub_dir
│    │    │      ├── _required.dll
│    │    │      └── __init__.py
│    │    ├── get_key.py
│    │    └── __init__.py
│    └── __init__.py
├── my_program.py
└── __init__.py

I've been trying without success to add the required.dll files with the installation of this module. I know I have to add it in the setup.py file. What I've tried so far (I'll skip all unnecessary parameters) :

First:

setuptools.setup(name='my_project',
                 packages=setuptools.find_packages(),
                 include_package_data=True,
                 package_data={'': ['my_project\\key\\1_0\\sub_dir\\_required.dll',
                                    'my_project\\key\\1_1\\sub_dir\\_required.dll',
                                    'my_project\\key\\1_2\\sub_dir\\_required.dll']},
                 ...)

Second:

setuptools.setup(name='my_project',
                 packages=setuptools.find_packages(),
                 include_package_data=True,
                 package_data={'key': ['1_0\\sub_dir\\_required.dll',
                                       '1_1\\sub_dir\\_required.dll',
                                       '1_2\\sub_dir\\_required.dll']},
                 ...)

Third:

setuptools.setup(name='my_project',
                 packages=setuptools.find_packages(),
                 include_package_data=True,
                 package_data={'my_project\\key\\1_0\\sub_dir': ['_required.dll'],
                               'my_project\\key\\1_1\\sub_dir': ['_required.dll'],
                               'my_project\\key\\1_2\\sub_dir': ['_required.dll']}
                 ...)
                 

Whenever I call python setup.py sdist --format=zip, dll files are never included. BTW, I'd rather not change directory structure, unless there is no other option.

What am I missing here?

Regards.

François

Francois
  • 586
  • 2
  • 6
  • 19
  • 1
    Have you tried the `data_files` parameter? Or perhaps the `MANIFEST.in` file should be used a mentioned [here](https://stackoverflow.com/a/64824372/6340496) and [here](https://setuptools.pypa.io/en/latest/userguide/datafiles.html). – S3DEV Nov 02 '21 at 19:38
  • @S3DEV Yes, I tried the `data_files` parameter. But `dll` files were not added with other `__init__.py`, which is not acceptable. I tried `MANIFEST.in` with `recursive-include key _required.dll` without success. – Francois Nov 02 '21 at 19:44
  • 1
    @S3DEV Finally, your suggestion (using a `MANIFEST.py` file) was the good one. To make it work, I had to add the lines `include my_project\key\1_0\sub_dir\_required.dll`, `include my_project\key\1_1\sub_dir\_required.dll` and `include my_project\key\1_2\sub_dir\_required.dll` . Thanks! – Francois Nov 04 '21 at 20:07
  • Excellent. Glad to hear you’ve found something which works for you. Adding data files is something I’ve always found tricky, no matter how many times I’ve done it. – S3DEV Nov 04 '21 at 21:33

0 Answers0