Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set up properly package_data in setup.py?

I am facing an error like No such file or directory.... Could anyone help me with this out? I'd really appreciate it! This is the directory: enter image description here

And this is the setup.py code:

from setuptools import setup

setup(
    name='raw-microsoft-wwi',
    version='1.0.0',
    package_dir={"":"src"},
    packages=[
        "raw_microsoft_wwi",
        "raw_microsoft_wwi.configuration",
        "raw_microsoft_wwi.reader",
        "raw_microsoft_wwi.writer",
        "raw_microsoft_wwi.transformer"
    ],
    package_data = {"src/raw_microsoft_wwi/queries": ["*.sql"]},
    include_package_data = True,
    install_requires=[
        "delta-spark==1.2.0",
        "pyspark==3.2.1",
        "python-environ==0.4.54"
    ],
    zip_safe=False
)

1 Answers

Setuptools expects package_data to be a dictionary mapping from Python package names to a list of file name patterns.

This means that the keys in the dictionary should be similar to the values you listed in the packages configuration (instead of paths).

I think you can try the following:

  1. Add the missing raw_microsoft_wwi.queries, raw_microsoft_wwi.queries.incremental_table_queries, raw_microsoft_wwi.queries.regular_tables_queries (etc) to the packages list (effectivelly all these folders are considered packages by Python, even if they don't have a __init__.py file).
  2. Replace package_data, with something similar to:
package_data = {"raw_microsoft_wwi.queries": ["**/*.sql"]}

More information is available in https://setuptools.pypa.io/en/latest/userguide/datafiles.html.

like image 61
Anderson Bravalheri Avatar answered Oct 19 '25 08:10

Anderson Bravalheri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!