Pipenv installed git package not importable

Viewed 315

I'm using pipenv (version 2018.11.26, Python 3.6.0) to install a package I've created and pushed on a private github repo.

The package contains a setup.py file with the following content:

import setuptools

setuptools.setup(
    name='testlib',
    version='0.0.1',
    desctiption='Hello py packaging',
    packages=setuptools.find_packages()
)

I install the package in a virtualenv with

pipenv install  git+https://<token>@github.<private-repo>/<subdir>/testlib.git#egg=testlib
> Successfully installed testlib-0.0.1

and check if it has been installed correctly

$ pip freeze | grep testlib
> testlib==0.0.1

But if I try to import the module, I get a ModuleNotFoundError

(.venv) pipenv_tests>python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 11:57:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import testlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'testlib'
>>>

Can anyone help me understand why? Thanks

1 Answers

My bad, the folder structure was wrong!

setup.py has to be outside the package folder:

repo_folder
|_ setup.py
|_ testlib
|__ classa.py
|__ classb.py

where setup.py (as mentioned in the question) is

import setuptools

setuptools.setup(
    name='testlib',
    version='0.0.1',
    desctiption='Hello py packaging',
    packages=setuptools.find_packages()
)

Now if I import the package, it works!!!

(.venv) pipenv_tests>python
Python 3.6.0 |Continuum Analytics, Inc.| (default, Dec 23 2016, 12:06:52) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import testlib
>>> _
Related