简体   繁体   English

如何使用 pip install git +“git repo”重命名站点包?

[英]How to rename the site-package using pip install git +“git repo”?

How to give a specify site package name when doing following command:执行以下命令时如何给指定站点 package 名称:

pip install git+"git_repo"

I can see that "dremio_client" is successfully install under site package, but I want it call "dremio_client_test".我可以看到“dremio_client”已成功安装在站点 package 下,但我希望它称为“dremio_client_test”。

 -python
  -external libraries 
   -site package
    - dremio_client

What I have done:我做了什么:

I fork this project ( https://github.com/rymurr/dremio_client/blob/master/setup.py ) and want to know how to modify setup.py to achieve me goals.我分叉了这个项目( https://github.com/rymurr/dremio_client/blob/master/setup.py )并想知道如何修改 setup.py 以实现我的目标。

setup.py安装程序.py

keywords="dremio_client",
name="dremio_client",
packages=find_packages(
    include=[
        "dremio_client",
        "dremio_client.flight",
        "dremio_client.auth",
        "dremio_client.model",
        "dremio_client.util",
        "dremio_client.conf",
    ]
),

I try to give it another name: "dremio_client_test" and keywords: "dremio_client_test", but it dosen't work.我尝试给它另一个名称:“dremio_client_test”和关键字:“dremio_client_test”,但它不起作用。

I have to modify the folder name and setup.py(packages=find_packages) then it works.我必须修改文件夹名称和 setup.py(packages=find_packages) 然后它才能工作。 Wanna know is there any efficient way to do that?想知道有没有有效的方法来做到这一点?

Rename folder from dremio_client to dremio_client_test

-dremio_client
  -dremio_client_test

Rename the package name
packages=find_packages(
    include=[
        "dremio_client_test",
        "dremio_client_test.flight",
        "dremio_client_test.auth",
        "dremio_client_test.model",
        "dremio_client_test.util",
        "dremio_client_test.conf",
    ]

Thanks!谢谢!

I have to modify the folder name and setup.py(packages=find_packages) then it works.我必须修改文件夹名称和 setup.py(packages=find_packages) 然后它才能工作。 Wanna know is there any efficient way to do that?想知道有没有有效的方法来做到这一点?

This is the only way to do it.这是唯一的方法。 The name of the directory is always the name of the package.目录的名称始终是 package 的名称。

  1. You must rename dremio_client to dremio_client_test您必须将dremio_client重命名为dremio_client_test
  2. You must rename every reference to dremio_client inside the code to dremio_client_test您必须将代码中对dremio_client每个引用重命名为dremio_client_test
  3. You must change every reference in setup.py from dremio_client to dremio_client_test .您必须将setup.py中的每个引用从dremio_clientdremio_client_test

Yes, it is tedious.是的,这很乏味。 No, it's not something you are expected to do frequently.不,这不是您应该经常做的事情。 However an IDE like PyCharm can help automate renaming operations.然而,像 PyCharm 这样的 IDE 可以帮助自动化重命名操作。

Also make sure that you also change the name= in setup.py , otherwise it will clash with the actual dremio-client distribution.还要确保您还更改了setup.py中的name= ,否则它将与实际的dremio-client分发冲突。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM