Codle commented on code in PR #12000:
URL: https://github.com/apache/tvm/pull/12000#discussion_r914094183


##########
python/setup.py:
##########
@@ -194,7 +194,15 @@ def is_pure(self):
     curr_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
     for i, path in enumerate(LIB_LIST):
         LIB_LIST[i] = os.path.relpath(path, curr_path)
-    setup_kwargs = {"include_package_data": True, "data_files": [("tvm", 
LIB_LIST)]}
+    LIB_DATA_FILES = []
+    if os.path.isfile(path):
+        LIB_DATA_FILES.append(os.path.relpath(path, curr_path))
+    if os.path.isdir(path):
+        for root, dirs, files in os.walk(path):
+            for filename in files:
+                file_path = os.path.join(root, filename)
+                LIB_DATA_FILES.append(os.path.relpath(file_path, curr_path))
+    setup_kwargs = {"include_package_data": True, "data_files": [("tvm", 
LIB_DATA_FILES)]}

Review Comment:
   Yes, you are right, the files are kept flat in the package. I try to find 
out the best practice of packing non-package file in setup.py and this PR gives 
my idea: https://github.com/pypa/sampleproject/issues/30
   
   While include_package_data=True, the setup program will run commands in 
MANIFEST.in, so it's less necessary to use data_files. This step is explained 
in 
[setuptools/docs/references/keywords.rst](https://github.com/pypa/setuptools/blob/main/docs/references/keywords.rst)
   
   > include_package_data: If set to True, this tells setuptools to 
automatically include any data files it finds inside your package directories 
that are specified by your MANIFEST.in file. For more information, see the 
section on [:ref:`Including Data 
Files`](https://github.com/pypa/setuptools/blob/0bd847c4aea839b3a75f4e3f09a36526453bd267/docs/references/keywords.rst#id23).
   
   In the first PR: https://github.com/apache/tvm/pull/380 for data_files 
field, I found the include_package_data was set to False in wheel packing. So 
the automatically copy action of include_package_data may be ignored by the 
commiter.
   
   Here is the result of unzipping .egg / .whl file, `configs` dir not be 
flatten to the json files.
   
   .whl 
   ```
   dist
   ├── tvm
   │   ├── __init__.py
   │   ├── _ffi
   │   ├── arith
   │   ├── auto_scheduler
   │   ├── autotvm
   │   ├── configs
   │   ├── contrib
   │   ├── driver
   │   ├── error.py
   │   ├── exec
   │   ├── generic.py
   │   ├── ir
   │   ├── libtvm.so
   │   ├── libtvm_runtime.so
   │   ├── meta_schedule
   │   ├── micro
   │   ├── parser
   │   ├── relay
   │   ├── rpc
   │   ├── runtime
   │   ├── script
   │   ├── support.py
   │   ├── target
   │   ├── te
   │   ├── testing
   │   ├── tir
   │   ├── topi
   │   └── utils
   ├── tvm-0.9.dev1753+g6236f2cb6-cp38-cp38-linux_x86_64.whl
   └── tvm-0.9.dev1753+g6236f2cb6.dist-info
       ├── METADATA
       ├── RECORD
       ├── WHEEL
       ├── entry_points.txt
       └── top_level.txt
   ```
   
   .egg
   
   ```
   dist
   ├── EGG-INFO
   │   ├── PKG-INFO
   │   ├── SOURCES.txt
   │   ├── dependency_links.txt
   │   ├── entry_points.txt
   │   ├── native_libs.txt
   │   ├── not-zip-safe
   │   ├── requires.txt
   │   └── top_level.txt
   ├── tvm
   │   ├── __init__.py
   │   ├── _ffi
   │   ├── arith
   │   ├── auto_scheduler
   │   ├── autotvm
   │   ├── configs
   │   ├── contrib
   │   ├── driver
   │   ├── error.py
   │   ├── exec
   │   ├── generic.py
   │   ├── ir
   │   ├── libtvm.so
   │   ├── libtvm_runtime.so
   │   ├── meta_schedule
   │   ├── micro
   │   ├── parser
   │   ├── relay
   │   ├── rpc
   │   ├── runtime
   │   ├── script
   │   ├── support.py
   │   ├── target
   │   ├── te
   │   ├── testing
   │   ├── tir
   │   ├── topi
   │   └── utils
   └── tvm-0.9.dev1754+g2a71c380e-py3.8-linux-x86_64.egg
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to