Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pip install ignores files in MANIFEST.in - how to structure the project correctly?

I read a lot about this problem but could not find any solution, so I'll ask yet another question about it, since I'm not even sure if I use the correct folder structure for my Python package.

So basically I'm developing an application which uses the Tornado web-server framework and I want to package it, so the users can install it via pip and get access to a basic script to start the web server.

The directory structure is the following:

├── MANIFEST.in
├── README.md
├── config
│   └── default.cfg
├── docs
│   ├── Makefile
│   ├── _build
│   ├── _static
│   ├── _templates
│   ├── conf.py
│   ├── index.rst
├── foopackage
│   ├── __init__.py
│   ├── barmodule.py
│   └── bazmodule.py
├── setup.py
├── static
│   ├── css
│   │   ├── menu.css
│   │   └── main.css
│   ├── img
│   │   └── logo.png
│   ├── js
│   │   ├── ui.js
│   │   └── navigation.js
│   └── lib
│       ├── d3.v3.min.js
│       └── jquery-1.11.0.min.js
└── templates
    ├── index.html
    └── whatever.html

The Python code is as you can see in the package foopackage.

The MANIFEST.in file recursively includes the directories config, static, templates, and docs.

This is my setup.py (only the relevant parts:

from setuptools import setup

setup(name='foo',
      version='0.1.0',
      packages=['foopackage'],
      include_package_data=True,
      install_requires=[
          'tornado>=3.2.2',
      ],
      entry_points={
          'console_scripts': [
              'foo=foopackage.barmodule:main',
          ],
      },
)

If I run python setup.py sdist, everything gets packaged nicely, the docs, templates and config files etc. are included. However, if I run pip install ..., only the foopackage gets installed and everything else is ignored.

How do I include those additional files to the install procedure? Is my directory structure OK? I also read about "faking a package", so putting everything in a directory and touch a __init__.py file, but that seems pretty odd to me :-\

like image 231
tamasgal Avatar asked Jul 22 '14 10:07

tamasgal


People also ask

How does pip decide where to install?

Once pip has a list of compatible distributions, it sorts them by version, chooses the most recent version, and then chooses the "best" distribution for that version. It prefers binary wheels if there are any, and if they are multiple it chooses the one most specific to the install environment.

Why can't I install using pip?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.

What are the different steps and processes involved in installation of pip elaborate?

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process. Voila!


1 Answers

I solved the problem by moving the static directory to the actual Python module directory (foopackage). It seems that top level "non-package" folders are ignored otherwise.

like image 195
tamasgal Avatar answered Sep 25 '22 16:09

tamasgal