python - Edit package installed by pip -


i'm trying edit package installed via pip, called py_mysql2pgsql (i had error when converting db mysql postgre, this.

however, when got folder /user/local/lib/python2.7/dist-packages/py_mysql2pgsql-0.1.5.egg-info, cannot find source code package. find pkg-info , text files.

how can find actual source code package (or in particular, package)?

thanks

tl;dr:

modifying in place dangerous. modify source , then install modified version.

details

pip tool managing installation of packages. should not modify files creating during package installation. @ best, doing mean pip believe particular version of package installed when isn't. not interact upgrade function. suspect pip overwrite customizations, discarding them forever, haven't confirmed. other possibility checks if files have changed , throws error if so. (i don't think that's likely.) misleads other users of system. see have package installed, don't have version indicated; have customized version. result in confusion if try install unmodified version somewhere else or if expect particular behavior version installed.

if want modify source code, right thing modify source code , either build new, custom package or install source. py-mysql2pgsql provides instructions performing source install:

> git clone git://github.com/philipsoutham/py-mysql2pgsql.git > cd py-mysql2pgsql > python setup.py install 

you can clone source, modify it, , install without using pip. alternatively build own customized version of package if need redistribute internally. project uses setuptools building packages, need familiarize setuptools make use of setup.py file. make sure installing way doesn't create misleading entries in pip's package list. if does, either find way make sure entry more clear or find alternative install method.

since you've discovered bug in software, highly recommend forking on github , submitting pull request once have fixed. if so, can use above installation instructions changing repository url fork. if don't fork it, @ least file issue , describe changes fix it.

alternatives:

  • you copy source code project, modify there, , distribute modified version rest of code. (make sure don't violate license if so.)
  • you might able solve problem @ runtime. monkey-patching module little risky if other people on team might not expect change in behavior, done global modification of module's behavior. create additional code wraps buggy code: can take input, call buggy code, , either prevents or handles bug (e.g., modifying input make work or catching exception , handling it, etc.).