Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Python Package From Private Bitbucket Repo

Tags:

I created a Python 3.5 package for work, which is in a private Bitbucket repo and I can easily pull the code and do a "python .\setup.py install" to have it install, but I want to try to eliminate the step of having to pull the code and have multiple copies on my machine and at the same time make it easier for my coworkers to install/update the package. Is it possible to use git bash or cmd (we are all on Windows) to install the package and ask for credentials in the process?

like image 814
Hososugi Avatar asked Jul 12 '16 17:07

Hososugi


People also ask

How do I automatically install packages in Python?

You can use pipreqs to automatically generate a requirements. txt file based on the import statements that the Python script(s) contain. To use pipreqs , assuming that you are in the directory where example.py is located: pip install pipreqs pipreqs .


2 Answers

You can use the https option listed in pip_install. https://pip.pypa.io/en/stable/reference/pip_install/#git

Sample Code:

pip install git+https://USER_NAME@GIT_URL/PATH_TO_YOUR_REPO.git 

You can use the url Bitbucket gives you when you request the clone url. Just remember to add the git+ to it.

like image 132
Zack Lawson Avatar answered Nov 09 '22 23:11

Zack Lawson


Bitbucket is now moving to App Passwords and is deprecating the use of passwords in the clone command.

To install from a private repo with pip use

pip install git+https://USER_NAME:APP_PASSWORD@GIT_URL/PATH_TO_YOUR_REPO.git 

You can create an app_password from following these instructions https://support.atlassian.com/bitbucket-cloud/docs/app-passwords/

like image 43
user3084455 Avatar answered Nov 09 '22 23:11

user3084455