Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build_meta does not include setup.py #1506

Closed
gaborbernat opened this issue Oct 8, 2018 · 2 comments · Fixed by #1554
Closed

build_meta does not include setup.py #1506

gaborbernat opened this issue Oct 8, 2018 · 2 comments · Fixed by #1554
Labels
bug critical help wanted Needs Implementation Issues that are ready to be implemented.

Comments

@gaborbernat
Copy link
Contributor

When someone invokes the build operation via the build_meta (via https://github.com/pypa/setuptools/blob/master/setuptools/build_meta.py#L170 - https://www.python.org/dev/peps/pep-0517/#build-sdist) the setup.py is no longer automatically packaged.

In case of python setup.py sdist what ensured that this will happen is https://github.com/python/cpython/blob/master/Lib/distutils/command/sdist.py#L250. Here distribution.script_name is set to setup.py when called via python setup.py sdist. This is not set though when calling it directly via build_meta so packaging setup.py is safely ignored.

Note the files to package is determined while running egg_info, and this is re-used across runs (by reading SOURCES.txt). Therefore this bug is hidden when:

  • anyone beforehand calls python setup.py sdist,
  • when there's a distutils extension that automatically pulls in setup.py (such as setuptools-scm),
  • when some config value pulls in (one in MANIFEST.in, setup.cfg, setup.py).
@gaborbernat gaborbernat changed the title build_meta does not include setup.py build_meta does not include setup.py Oct 8, 2018
@pganssle pganssle added Needs Triage Issues that need to be evaluated for severity and status. Needs Repro Issues that need a reproducible example. bug critical Needs Implementation Issues that are ready to be implemented. and removed Needs Triage Issues that need to be evaluated for severity and status. Needs Repro Issues that need a reproducible example. labels Oct 19, 2018
@pganssle
Copy link
Member

Here is a minimal script that confirms the bug.

Here is a script to create an MWE repo:

#!/usr/bin/bash

# Make the directory
mkdir mypkg
cd mypkg
mkdir mypkg
touch mypkg/__init__.py

# Make setup.py
cat << EOF > setup.py
from setuptools import setup

setup(name="mypkg", packages=["mypkg"], version="0.0.1")
EOF

After running it, cd into mypkg and run:

python -c 'from setuptools.build_meta import build_sdist; build_sdist(".")'

This will build the sdist, and you can confirm that setup.py is not included in the tarball:

$ tar -tf mypkg-0.0.1.tar.gz 
mypkg-0.0.1/
mypkg-0.0.1/PKG-INFO
mypkg-0.0.1/mypkg/
mypkg-0.0.1/mypkg/__init__.py
mypkg-0.0.1/mypkg.egg-info/
mypkg-0.0.1/mypkg.egg-info/PKG-INFO
mypkg-0.0.1/mypkg.egg-info/SOURCES.txt
mypkg-0.0.1/mypkg.egg-info/dependency_links.txt
mypkg-0.0.1/mypkg.egg-info/top_level.txt
mypkg-0.0.1/setup.cfg

A PR with a failing test that basically repeats those steps and asserts that setup.py is included in the resulting tarball would be accepted, as would a fix for said test.

@shashanksingh28
Copy link
Contributor

Working on this based on the PyPA sprint : https://github.com/orgs/pypa/projects/1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug critical help wanted Needs Implementation Issues that are ready to be implemented.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants