How does setuptools decide which files to keep for sdist/bdist?

2024/11/17 3:39:41

I'm working on a Python package that uses namespace_packages and find_packages() like so in setup.py:

from setuptools import setup, find_packages
setup(name="package",version="1.3.3.7",package=find_packages(),namespace_packages=['package'], ...)

It isn't in source control because it is a bundle of upstream components. There is no MANIFEST.

When I run python setup.py sdist I get a tarball of most of the files under the package/ directory but any directories that don't contain .py files are left out.

What are the default rules for what setup.py includes and excludes from built distributions? I've fixed my problem by adding a MANIFEST.in with

recursive-include package *

but I would like to understand what setuptools and distutils are doing by default.

Answer

You need to add a package_data directive. For example, if you want to include files with .txt or .rst extensions:

from setuptools import setup, find_packages
setup(name="package",version="1.3.3.7",package=find_packages(),include_package_data=True,namespace_packages=['package'], package_data = {# If any package contains *.txt or *.rst files, include them:'': ['*.txt', '*.rst']...)
https://en.xdnf.cn/q/71261.html

Related Q&A

How to implement multivariate linear stochastic gradient descent algorithm in tensorflow?

I started with simple implementation of single variable linear gradient descent but dont know to extend it to multivariate stochastic gradient descent algorithm ?Single variable linear regression impo…

How to do os.execv() in Python in Windows without detaching from the console?

Im using Python 2.6 on Windows 7. I have Windows .cmd file which invokes Python to run the CherryPy Web server (version 3.1.2). I start this .cmd file by executing it at the prompt in a Windows CMD she…

Django queryset permissions

I am building a quite complex Django application to be used on top of and email scanning service. The Django application is written using Python 3.5+This application primarily uses Django Rest Framewor…

How to extract certain parts of a web page in Python

Target web page: http://www.immi.gov.au/skilled/general-skilled-migration/estimated-allocation-times.htmThe section I want to extract:<tr><td>Skilled &ndash; Independent (Residence) sub…

Accessing axis or figure in python ggplot

python ggplot is great, but still new, and I find the need to fallback on traditional matplotlib techniques to modify my plots. But Im not sure how to either pass an axis instance to ggplot, or get one…

Importing the same modules in different files

Supposing I have written a set of classes to be used in a python file and use them in a script (or python code in a different file). Now both the files require a set of modules to be imported. Should t…

Manually calculate AUC

How can I obtain the AUC value having fpr and tpr? Fpr and tpr are just 2 floats obtained from these formulas:my_fpr = fp / (fp + tn) my_tpr = tp / (tp + fn) my_roc_auc = auc(my_fpr, my_tpr)I know thi…

Plotly: How to make stacked bar chart from single trace?

Is it possible to have two stacked bar charts side by side each of them coming from a single column?Heres my df:Field IssuePolice Budget cuts Research Budget cuts Police Time consum…

zip function help with tuples

I am hoping someone can help me with a problem Im stuck with. I have a large number of tuples (>500) that look like this:(2,1,3,6) (1,2,5,5) (3,0,1,6) (10,1,1,4) (0,3,3,0) A snippet of my c…

Mini batch training for inputs of variable sizes

I have a list of LongTensors, and another list of labels. Im new to PyTorch and RNNs so Im quite confused as to how to implement minibatch training for the data I have. There is much more to this data,…