Home > Software design >  `pip install` from Github private repo with `setup.py` not in `root` directory
`pip install` from Github private repo with `setup.py` not in `root` directory

Time:10-05

Our current setup is this:

  • repo_1
  • repo_2
  • components_repo

repo_1 and repo_2 both need to make use of the components from the component_repo and all 3 repo's are in Github.

The component_repo folder structure is like this:

.
├── README.md
└── src
    ├── setup.py
    ├── folder_1
    │   ├── functions.py
    ├── folder_2
    │   ├── functions.py

So I looked into "installing" this component_repo and found these docs:

  • enter image description here

    So as I understand, it will do a git clone, then build with setup.py and then remove the cloned repo. But it's failing at step 2 and not completing the final step (I think).

    Admittedly, I still don't quite understand what needs to be used for #egg= but I do know, if I exclude #egg=[whatever] from the command, then I get this error:

    ERROR: Could not detect requirement name for 'git https://$GITHUB_USER:[email protected]/$GITHUB_USER/components.git@main', please specify one with #egg=your_package_name

    I figured that with using the &subdirectory=src in the command, I am specifying the location of the setup.py file, but it turns out, that's not the case.

    So I thought I would move the setup.py file one directory up, to be in the root directory instead, and lo and behold, it works. I did need to update the paths inside the setup.py file for it to work (since I am one directory higher), but it worked.

    CodePudding user response:

    Depending on your shell, you might need to add double quotes around that URL, otherwise # and/or & might be interpreted by the shell:

    python -m pip install -e "git https://$GITHUB_USER:[email protected]/$GITHUB_USER/components.git@main#egg=common&subdirectory=src"
    
  • Related