2

I have a library that requires a .ini file at some point (a default config file if none provided by the user).

Here is the hierarchy, with the required file marked:


├───src
│   ├───main
│   │   │   MANIFEST.in
│   │   │   setup.py
│   │   │
│   │   ├───matmuttools
│   │   │   │   matmut_logging.py
│   │   │   │   proxy.py
│   │   │   │   PROXY_USAGE.md
│   │   │   │   singleton.py
│   │   │   │   __init__.py
│   │   │   │
│   │   │   │
│   │   │   ├───ql
│   │   │   │   │   default_config.ini    <----
│   │   │   │   │   query_language.py
│   │   │   │   │   tsql.py
│   │   │   │   │   __init__.py

I have tried several things, based on this question and this doc

Using the following in the manifest does not "package" the ini file:

include matmuttools/ql/default_config.ini

Using setup.py, the following does not work either:

include_package_data=True,
package_data={'matmuttools': ['*.ini']}

I know that the file is not included because this file is read by configparser and it throws me an error when looking for a section contained in the file.

  File "/usr/local/lib/python3.9/site-packages/matmuttools/ql/query_language.py", line 41, in __init__
    raise ValueError(f"{self.language_name} not found in config file")
ValueError: TSQL not found in config file

Moreover, using ls to check out the package when installed does not show the file:

ls -lR /usr/local/lib/python3.9/site-packages/matmuttools/*

/usr/local/lib/python3.9/site-packages/matmuttools/ql:
total 16
-rw-r--r-- 1 root root  120 Sep 30 08:44 __init__.py
drwxr-xr-x 2 root root 4096 Sep 30 08:44 __pycache__
-rw-r--r-- 1 root root 2159 Sep 30 08:44 query_language.py
-rw-r--r-- 1 root root  478 Sep 30 08:44 tsql.py

The library is installed via:

pip install "git+http:myurl"


How can I ship correctly this configuration file with my library ?


Content of the wheel:

Building the wheel with:

python setup.py bdist_wheel

It contains:

$ zipinfo dist/matmuttools-3.2.0-py3-none-any.whl 
Archive:  dist/matmuttools-3.2.0-py3-none-any.whl
Zip file size: 12646 bytes, number of entries: 14
-rw-rw-rw-  2.0 fat      153 b- defN 22-Sep-29 10:12 matmuttools/__init__.py
-rw-rw-rw-  2.0 fat     9841 b- defN 22-Jun-13 06:37 matmuttools/matmut_logging.py
-rw-rw-rw-  2.0 fat     2047 b- defN 22-Jun-13 06:37 matmuttools/proxy.py
-rw-rw-rw-  2.0 fat      928 b- defN 22-Jun-13 06:37 matmuttools/singleton.py
-rw-rw-rw-  2.0 fat      257 b- defN 22-Jun-13 06:37 matmuttools/hadoop/__init__.py
-rw-rw-rw-  2.0 fat     9891 b- defN 22-Jun-13 06:37 matmuttools/hadoop/hdfs_wrapper.py
-rw-rw-rw-  2.0 fat    10465 b- defN 22-Jun-13 06:37 matmuttools/hadoop/impala_wrapper.py
-rw-rw-rw-  2.0 fat      120 b- defN 22-Sep-29 09:22 matmuttools/ql/__init__.py
-rw-rw-rw-  2.0 fat     2159 b- defN 22-Sep-29 12:19 matmuttools/ql/query_language.py
-rw-rw-rw-  2.0 fat      478 b- defN 22-Sep-29 11:56 matmuttools/ql/tsql.py
-rw-rw-rw-  2.0 fat      454 b- defN 22-Sep-30 09:08 matmuttools-3.2.0.dist-info/METADATA
-rw-rw-rw-  2.0 fat       97 b- defN 22-Sep-30 09:08 matmuttools-3.2.0.dist-info/WHEEL
-rw-rw-rw-  2.0 fat       12 b- defN 22-Sep-30 09:08 matmuttools-3.2.0.dist-info/top_level.txt
?rw-rw-r--  2.0 fat     1155 b- defN 22-Sep-30 09:08 matmuttools-3.2.0.dist-info/RECORD
14 files, 38057 bytes uncompressed, 10720 bytes compressed:  71.8%

It seems the MANIFEST.in is not even used. Adding prune matmuttools/ql to it does nothing. The content of the wheel is the same as above.

8
  • I can't think of a reason why that MANIFEST.in configuration wouldn't work. What happens if you just build the wheel locally (e.g. install the build package and python -m build .) and look at what's inside (wheels are zips, so zipinfo something.whl)? Commented Sep 30, 2022 at 8:57
  • @AKX done. Question updated with result. Commented Sep 30, 2022 at 9:09
  • Okay, can you also add the full setup.py? Have you tried updating your version of setuptools? Commented Sep 30, 2022 at 9:31
  • The file doesn't belong to matmuttools package but to matmuttools.ql subpackage so try this: package_data={'matmuttools.ql': ['*.ini']} Commented Sep 30, 2022 at 10:58
  • 1
    Here you go: github.com/Andromelus/ilikeapples Commented Sep 30, 2022 at 11:33

1 Answer 1

4

The file default_config.ini doesn't belong to matmuttools package but to matmuttools.ql subpackage so fix it this way:

package_data={'matmuttools.ql': ['*.ini']}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.