user1381
user1381

Reputation: 526

pip3 does not install my data files though my setup.py has include_package_data

Along with my Python scripts, I want my package to include a few configuration files (*.conf). So, in setup.py, I set the option include_package_data=True and created a file MANIFEST.in which lists the data files I want to include.

The creation of the source package is okay, and my tar.gz contains the configuration files:

drwxrwxr-x axelle/axelle     0 2020-02-28 15:01 droidlysis-3.0.13/
-rw-r--r-- axelle/axelle  3551 2020-01-14 14:19 droidlysis-3.0.13/droidconfig.py
-rw-rw-r-- axelle/axelle    38 2020-02-28 15:01 droidlysis-3.0.13/setup.cfg
-rw-rw-r-- axelle/axelle  1123 2020-02-28 15:01 droidlysis-3.0.13/setup.py
-rw-r--r-- axelle/axelle  4902 2020-01-13 10:10 droidlysis-3.0.13/droidziprar.py
drwxrwxr-x axelle/axelle     0 2020-02-28 15:01 droidlysis-3.0.13/conf/
-rw-r--r-- axelle/axelle  1872 2019-06-03 09:43 droidlysis-3.0.13/conf/manifest.conf
-rw-r--r-- axelle/axelle 10127 2020-01-20 09:38 droidlysis-3.0.13/conf/kit.conf
...

However, when I upload the package to test pypi and test the install (in a Python virtual environment), the configuration files are not present!

~/softs/myvirtualenvs/testdroidlysis $ pip3 install --no-cache-dir --extra-index-url https://test.pypi.org/simple/ droidlysis 
Collecting droidlysis
  Downloading https://test-files.pythonhosted.org/packages/4c/3a/c559b3552af14337b1b3687a2be984401f9e503441f8a72a383c05470b7d/droidlysis-3.0.13.tar.gz (40kB)
    100% |████████████████████████████████| 40kB 505kB/s 
Requirement already satisfied: SQLAlchemy in ./lib/python3.6/site-packages (from droidlysis)
Requirement already satisfied: configparser in ./lib/python3.6/site-packages (from droidlysis)
Requirement already satisfied: python-magic in ./lib/python3.6/site-packages (from droidlysis)
Requirement already satisfied: rarfile in ./lib/python3.6/site-packages (from droidlysis)
Installing collected packages: droidlysis
  Running setup.py install for droidlysis ... done
Successfully installed droidlysis-3.0.13

~/softs/myvirtualenvs/testdroidlysis $ find . -name "*.conf" -print
~/softs/myvirtualenvs/testdroidlysis $

FYI, my MANIFEST.in:

include conf/*.conf

Update: this is the setup.py

#!/usr/bin/env python3

from setuptools import setup

with open("README.md", "r") as fh:
    long_description = fh.read()

setup(
    name = 'droidlysis',
    description='DroidLysis: pre-analysis script for suspicious Android samples',
    long_description=long_description,
    long_description_content_type="text/markdown",
    author='me',
    author_email='[email protected]',
    url='https://github.com/me',
    license='MIT',
    keywords="android malware reverse",
    python_requires='>=3.0.*',
    version = '3.0.13',
    classifiers=[
        "Programming Language :: Python :: 3",
        "License :: OSI Approved :: MIT License",
        "Development Status :: 3 - Alpha",
        "Operating System :: Unix",
        "Topic :: Software Development :: Disassemblers",
    ],
    include_package_data=True,
    install_requires=[ 'configparser', 'python-magic', 'SQLAlchemy', 'rarfile' ],
    scripts = [ 'droidlysis3.py', 'droidconfig.py', 'droidcountry.py', 'droidproperties.py', 'droid
report.py', 'droidsample.py', 'droidsql.py', 'droidurl.py', 'droidutil.py', 'droidziprar.py' ],
)

Upvotes: 1

Views: 236

Answers (1)

phd
phd

Reputation: 94483

I see these problems with your distribution and setup.py:

  1. It lists neither Python modules nor packages to install, it only lists scripts. Data installed with MANIFEST.in could only be installed to a package (importable directory with __init__.py in it).

  2. include_package_data doesn't work with source distributions, it only works with wheels. MANIFEST.in is for sdists.

  3. You've forgotten to include setup.py in the git repository.

Upvotes: 1

Related Questions