pkg_resources.safe_names should support underscores

Issue #380 invalid
binaryechoes
created an issue

I'm having a problem maintaining the latest package versions via puppet (which runs "pip freeze"). This stems from not allowing underscores in the safe_name function. "pip freeze" returns "package-name", when in fact it should return "package_name". "pip freeze" retrieves the packages from pkg_resources.working_set.

The search/replace is performed by safe_names, which can be found here https://bitbucket.org/tarek/distribute/src/3bf82d0cbc6e0a6d383f177c4def1222f3c3ba46/pkg_resources.py?at=default#cl-1145

One of the packages in question is riak_pb (https://pypi.python.org/pypi/riak_pb)

"Underscores can be used in the module name if it improves readability." http://www.python.org/dev/peps/pep-0008/#package-and-module-names

Comments (3)

  1. Jason R. Coombs

    I've tried reproducing this problem and I couldn't:

    vagrant@precise64:~$ foo/bin/pip install accessible_output
    Downloading/unpacking accessible-output
      Downloading accessible_output-0.7.5.zip
      Running setup.py egg_info for package accessible-output
    
        warning: no files found matching '*.dll' under directory 'lib'
        no previously-included directories found matching '.hg'
    Installing collected packages: accessible-output
      Running setup.py install for accessible-output
        deleting accessible_output.egg-info/requires.txt
    
        warning: no files found matching '*.dll' under directory 'lib'
        no previously-included directories found matching '.hg'
    Successfully installed accessible-output
    Cleaning up...
    vagrant@precise64:~$ foo/bin/pip freeze
    accessible-output==0.7.5
    argparse==1.2.1
    distribute==0.6.36
    wsgiref==0.1.2
    vagrant@precise64:~$ foo/bin/pip freeze > reqs.txt
    vagrant@precise64:~$ foo/bin/pip uninstall accessible-output
    Uninstalling accessible-output:
    ...
    Proceed (y/n)? y
      Successfully uninstalled accessible-output
    vagrant@precise64:~$ foo/bin/pip install -f reqs.txt
    You must give at least one requirement to install (maybe you meant "pip install reqs.txt"?)
    vagrant@precise64:~$ foo/bin/pip install -r reqs.txt
    Downloading/unpacking accessible-output==0.7.5 (from -r reqs.txt (line 1))
      Downloading accessible_output-0.7.5.zip
      Running setup.py egg_info for package accessible-output
    
        warning: no files found matching '*.dll' under directory 'lib'
        no previously-included directories found matching '.hg'
    Requirement already satisfied (use --upgrade to upgrade): argparse==1.2.1 in /usr/lib/python2.7 (from -r reqs.txt (line 2))
    Requirement already satisfied (use --upgrade to upgrade): distribute==0.6.36 in ./foo/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg (from -r reqs.txt (line 3))
    Requirement already satisfied (use --upgrade to upgrade): wsgiref==0.1.2 in /usr/lib/python2.7 (from -r reqs.txt (line 4))
    Installing collected packages: accessible-output
      Running setup.py install for accessible-output
        deleting accessible_output.egg-info/requires.txt
    
        warning: no files found matching '*.dll' under directory 'lib'
        no previously-included directories found matching '.hg'
    Successfully installed accessible-output
    Cleaning up...
    

    I did try with riak_pb, but I couldn't install it because I didn't have a protoc compiler installed. Perhaps your issue is related to the same aspect?

    In any case, the simple case does work and as Daniel points out, it would be very difficult to change this behavior at this point.

    Thanks for the report. If you can provide an example case that we can reproduce that demonstrates a clear need to eliminate safe_name, we can re-visit the issue.

  2. Log in to comment