PyPI bdist_wininst upload failing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steven Bethard

    #1

    PyPI bdist_wininst upload failing

    I just tried to upload new versions of the argparse module to PyPI, but
    it seems like I can no longer upload Windows installers:

    $ setup.py sdist bdist_wininst upload
    ...
    running upload
    Submitting dist\argparse-0.8.0.zip to http://www.python.org/pypi
    Server response (200): OK
    Submitting dist\argparse-0.8.0.win32.exe to http://www.python.org/pypi
    Upload failed (400): Bad Request

    Anyone know what I'm doing wrong? (I've always been able to upload
    bdist_wininst packages to PyPI in the past.)

    STeVe
  • Steven Bethard

    #2
    Re: PyPI bdist_wininst upload failing

    Steven Bethard wrote:
    I just tried to upload new versions of the argparse module to PyPI, but
    it seems like I can no longer upload Windows installers:
    >
    $ setup.py sdist bdist_wininst upload
    ...
    running upload
    Submitting dist\argparse-0.8.0.zip to http://www.python.org/pypi
    Server response (200): OK
    Submitting dist\argparse-0.8.0.win32.exe to http://www.python.org/pypi
    Upload failed (400): Bad Request
    >
    Anyone know what I'm doing wrong? (I've always been able to upload
    bdist_wininst packages to PyPI in the past.)
    Still haven't figured this out yet, but I discovered that I get a
    slightly more informative message if I do the upload manually with the
    PyPI form. It then says:

    Error processing form

    invalid distribution file

    Looks like this originates from:



    down near the bottom in the file_upload() method. I can't figure out
    which "invalid distribution file" error is being triggered, but in
    looking around, I saw that is_distutils_fi le() in:



    says:

    if filename.endswi th('.exe'):
    # check for valid exe
    if filetype != 'bdist_wininst' :
    return False

    try:
    t = StringIO.String IO(content)
    t.filename = filename
    z = zipfile.ZipFile (t)
    l = z.namelist()
    except zipfile.error:
    return False

    for zipname in l:
    if not safe_zipnames.m atch(zipname):
    return False

    That seems a little weird to me. Are the bdist_wininst exe files really
    zip files? Or did I just misunderstand what "content" is?

    STeVe

    Comment

    • John Machin

      #3
      Re: PyPI bdist_wininst upload failing

      On May 27, 4:20 pm, Steven Bethard <steven.beth... @gmail.comwrote :
      Steven Bethard wrote:
      I just tried to upload new versions of the argparse module to PyPI, but
      it seems like I can no longer upload Windows installers:
      [snip]
      That seems a little weird to me. Are the bdist_wininst exe files really
      zip files? Or did I just misunderstand what "content" is?
      >
      STeVe
      They are exe files with a zip appended. Try out the above code on your
      file; it may just help you suss out what the problem is.
      E.g.:
      >>import zipfile
      >>zipfile.ZipFi le('xlrd-0.6.1a4.win32.e xe').namelist()
      ['PURELIB/xlrd-0.6.1a4-py2.5.egg-info', 'PURELIB/xlrd/biffh.py',
      .... snip ...
      'SCRIPTS/xlrdnameAPIdemo .py']
      >>>
      HTH,
      John

      Comment

      • Steven Bethard

        #4
        Re: PyPI bdist_wininst upload failing

        John Machin wrote:
        On May 27, 4:20 pm, Steven Bethard <steven.beth... @gmail.comwrote :
        >Steven Bethard wrote:
        >>I just tried to upload new versions of the argparse module to PyPI, but
        >>it seems like I can no longer upload Windows installers:
        [snip]
        >That seems a little weird to me. Are the bdist_wininst exe files really
        >zip files? Or did I just misunderstand what "content" is?
        >
        They are exe files with a zip appended. Try out the above code on your
        file; it may just help you suss out what the problem is.
        E.g.:
        >>>import zipfile
        >>>zipfile.ZipF ile('xlrd-0.6.1a4.win32.e xe').namelist()
        ['PURELIB/xlrd-0.6.1a4-py2.5.egg-info', 'PURELIB/xlrd/biffh.py',
        ... snip ...
        'SCRIPTS/xlrdnameAPIdemo .py']
        Interesting. Thanks!
        >>zipfile.ZipFi le('argparse-0.8.0.win32.exe ').namelist()
        ['.../lib/argparse-0.8.0-py2.5.egg-info', '.../lib/argparse.py']

        Interestingly, it looks like none of these are "safe_zipna mes" according to:



        I wonder why that is...

        Also, I couldn't get the StringIO code from there to work:
        >>import StringIO
        >>content = open('argparse-0.8.0.win32.exe ').read()
        >>t = StringIO.String IO(content)
        >>t.filename = 'argparse-0.8.0.win32.exe '
        >>z = zipfile.ZipFile (t)
        Traceback (most recent call last):
        File "<interacti ve input>", line 1, in <module>
        File "C:\Python25\li b\zipfile.py", line 346, in __init__
        self._GetConten ts()
        File "C:\Python25\li b\zipfile.py", line 366, in _GetContents
        self._RealGetCo ntents()
        File "C:\Python25\li b\zipfile.py", line 378, in _RealGetContent s
        raise BadZipfile, "File is not a zip file"
        BadZipfile: File is not a zip file

        STeVe

        Comment

        • Gabriel Genellina

          #5
          Re: PyPI bdist_wininst upload failing

          En Sun, 27 May 2007 12:19:03 -0300, Steven Bethard
          <steven.bethard @gmail.comescri bió:
          Also, I couldn't get the StringIO code from there to work:
          >
          >>import StringIO
          >>content = open('argparse-0.8.0.win32.exe ').read()
          Use open("...","rb" ).read() - the "b" is important on Windows.

          --
          Gabriel Genellina

          Comment

          • Steven Bethard

            #6
            Re: PyPI bdist_wininst upload failing

            Gabriel Genellina wrote:
            En Sun, 27 May 2007 12:19:03 -0300, Steven Bethard
            <steven.bethard @gmail.comescri bió:
            >
            >Also, I couldn't get the StringIO code from there to work:
            >>
            > >>import StringIO
            > >>content = open('argparse-0.8.0.win32.exe ').read()
            >
            Use open("...","rb" ).read() - the "b" is important on Windows.
            Ahh, great. Thanks.

            So any ideas why distutils is generating a bdist_wininst installer with
            file names like:

            lib/argparse-0.8.0-py2.5.egg-info
            lib/argparse.py

            instead of what John Machin had:

            PURELIB/xlrd-0.6.1a4-py2.5.egg-info
            PURELIB/xlrd/biffh.py

            The ones with 'lib' instead of 'PURELIB' will get rejected by the
            safe_zipnames regular expression in verify_filetype .py:

            re.compile(r'(p urelib|platlib| headers|scripts |data).+', re.I)

            Is there something I need to do when running 'setup.py bdist_wininst' to
            get 'PURELIB' instead of 'lib'?

            STeVe

            Comment

            • Steven Bethard

              #7
              Re: PyPI bdist_wininst upload failing

              Steven Bethard wrote:
              Gabriel Genellina wrote:
              >En Sun, 27 May 2007 12:19:03 -0300, Steven Bethard
              ><steven.bethar d@gmail.comescr ibió:
              >>
              >>Also, I couldn't get the StringIO code from there to work:
              >>>
              >> >>import StringIO
              >> >>content = open('argparse-0.8.0.win32.exe ').read()
              >>
              >Use open("...","rb" ).read() - the "b" is important on Windows.
              >
              Ahh, great. Thanks.
              >
              So any ideas why distutils is generating a bdist_wininst installer with
              file names like:
              >
              lib/argparse-0.8.0-py2.5.egg-info
              lib/argparse.py
              >
              instead of what John Machin had:
              >
              PURELIB/xlrd-0.6.1a4-py2.5.egg-info
              PURELIB/xlrd/biffh.py
              >
              The ones with 'lib' instead of 'PURELIB' will get rejected by the
              safe_zipnames regular expression in verify_filetype .py:
              >
              re.compile(r'(p urelib|platlib| headers|scripts |data).+', re.I)
              >
              Is there something I need to do when running 'setup.py bdist_wininst' to
              get 'PURELIB' instead of 'lib'?
              I figured it out. As suggested here:

              http://peak.telecommunity.com/DevCen...r-installation

              I had created a distutils.cfg to redirect my installs from the regular
              site-packages directory.

              Since the distutils.cfg settings are read in for all distutils uses at
              the command line, they were also being read in when I tried to run
              "setup.py bdist_wininst", and so all my filenames were getting the
              altered paths instead of the regular PURELIB ones.

              Thanks everyone for the help!

              STeVe

              Comment

              Working...