aviit
aviit

Reputation: 2109

pip install missed setup.py

I create a very simple python project include empty foo.py and setup.py:

setup( # ...
    name='any_name',
    version='1.4',
    py_modules=['foo']
# ...
)

Then distribute it to my local pypi repo (Nexus): $ python setup.py sdist upload -r mypypi.
There is a setup.py in the zip file on the repo.
And install to my current folder: $ pip install --target=. any_name.
There are no setup.py in the installed folder.
I want setup.py must be in the installed folder. Is this correct?

Thanks!

Upvotes: 3

Views: 1401

Answers (1)

Guybrush
Guybrush

Reputation: 2790

edited: I completely revised my answer to make things easier (I hope).

setup.py is not required to be installed, it's only required to install the package. By default, when a distribution is created based on a setup.py, it already includes several files and/or directories (e.g. modules referenced in packages parameter of ´setup(...),setup.py,*.txt` files, and so on). A complete list of files that are automatically bundled in a distribution can be found here: https://docs.python.org/3.6/distutils/sourcedist.html#specifying-the-files-to-distribute

If you need to specify other files or directories that should be part of your distribution, you can either define the package_data and/or data_files parameters when calling setup(...). See ttps://docs.python.org/3.6/distutils/setupscript.html#distutils-installing-package-data for more information about the expected format of package_data and data_files.

You can also define a MANIFEST.in file to list all the files and directories that need to be part of your distribution. By default, all the files that are listed in package_data and data_files will be automatically appended to the ones listed in MANIFEST.in.

Notice that all the files defined in MANIFEST.in will be part of your distribution, but not necessarily included when your package is installed. For what I understood from Python packaging documentation: - Files listed in package_data and data_files will be automatically copied upon installation; - Files listed in MANIFEST.in will be copied only if include_package_data parameter to setup(...) is set to True.

However, please note that files listed in package_data are only included in your installation if you're not using sdist (i.e. only for binary distribution). As a consequence, it's safer to always rely on MANIFEST.in combined with include_package_data=True.

Upvotes: 1

Related Questions