Skip to content

Updating MANIFEST.in does not correctly update the package sdist creates #436

Open

Description

Originally reported by: spookylukey (Bitbucket: spookylukey, GitHub: spookylukey)


The behaviour of sdist depends on previous contents of MANIFEST.in, not just the current. This is not fixed even by running setup.py clean or setup.py clean --all (although this should not be necessary).

This is very surprising behaviour, and potentially dangerous too - if someone accidentally adds a MANIFEST.in rule that includes a file that must not be distributed and notice the problem, they would expect that removing the rule will remove the file, but it does not.

I've attached a bash script that demonstrates the problem.


Activity

  1. ghost added on Mar 29, 2016
  2. miccoli commented on Feb 27, 2017

    @miccoli
    Contributor

    I have been hit by this same bug. My current remedy is to delete the *.egg-info directory before running setup.py sdist.

  3. miccoli commented on Feb 27, 2017

    @miccoli
    Contributor

    The problema appears to be in the logic with which the SOURCES.txt file is updated by python setup.py egg_info:

    $ python setup.py egg_info
    running egg_info
    writing sample.egg-info/PKG-INFO
    writing dependency_links to sample.egg-info/dependency_links.txt
    writing entry points to sample.egg-info/entry_points.txt
    writing requirements to sample.egg-info/requires.txt
    writing top-level names to sample.egg-info/top_level.txt
    reading manifest file 'sample.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'sample.egg-info/SOURCES.txt'
    

    Files already in SOURCES.txt are preserved across subsequent runs of python setup.py egg_info. Could please one of the developers clarify if this is intended behaviour and why?

  4. miccoli commented on Feb 28, 2017

    @miccoli
    Contributor

    See also

    def add_defaults(self):
    sdist.add_defaults(self)
    self.filelist.append(self.template)
    self.filelist.append(self.manifest)
    rcfiles = list(walk_revctrl())
    if rcfiles:
    self.filelist.extend(rcfiles)
    elif os.path.exists(self.manifest):
    self.read_manifest()
    ei_cmd = self.get_finalized_command('egg_info')
    self.filelist.graft(ei_cmd.egg_info)

    where the actual reading of SOURCES.txt takes place:

            rcfiles = list(walk_revctrl())
            if rcfiles:
                self.filelist.extend(rcfiles)
            elif os.path.exists(self.manifest):
                self.read_manifest()

    I cannot understand the reason for this logic.

  5. miccoli commented on Apr 12, 2017

    @miccoli
    Contributor

    @jaraco I think I nailed down this old (annoying bug), but nobody cares of these old bugs. Should I reopen or provide a pull request?

  6. jaraco commented on Apr 12, 2017

    @jaraco
    Member

    @miccoli: If this ticket describes the issue, it's still open. A PR would be most appreciated.

  7. miccoli commented on Apr 13, 2017

    @miccoli
    Contributor

    @jaraco yes: this ticket is accurate. Since there is no discussion active, I assume that I should provide my own PR.

  8. added a commit that references this issue on Apr 15, 2017
  9. PiDelport commented on Apr 18, 2017

    @PiDelport
    Contributor

    I think this change may have broken sdist installs with package data: #1016

  10. miccoli commented on Apr 18, 2017

    @miccoli
    Contributor

    The reason for

            rcfiles = list(walk_revctrl())
            if rcfiles:
                self.filelist.extend(rcfiles)
            elif os.path.exists(self.manifest):
                self.read_manifest()

    is now clear: in the develop tree (under SCM control) the files to be installed are determined from the SCM system (walk_revctrl()); in an sdist install the files are to be determined from the existing manifest file, which was previously generated in the develop tree + setuptools_scm

    This logic is broken for packages that do not use setuptools_scm, for which there is no guarantee that the current manifest file (in the development tree) is correct.

    Unfortunately my PR #1014 badly brokes this intended behaviour, so that pip install of sdist packages under SCM control and include_package_data=True is not more possible, see #1016 .

  11. added a commit that references this issue on Apr 18, 2017
  12. added a commit that references this issue on Apr 18, 2017
  13. reopened this on Apr 18, 2017
  14. 3 remaining items

  15. lucacerone commented on Apr 21, 2020

    @lucacerone

    Hi I am running into the same issue, but I haven't quite figured out
    how to get only the code in the package "src" folder be added to the final package.

    @miccoli @rsyring could you help me with a bit more explanations? I don't have a MANIFEST.in file and I am not quite sure what steps I should follow to have python setup.py sdist create the package only with the desired files.

    Thanks a lot for the help!

  16. miccoli commented on Apr 24, 2020

    @miccoli
    Contributor

    @lucacerone This issue is specific to a setup with MANIFEST.in: please first check the docs at https://packaging.python.org/guides/using-manifest-in/ and see if following those instruction you are able to obtain the desired source distribution.

    The only thing that you should be aware, regarding this specific bug, is that after each change to MANIFEST.in you should delete the <package>.egg-info directory to be sure that the SOURCES.txt is regenerated appropriately.

  17. lucacerone commented on Apr 24, 2020

    @lucacerone

    Thanks a lot @miccoli, I managed to get the "data" in my package by adding a Manifest.in.

    I don't quite understand what happens to "data" that resides outside of the "package" folder (I know it's not the preferred way, and in the end I moved the folder within the package), because if I add it to the Manifest.in, in the resulting archive I see those folders, but then they don't get copied to the site-packages folder (or any other folder I looked).

    I think the documentation could be a bit more clear on what's going on under the hood, but in the end I found a way that works for me :)

    Many thanks for your answer, I really appreciated it!

  18. tekumara commented on Aug 30, 2020

    @tekumara
    Contributor

    @miccoli I've also encountered this without a MANIFEST.in, see the repro case in #2347

  19. alena-bartosh commented on Aug 10, 2021

    @alena-bartosh

    For me this

    The only thing that you should be aware, regarding this specific bug, is that after each change to MANIFEST.in you should delete the .egg-info directory to be sure that the SOURCES.txt is regenerated appropriately.

    from @miccoli works fine 😉.

  20. MangelFdz commented on Jan 18, 2022

    @MangelFdz

    So annoying this bug... I tried to delete the .egg-info directory as @miccoli suggested but I can not update the files included in my python package by updating the MANIFEST.in. Even if I delete the whole MANIFEST.in file, when I rerun "$ python setup.py sdist" the SOURCE.txt include all the old files I included in the MANIFEST.in.

    Is not there any fix for this bug yet?

  21. abravalheri commented on Jan 18, 2022

    @abravalheri
    Contributor

    @MangelFdz do you have a reproduction? This does not seem to be quite the same problem described previously in this issue (for that problem things should work when you remove the .egg-info/build directories).

  22. microprediction commented on Feb 2, 2022

    @microprediction

    I have this issue. I have fallen back to just adding back in empty directories corresponding to those that were once in the MANIFEST.in

    Not a great solution, but moving on I guess.

  23. mxmlnkn commented on Jul 11, 2022

    @mxmlnkn

    I can confirm that deleting the .egg_info directory helps. I thought I was going insane. It kept adding files even though I removed those from the manifest...

  24. Skylark0924 commented on Jul 3, 2024

    @Skylark0924

    I have been hit by this same bug. My current remedy is to delete the *.egg-info directory before running setup.py sdist.

    Thx! That really solved the problem.

  25. jaraco commented on Jul 11, 2024

    @jaraco
    Member

    I can confirm the issue still exists, even when building using the PEP 517 builder:

    Details
     draft @ cat > MANIFEST.in
    include foo*.txt
    include bar*.txt
     draft @ cat > pyproject.toml
    [build-system]
    requires=['setuptools']
    build-backend='setuptools.build_meta'
     draft @ touch foo1.txt
     draft @ touch bar1.txt
     draft @ pyproject-build -s .
    * Creating isolated environment: venv+pip...
    * Installing packages in isolated environment:
      - setuptools
    * Getting build dependencies for sdist...
    running egg_info
    writing UNKNOWN.egg-info/PKG-INFO
    writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
    writing top-level names to UNKNOWN.egg-info/top_level.txt
    reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    * Building sdist...
    running sdist
    running egg_info
    writing UNKNOWN.egg-info/PKG-INFO
    writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
    writing top-level names to UNKNOWN.egg-info/top_level.txt
    reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md
    
    running check
    warning: check: missing required meta-data: name
    
    creating unknown-0.0.0
    creating unknown-0.0.0/UNKNOWN.egg-info
    copying files to unknown-0.0.0...
    copying MANIFEST.in -> unknown-0.0.0
    copying bar1.txt -> unknown-0.0.0
    copying foo1.txt -> unknown-0.0.0
    copying pyproject.toml -> unknown-0.0.0
    copying UNKNOWN.egg-info/PKG-INFO -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/SOURCES.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/dependency_links.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/top_level.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/SOURCES.txt -> unknown-0.0.0/UNKNOWN.egg-info
    Writing unknown-0.0.0/setup.cfg
    Creating tar archive
    removing 'unknown-0.0.0' (and everything under it)
    Successfully built unknown-0.0.0.tar.gz
     draft @ rm -r dist
     draft @ cat > MANIFEST.in
    include foo*.txt
     draft @ pyproject-build -s .
    * Creating isolated environment: venv+pip...
    * Installing packages in isolated environment:
      - setuptools
    * Getting build dependencies for sdist...
    running egg_info
    writing UNKNOWN.egg-info/PKG-INFO
    writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
    writing top-level names to UNKNOWN.egg-info/top_level.txt
    reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    * Building sdist...
    running sdist
    running egg_info
    writing UNKNOWN.egg-info/PKG-INFO
    writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
    writing top-level names to UNKNOWN.egg-info/top_level.txt
    reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md
    
    running check
    warning: check: missing required meta-data: name
    
    creating unknown-0.0.0
    creating unknown-0.0.0/UNKNOWN.egg-info
    copying files to unknown-0.0.0...
    copying MANIFEST.in -> unknown-0.0.0
    copying bar1.txt -> unknown-0.0.0
    copying foo1.txt -> unknown-0.0.0
    copying pyproject.toml -> unknown-0.0.0
    copying UNKNOWN.egg-info/PKG-INFO -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/SOURCES.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/dependency_links.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/top_level.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/SOURCES.txt -> unknown-0.0.0/UNKNOWN.egg-info
    Writing unknown-0.0.0/setup.cfg
    Creating tar archive
    removing 'unknown-0.0.0' (and everything under it)
    Successfully built unknown-0.0.0.tar.gz
     draft @ ls -la
    total 16
    drwxr-xr-x   8 jaraco  staff   256 Jul 11 01:03 .
    drwxr-x---+ 60 jaraco  staff  1920 Jul 10 22:21 ..
    -rw-r--r--   1 jaraco  staff    17 Jul 11 01:03 MANIFEST.in
    drwxr-xr-x   6 jaraco  staff   192 Jul 11 01:03 UNKNOWN.egg-info
    -rw-r--r--   1 jaraco  staff     0 Jul 11 01:02 bar1.txt
    drwxr-xr-x   3 jaraco  staff    96 Jul 11 01:03 dist
    -rw-r--r--   1 jaraco  staff     0 Jul 11 01:02 foo1.txt
    -rw-r--r--   1 jaraco  staff    77 Jul 11 01:02 pyproject.toml
     draft @ rm -r UNKNOWN.egg-info/
     draft @ pyproject-build -s .
    * Creating isolated environment: venv+pip...
    * Installing packages in isolated environment:
      - setuptools
    * Getting build dependencies for sdist...
    running egg_info
    creating UNKNOWN.egg-info
    writing UNKNOWN.egg-info/PKG-INFO
    writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
    writing top-level names to UNKNOWN.egg-info/top_level.txt
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    * Building sdist...
    running sdist
    running egg_info
    writing UNKNOWN.egg-info/PKG-INFO
    writing dependency_links to UNKNOWN.egg-info/dependency_links.txt
    writing top-level names to UNKNOWN.egg-info/top_level.txt
    reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    warning: sdist: standard file not found: should have one of README, README.rst, README.txt, README.md
    
    running check
    warning: check: missing required meta-data: name
    
    creating unknown-0.0.0
    creating unknown-0.0.0/UNKNOWN.egg-info
    copying files to unknown-0.0.0...
    copying MANIFEST.in -> unknown-0.0.0
    copying foo1.txt -> unknown-0.0.0
    copying pyproject.toml -> unknown-0.0.0
    copying UNKNOWN.egg-info/PKG-INFO -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/SOURCES.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/dependency_links.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/top_level.txt -> unknown-0.0.0/UNKNOWN.egg-info
    copying UNKNOWN.egg-info/SOURCES.txt -> unknown-0.0.0/UNKNOWN.egg-info
    Writing unknown-0.0.0/setup.cfg
    Creating tar archive
    removing 'unknown-0.0.0' (and everything under it)
    Successfully built unknown-0.0.0.tar.gz
    
    

    I don't know why I thought that build would always build from a copy of the sources and not the actual directory.

    I think what I'd like to see is for setuptools not to write an .egg-info at all when doing a build. I know it's unnecessary in general (not required by the specs or created by other backends). I wonder if there are any setuptools-specific behaviors that depend on that egg-info directory (in the working directory or the sdist).

  26. htgoebel commented on Jul 30, 2025

    @htgoebel

    I can confirm this bug still exists in setuptools 80.9.0.

    As you can see in the output below: When running the egg_info command a second time, the file egg_info/SOURCES.txt is read as a manifest file. Thus all files which have been included in the last run, will be included again – even if MANIFEST.in no lpnger lists them.

    Attached please find a shell-script demonstrating the issue test-st-bug-436.txt and below please find a (shortened, pseudo) output from this script. The script is based on the "details" from the last comment, but using plain setuptools.

    ====Preparation====
    + pip show setuptools
    Name: setuptools
    Version: 80.9.0
    …
    + rm -rf /tmp/st-bug-436
    + mkdir /tmp/st-bug-436
    + cd /tmp/st-bug-436
    + echo >> MANIFEST.in 'include aaa*.txt'
    + echo >> MANIFEST.in 'include bbb*.txt'
    + echo aaaaa > aaa1.txt
    + echo bbbbb > bbb1.txt
    
    + cat > pyproject.toml << EOF
    [build-system]
    requires=['setuptools']
    build-backend='setuptools.build_meta'
    EOF
    
    ==== build egg_info/SOURCES.txt ====
    + python -c 'from setuptools import * ; setup()' egg_info
    running egg_info
    …
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    + cat UNKNOWN.egg-info/SOURCES.txt
    …
    aaa1.txt
    bbb1.txt
    …
    
    ==== bbb1.txt is included, okay ===
    
    ======== Now demonstrating the bug =========
    === Write new MANIFEST.in not containing bbb*.txt ===
    + echo > MANIFEST.in 'include aaa*.txt'
    
    ==== build egg_info/SOURCES.txt ====
    + python3.10 -c 'from setuptools import * ; setup()' egg_info
    running egg_info
    …
    reading manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'UNKNOWN.egg-info/SOURCES.txt'
    + cat UNKNOWN.egg-info/SOURCES.txt
    …
    aaa1.txt
    bbb1.txt
    …
    
    ==== bbb1.txt is still included, BUG ====
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions