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

bdist_wheel should start by cleaning up its build directory #147

Closed
agronholm opened this issue Aug 21, 2015 · 12 comments
Closed

bdist_wheel should start by cleaning up its build directory #147

agronholm opened this issue Aug 21, 2015 · 12 comments

Comments

@agronholm
Copy link
Contributor

Originally reported by: Xavier Fernandez (Bitbucket: xavfernandez, GitHub: xavfernandez)


bdist_wheel does not clean up its build directory making it easy to include obsolete/unwanted files.

On python 2.7, if you run python setup.py bdist_wheel once, add a file in build/lib.linux-x86_64-2.7 and rerun python setup.py bdist_wheel you'll have the file in your wheel.
I had this issue with https://github.com/Polyconseil/getconf but it concerns all packages, you can easily reproduce with the wheel package.

It can be quite unsettling, since it bypasses, all MANIFEST or find_packages rules...

It would seem cleaner and safer to simply start from a fresh directory and delete it afterwards.


@agronholm
Copy link
Contributor Author

Original comment by Daniel Greenfeld (Bitbucket: pydanny, GitHub: pydanny):


Had the same problem at BradWhittington/django-mailgun#28.

@agronholm
Copy link
Contributor Author

Original comment by Michael Merickel (Bitbucket: mmerickel, GitHub: mmerickel):


Same problem here Pylons/pyramid#2525

Used a stale build folder and had no idea that bdist_wheel would ignore setuptools-git. Honestly the best approach would be to just take the sdist and convert to a wheel, since the sdist does what I want.

@agronholm
Copy link
Contributor Author

Original comment by feluxe (Bitbucket: le0m, GitHub: le0m):


bdist_wheel does not clean up its build directory making it easy to include obsolete/unwanted files.

I have the same issue. It's very annoying, because you usually notice the obsolete modules/packages after publishing. So you have to bump version num again, re-build, re-publish, etc...

@agronholm
Copy link
Contributor Author

Original comment by JonathonReinhart (Bitbucket: JonathonReinhart, GitHub: JonathonReinhart):


Do you guys think this issue is the cause of my problem where bdist_wheel and sdist bdist_wheel are different? JonathonReinhart/staticx#22 (comment)

@agronholm
Copy link
Contributor Author

Original comment by JonathonReinhart (Bitbucket: JonathonReinhart, GitHub: JonathonReinhart):


I've opened this issue with setuptools (1064) for my problem (which may be related to this one).

@mcarans
Copy link

mcarans commented May 20, 2019

Any news on this issue? I just ran into it nearly 4 years after it was first reported :-(

Also are there any workarounds?

@agronholm
Copy link
Contributor Author

Workaround: remove the build directory before running bdist_wheel. Have you read the discussion? I've pointed out that the fault does not lie with bdist_wheel but distutils. Do you have any suggestions to give?

@mcarans
Copy link

mcarans commented May 20, 2019

Thanks, I have been investigating the best way to do it. I found this https://github.com/dave-shawley/setupext-janitor, but this seems like overkill. I don't know if this is a good way to do it, but in my setup.py, I have done this:

setup_requirements = ['pytest-runner']

def setup_requires():
    rmtree(script_dir_plus_file('build', setup_requires), ignore_errors=True)
    return setup_requirements

setup(
...
    setup_requires=setup_requires(),
...)

script_dir_plus_file is defined as follows:

def script_dir(pyobject, follow_symlinks=True):
    """Get current script's directory

    Args:
        pyobject (Any): Any Python object in the script
        follow_symlinks (bool): Follow symlinks or not. Defaults to True.

    Returns:
        str: Current script's directory
    """
    if getattr(sys, 'frozen', False):  # py2exe, PyInstaller, cx_Freeze
        path = abspath(sys.executable)
    else:
        path = inspect.getabsfile(pyobject)
    if follow_symlinks:
        path = realpath(path)
    return dirname(path)


def script_dir_plus_file(filename, pyobject, follow_symlinks=True):
    """Get current script's directory and then append a filename

    Args:
        filename (str): Filename to append to directory path
        pyobject (Any): Any Python object in the script
        follow_symlinks (bool): Follow symlinks or not. Defaults to True.

    Returns:
        str: Current script's directory and with filename appended
    """
    return join(script_dir(pyobject, follow_symlinks), filename)

pradyunsg added a commit to pradyunsg/pip that referenced this issue Jan 21, 2020
pradyunsg added a commit to pradyunsg/pip that referenced this issue Jan 21, 2020
chrisjbillington added a commit to chrisjbillington/setuptools-conda that referenced this issue May 19, 2020
If build dir is not cleaned, then building for multiple different
Pythons will include extensions compiled for one Python version in the
wheels for another version, which conda does not like one bit
(among other reasons not to do it):

pypa/wheel#147

Add `--no-deps` to pip command. It doesn't seem to be necessary, as I
don't see dependencies being installed at build time. However it is
recommended so I'm doing it just in case.
@pradyunsg
Copy link
Member

Is running self.run_command("clean") at the start of bdist_wheel, not a complete solution here?

@agronholm
Copy link
Contributor Author

The name of the issue suggests that bdist_wheel leaves temporary files behind which is not true. Again, this needs to be solved in setuptools (which now CAN solve the problem due to vendoring distutils).

@mhsmith
Copy link

mhsmith commented Jan 23, 2023

Related: pypa/setuptools#1871

@agronholm
Copy link
Contributor Author

Closing as not relevant to this project anymore as bdist_wheel is now canonically part of setuptools.

@agronholm agronholm closed this as not planned Won't fix, can't repro, duplicate, stale Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants