Remove setuptools dependency on Windows #539

Closed
minrk opened this Issue Jun 25, 2011 · 5 comments

Projects

None yet

2 participants

@minrk
Member
minrk commented Jun 25, 2011

setuptools was added as an install and runtime dependency in 0.11 on Windows by PR #536, but when someone has time this dependency should be removed, and plain distutils installation should be fixed, including '.bat' files, etc.

See #351 and #369 for more information.

@waltherg

Going through your setup.py for some inspiration I bumped into a mention of this issue.

If you look at how Continuum Anaconda handles Python scripts (.bat files as you mention in Anaconda/Scripts), this suggests a fix for this problem.

Something along these lines does it for me:

def windows_prepare(scripts):
    bat = ['@echo off\n',
          'set PYFILE=%~f0\n',
          'set PYFILE=%PYFILE:~0,-4%-script.py\n'
          '"python.exe" "%PYFILE%" %*\n']

    windows_scripts = []
    windows_bat_files = []

    for script in scripts:
        windows_scripts.append(script+'-script.py')
        with open(script+'.bat', "w") as f:
            for string in bat:
                f.write(string)
            windows_bat_files.append(f.name)

    for script, script_w in zip(scripts, windows_scripts):
        shutil.copy(script, script_w)

    return windows_scripts+windows_bat_files

if os_name == 'windows':
    scripts = windows_prepare(scripts)

Plus some cleanup of the -script.py and .bat files this created.

@minrk
Member
minrk commented Nov 22, 2013

Thanks, there's hope for dropping the setuptools entry points, yet! Is python.exe right? shouldn't it be sys.executable, since PATH is not trustworty?

@waltherg

Good call and you're most likely correct. In Anaconda/Scripts you'll find that they call the nearest python.exe in a parent directory. This might be safest to do?

@minrk
Member
minrk commented Nov 22, 2013

that ought to be the right thing to do for an installed script, certainly.

@minrk minrk modified the milestone: 3.0, wishlist Nov 11, 2014
@minrk
Member
minrk commented Nov 11, 2014

Fixed by #6899

@minrk minrk closed this Nov 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment