{"id":314,"date":"2023-06-21T16:06:43","date_gmt":"2023-06-21T21:06:43","guid":{"rendered":"http:\/\/myblog.vindaloo.com\/?p=314"},"modified":"2023-06-23T10:55:03","modified_gmt":"2023-06-23T15:55:03","slug":"pip-git-for-development","status":"publish","type":"post","link":"http:\/\/myblog.vindaloo.com\/?p=314","title":{"rendered":"Pip + git for development"},"content":{"rendered":"\n<p>I&#8217;m working on what should be a simple raspberry pi display project and I came up with the need for a set of ad-hoc python modules that were installable from my gitlab server. It was a bit of a journey. Here are the broad steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Create a gitlabs project for your python module. Since will probably have a few of these, it might be good to make a group for them right now.<\/li><li>I think that you can use <code>git+ssh:\/\/git@gitlabs.example.com...<\/code> for this but I chose to use a gitlabs impersonation token for this since ssh isn&#8217;t installed everywhere and sometimes the installation needs a bunch of hints in <code>~\/.ssh\/config<\/code>.<\/li><li>A standard install will be done with pip as follows pip install <code>git+https:\/\/{user}:{password}@git.example.com\/example-group\/example-project.git<\/code>. If you created a gitlabs impersonation token about, you can substitute it for password here.<\/li><\/ul>\n\n\n\n<p>Sometimes I need to edit the installed package that I&#8217;m working on. The way to do this is to  use the <em>&#8211;editable<\/em> flag to pip. To do that you need to specify some extra information to git when checking out the project. I found that this command line: <\/p>\n\n\n\n<p><code>pip install --editable git+https:\/\/{user}:{token}@gitlabs.example.com\/example-group\/example-project.git#egg={module_name}<\/code> <\/p>\n\n\n\n<p>I think that the #egg={module_name} piece provides pip with name of the module as installed. I found the <a rel=\"noreferrer noopener\" href=\"https:\/\/pip.pypa.io\/en\/stable\/topics\/vcs-support\/\" target=\"_blank\">documentation that explains this here: &#8220;https:\/\/pip.pypa.io\/en\/stable\/topics\/vcs-support\/&#8221;.<\/a> Assuming that you are doing this in a venv, and it doesn&#8217;t make sense not to, you&#8217;ll get a new directory called <code>venv\/src\/{module_name}<\/code> which has a git checkout of your module so you can edit it to your needs for this particular project.<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on what should be a simple raspberry pi display project and I came up with the need for a set of ad-hoc python modules that were installable from my gitlab server. It was a bit of a journey. Here are the broad steps: Create a gitlabs project for your python module. Since will &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/myblog.vindaloo.com\/?p=314\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Pip + git for development&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[28,25],"tags":[],"class_list":["post-314","post","type-post","status-publish","format-standard","hentry","category-development","category-python"],"_links":{"self":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts\/314","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=314"}],"version-history":[{"count":5,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions"}],"predecessor-version":[{"id":323,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=\/wp\/v2\/posts\/314\/revisions\/323"}],"wp:attachment":[{"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=314"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=314"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/myblog.vindaloo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=314"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}