Search code examples
pythonpython-2.7setuptoolsegg

Restricting packages when trying to create an egg file doesnt work


I have a python project and I want to package into an egg two packages that sit under the root of the project.

I have a setup.py under the root that looks like this:

from setuptools import setup, find_packages

packages = find_packages(include=("datainfra.*", "serverinfra.*"))

setup(
    name="infra",
    version="0.1",
    packages=packages,
)

The problem: I run python setup.py bdist_egg, an egg file is indeed created but it takes all the packages under root rather than only the ones I specified.

Naturally, I made sure the return value of find_packages contains only the desired subset.

I am running python 2.7


Solution

  • Your setup script is correct - if you are getting unexpected build results, often it results from remains of previous builds still sitting in the project directory. Removing the <pkgname>.egg-info directory (if the resulting package has wrong metadata), the build directory (if the resulting package has wrong module set) or the .eggs directory (if wrong setup deps keep being used in build) and rebuilding is a quick and cheap fixing attempt.