1. PyPA
  2. Python Packaging Authority Projects
  3. wheel
  4. Issues
Issue #99 new

Cannot exclude directory

ijl
created an issue

I'm unable to exclude a directory 'test', using either MANIFEST.in or setup.py.

In MANIFEST.in, I have: recursive-exclude test *

In setup.py: packages=find_packages(exclude=['test', ]),

In each case, sdist correctly excludes the test directory, and bdist_wheel does not. The test directory is included in the wheel, and installed to site-packages at the first level, which is very undesirable.

Can you advise?

Comments (18)

  1. Michael Hoglan

    i have noticed the same behavior using global-exclude, I was trying to exclude *.iml (intellij project file) from being packaged; sdist excludes it bdist_wheel does not

    global-exclude *.iml

  2. Michael Hoglan

    You can work around it with a two step execution, build the source tarball and then build the wheel from the result with pip wheel

    python setup.py sdist  
    pip wheel --no-index --no-deps --wheel-dir dist dist/*.tar.gz
    
  3. dbrgn

    Same issue here. My MANIFEST.in looks like this:

    include README.rst LICENSE.txt CONTRIBUTORS.md
    prune tests
    

    And in setup.py:

    packages=find_packages(exclude=['*.tests', '*.tests.*', 'tests.*', 'tests']),
    

    A fix would be great.

  4. Nate Coraor

    I've been trying to reproduce this but so far I've been unable, using wheel versions 0.22.0 up to 0.26.0. For anyone encountering this issue, could you provide:

    • Your wheel version
    • Your setuptools version
    • And bonus points for an example package that exhibits the problem
  5. R J

    Here's a reproduction:
    wheel==0.26.0
    setuptools==18.2
    https://pypi.python.org/pypi/jsonmodel/1.0

    Command:
    python setup.py bdist_wheel upload

    I tried to run "python setup.py sdist bdist_wheel upload" prior to this command, but my request to pypi was rejected because the zip and tar.gz distributions had already been uploaded. I don't know if this was a factor in the creating the problem... but it might account for your failure to replicate the problem (with a fresh release) if wheel is actually using its tar.gz/zip builds to determine what to ignore.

    Luckily, I didn't actually have any files in my credentials folder, otherwise I'd be really upset that bdist_wheel ignored the instructions of my MANIFEST.in file.

    Hopefully this helps.

  6. Nate Coraor

    R J: tests/ and models/ are being included because they are being found by setuptools' find_packages(). The use of include_package_data is not related. If you use exclude in find_packages it should work:

    setup(
        name="jsonmodel",
        version="1.0",
        author = __author__,
        packages=find_packages(exclude=['tests', 'models']),
        ...
    

    By my reading of the setuptools docs, it's ambiguous as to whether MANIFEST.in should override things added by find_packages(), and if you build any other type of bdist with setuptools (including the generic bdist tarball) I believe you'll find that the MANIFEST.in method of excluding found packages does not work (it only works for sdists). The differing behavior does suggest it's a bug, but I believe this comes from setuptools, not wheel.

  7. R J

    Great! Thanks for uncovering the issue.

    I'm still trying to get used to the relationship between the MANIFEST.in file and the arguments which appear to perform the same function in setup.py. I have already made changes to setup.py to exclude the relevant directories and hopefully it will work out perfectly as expected now when I push the next version.

    Regardless, I'll make sure to run "twine upload" AFTER I build the package, so that if I do make future mistakes they aren't public mistakes. Thanks again.

  8. Ethan Furman

    I have experienced the same problem:

    My MANIFEST.in first excludes all files, then includes the desired ones; the zip and gztar source distributions are correct, but the wheel bdist includes all the files.

    The enum34 package (version 1.1.3) exhibits the problem.

  9. R J

    I ran into another problem trying to exclude sub-packages inside a top level directory. In this case, bdist_wheel has been picking up all the __pycache__ files throughout my module and I needed to remove them from the wheel build, so I tried to add them to the setup.py arguments using the syntax declared in the find_packages() method of setuptools but bdist_wheel was unable to recognize (and exclude) the sub-directories correctly. See syntax below:

    setup(
        name="jsonmodel",
        version="1.0",
        author = __author__,
        packages=find_packages(exclude=['tests', '__pycache__', '*.__pycache__', '__pycache.*', '*.__pycache__.*']),
        ...
    

    The workaround mentioned above using the two step process did work for me once I pruned all of the instances of __pycache__ in the MANIFEST.in file. Unfortunately, wheel cannot seem to recognize the MANIFEST.in file syntax, nor in this case, the excluded packages beyond the top-level directories. Perhaps a fix can be made.

    I attempted this using Windows 8.

  10. Log in to comment