Search code examples
pythonpackageinstallationsetup.pysdist

Create a python package & install it as source distribution and not a .egg?


I have a python package which has several data files in a data folder which have to be read when the package is used; these are not python scripts. However when I install my package to test it with python setup.py install --user only an ~/.local/lib/python2.7/site-package/mypackage-1.0.0-py2.7.egg is installed and so the code can't read the data directory.

I see other packages like numpy install with a *.dist-info and a numpy folder.

How do I make my package install like that?


Solution

  • python setup.py sdist
    pip install dist/*.tar.gz --user
    

    sdist creates a Source Archine as a tar.gz inside dist/. pip then installs it to the users site-packages directory.

    More info here.