3

Problem:

I cannot get a source distribution namespace package to install in a 3.6.4 virtual environment in the directory structure expected (under Lib/site-packages).

Background:

I'm working with namespace packages in 2 different versions of python.

When I build the package in 2.7.14 using pkgutils style ns packaging, I can install and the directory structure is rolled out how I want it to.

When I build the package in 3.6.4, the package installs, but the directory structure is not created as expected.

Setup:

I have 2 virtual environments.

In the working one, I'm using the 2.7.14 compatible pkgutils namespace package functionality. I'm using virtualenv for this virtual environment to confirm installation, and it installs as I wish. The directory structure shows up in my venv/Lib/site-packages as expected, such that venv/Lib/site-packages/tools/sub_a exists.

In the non-working one, I'm using venv and implicit namespace packaging per PEP420

Here is my 3.6.4 package directory structure:

tools
  -sub_a
   -__init__.py
   -module.py
setup.py
README.rst

my subpackage init only has the following inside:

name = 'sub_a'

Here is my setup.py

from setuptools import setup
from codecs import open
from os import path

here = path.abspath(path.dirname(__file__))

with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
    long_description = f.read()

setup(

name='tools-sub-a',
version='1.0.0',
description='A sample Python project',
long_description=long_description,
url='none',
author='myuser',
author_email='myuser@host.com',
classifiers=[
    'Development Status :: 3 - Alpha',
    'Intended Audience :: Developers',
    'Topic :: Software Development :: Build Tools',
    'License :: Only For Internal Use',
    'Programming Language :: Python :: 3.6.4'
],

keywords='none',
packages=['tools.sub_a'],
install_requires=[],
extras_require={},
package_data={},
data_files=[],
entry_points={},
project_urls={},
)

The package builds using python setup.py sdist, I transfer the tar.gz file over to the virtual environment directory root, and run

pip install --no-index --find-links=. tools-sub-a

This installs fine, however when I navigate to the virtual environment Lib/site-packages directory, the tools/sub_a directory structure is not there.

I see a tools_sub_a-1.0.0.dist-info, but none of the expected namespace package directories.

Matt_G
  • 506
  • 4
  • 14
  • 1
    Just a non-constructive side-note: The last time I tried PEP-420 namespace packages in conjunction with setuptools, I gave up eventually. – code_onkel Mar 23 '18 at 20:54
  • 1
    @code_onkel ouch. Unfortunately not an option for me. If I may, in order to be constructive, consider upvoting for visibility if this is a question you'd be interested in seeing solved. – Matt_G Mar 23 '18 at 20:58
  • 1
    I was not able to reproduce the described problem (Ubuntu 16.04 / Python 3.6.4). Did you verify that the right interpreter version and virtual environment is in effect when building, installing and testing the packages? Are you on Windows or Linux? (Despite the slashes, the path of the site-packages folder indicates windows) Did you try to re-build the venv from scratch? – code_onkel Mar 26 '18 at 05:56
  • I tried it on my laptop and it's installing correctly. Thank you. I'm going to try fresh installs and recreate the virtual envrionment. But now I know it at least works – Matt_G Mar 26 '18 at 21:34

0 Answers0