2

I am trying to create a python package that depends on another package hosted in a private repo. The setup.py looks like this:

setup(
    name="parasol",
    version="2.18.1",
    ...
    install_requires=[
        ...
        "pyGSO @ git+https://dev.azure.com/.../pyGSO@Main",
    ],
)

This works fine. Unfortunately, I now need to install it in an environment which has no access to the private repo. To work around that I am installing pyGSO manually in a separate build step, and then running this. But of course, as soon as it gets to the pyGSO requirement here it fails since it has no access to check the repo. What can I do?

Ideas I had, if anyone knows how to implement them:

  • Add a minimum version indicator to the requirement, so that if I manually install a newer version it won't try to access the unavailable repo
  • Somehow have it skip this dependency if it already is installed
  • Does [this answer](https://stackoverflow.com/questions/35668295/how-to-include-and-install-local-dependencies-in-setup-py-in-python) help you? You can change your dependency to the file you have available locally. – iuvbio Nov 16 '21 at 21:17
  • Unfortunately not. All other users will still need to have the repo link in the install_requires for them to install it normally, so I can't replace it with a local link. If I could, I would just omit pyGSO from the install_requires since I am already manually installing the dependency :) – Wyko ter Haar Nov 16 '21 at 21:28

1 Answers1

1

You can tell setup.py to not add the dependency with an environment variable:

import os


NO_PYGSO = os.getenv("PARASOL_NO_PYGSO")

dependencies = [...]

if NO_PYGSO is None:
    dependencies.append("pyGSO @ git+https://dev.azure.com/.../pyGSO@Main")

setup(
    name="parasol",
    version="2.18.1",
    ...
    install_requires=dependencies,
)

Then before installing in your environment without access to the repo, you do export PARASOL_NO_PYGSO=true (or equivalent for your shell, in case it's not bash).

iuvbio
  • 600
  • 6
  • 23
  • 1
    That's a great solution! I wish there was some way that I could tell pip directly to ignore this, but if that's not an option then this is a great workaround. – Wyko ter Haar Nov 22 '21 at 08:49
  • Nice, happy that this works for you. Please mark the answer as accepted, if it solved the problem. – iuvbio Nov 23 '21 at 11:06