Setting up setup.py for packaging of a single .py file and a single data file without needing to create any folders

前端 未结 2 1696
时光说笑
时光说笑 2021-02-02 07:07

Project tree:

$.
├── happy_birthday-art.txt
├── happy_birthday.py
├── MANIFEST.in
├── README.rst
└── setup.py

setup.py

2条回答
  •  执念已碎
    2021-02-02 07:27

    http://docs.python.org/2/distutils/setupscript.html

    "You can specify the data_files options as a simple sequence of files without specifying a target directory, but this is not recommended, and the install command will print a warning in this case. To install data files directly in the target directory, an empty string should be given as the directory."

    However, here the target directory is NOT the site-packages folder, but the prefix folder, that is the root of the venv. If you'd want the .txt reside in the site-packages dir bare, then it would look not only ugly but seem that really not supported. On the other hand it is possible to install it to another location in the env, for example in "share/doc/foo":

    data_files=[('share/doc/foo', ['happy_birthday-art.txt'])],
    

提交回复
热议问题