更新时间:2022-03-06 06:16:37
在原位进行修改很危险.修改源代码,然后从修改后的版本然后安装.
pip是用于管理软件包安装的工具.您不应该修改在软件包安装过程中创建的文件.充其量,这意味着pip会相信未安装软件包的特定版本.这将与升级功能无法很好地交互.我怀疑pip会覆盖您的自定义设置,并将其永久丢弃,但我尚未确认.另一种可能性是,它检查文件是否已更改,如果更改,则抛出错误. (我认为这不太可能.)这也会误导系统的其他用户.他们看到您已经安装了一个软件包,但实际上并没有指示该版本.您有一个自定义的版本.如果他们尝试将未修改的版本安装到其他地方,或者期望安装的版本有某些特定行为,则可能会造成混乱.
pip is a tool for managing the installation of packages. You should not modify files creating during package installation. At best, doing so would mean pip will believe that a particular version of the package is installed when it isn't. This would not interact well with the upgrade function. I suspect pip would just overwrite your customizations, discarding them forever, but I haven't confirmed. The other possibility is that it checks if files have changed and throws an error if so. (I don't think that's likely.) It also misleads other users of the system. They see that you have a package installed, but you don't actually have that version indicated; you have a customized version. This is likely to result in confusion if they try to install the unmodified version somewhere else or if they expect some particular behavior from the version installed.
如果要修改源代码,正确的做法是修改源代码,然后构建新的自定义程序包或仅从源代码安装. py-mysql2pgsql 提供了执行源代码安装的说明:
If you want to modify the source code, the right thing to do is modify the source code and either build a new, custom package or just install from source. py-mysql2pgsql provides instructions for performing a source install:
> git clone git://github.com/philipsoutham/py-mysql2pgsql.git
> cd py-mysql2pgsql
> python setup.py install
您可以克隆源代码,对其进行修改,然后在不使用pip的情况下进行安装.如果需要在内部重新分发,则可以选择构建自己的定制版本的软件包.该项目使用setuptools来构建其软件包,因此您只需要熟悉setuptools即可使用它们的setup.py
文件.确保以这种方式安装它不会在pip的软件包列表中创建任何误导性条目.如果是这样,请找到一种方法来确保条目更加清晰,或者找到另一种安装方法.
You can clone the source, modify it, and then install without using pip. You could alternatively build your own customized version of the package if you need to redistribute it internally. This project uses setuptools for building its packages, so you only need to familiarize yourself with setuptools to make use of their setup.py
file. Make sure that installing it this way doesn't create any misleading entries in pip's package list. If it does, either find a way to make sure the entry is more clear or find an alternative install method.
由于您已发现该软件中的错误,因此我强烈建议您在Github上对其进行分叉,并在修复后提交拉取请求.如果这样做,只需将存储库URL更改为fork即可使用上述安装说明.如果您不进行分叉,请至少提出一个问题并描述解决该问题的更改.
Since you've discovered a bug in the software, I also highly recommend forking it on Github and submitting a pull request once you have it fixed. If you do so, you can use the above installation instructions just by changing the repository URL to your fork. If you don't fork it, at least file an issue and describe the changes that fix it.
替代品: