Excluding a top-level directory from a setuptools package

后端 未结 7 1948
闹比i
闹比i 2020-12-25 11:02

I\'m trying to put a Python project into a tarball using setuptools. The problem is that setuptools doesn\'t appear to like the way that the source tree was originally setu

7条回答
  •  礼貌的吻别
    2020-12-25 11:49

    I have the following in my setup.py...

    setup(name='pyfoo',
          version="1.0.2",
          description='Example for stack overflow',
          url='http://stackoverflow.com/',
          author='David Michael Pennington',
          author_email='mike /|at|\ pennington.net',
          license='GPL',
          platforms='any',
          keywords='Stack Overflow Example',
          entry_points = "",
          long_description=read('README.rst'),
          include_package_data=True,  # Checks MANIFEST.in for explicit rules
          #                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
          packages=find_packages(),
          use_2to3=True,
          zip_safe=False,
          setup_requires=["setuptools_hg"],
    

    I had a doc/ directory that was getting massive due to the number of images I had in it; this meant that the size of my sdist was growing over 500kB. Originally I had this in my MANIFEST.in...

    include LICENSE CHANGES README.rst requirements.txt
    recursive-exclude * __pycache__
    recursive-exclude * *.pyc
    recursive-exclude * *.pyo
    recursive-exclude * *.orig
    

    The only thing I had to do to exclude my doc directory was this line at the bottom of MANIFEST.in...

    prune doc*
    

    Using prune doc* suddenly removed all my doc/ directory from the sdist tarball. So, it looks like you just need to use this in a MANIFEST.in file...

    prune tests*
    

提交回复
热议问题