0

I want to create a Python package. To make this work, the user needs to install multiple python packages. I also need the user to install a package that is currently only supported for installing straight from the source (i.e. pip install -e .). How do I create my own source package, which depends on another source package in a clean way? In my opinion, it would be best if the user can just run python setup.py once; which installs my package and all the requirements in requirements.txt as well as the other package straight from the source.

I added a setup.py file with the following content:

setuptools.setup(
    dependency_links=["git+https://github.com/facebookresearch/pytorch-dp.git#egg=pytorch-dp"],
    packages=setuptools.find_packages(),
    python_requires=">=3.6",
)

When I run the setup file I get:

Moving pytorch_dp-0.1-py3.6.egg to /usr/local/lib/python3.6/dist-packages
Adding pytorch-dp 0.1 to easy-install.pth file

but then if I try to import the package torchdp:

import torchdp

I get the error: ModuleNotFoundError: No module named 'torchdp'

I'm using a Google Colab Notebook for GPU support.*

3
  • -e and "straight from source" are not the same in my understanding. For me, "straight from source" might just be something like pip install git+https://github.com/tangentlabs/django-oscar-paypal.git. Could you clarify where the other dependencies are located? do they come from a git repo, do you package them with your application ...? May 11, 2020 at 12:19
  • Thanks that worked smooth! I didn't know. I just had to use #egg=eggname at the end. May 11, 2020 at 13:32
  • @FlyingTeller Please check my new question. I updated it because it still didn't work. May 11, 2020 at 14:06

1 Answer 1

0

Turned out I had to restart google colab, and then it worked. Yikes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.