Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: Package directory does not exist

I'm trying to install a python package in windows 10 using the following setup.py file.

"""Setup file for uhd module"""

from setuptools import setup

setup(name='uhd',
      version='3.14.0',
      description='Universal Software Radio Peripheral (USRP) Hardware Driver Python API',
      classifiers=[
          'Development Status :: 4 - Beta',
          'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
          'Programming Language :: C++',
          'Programming Language :: Python',
          'Topic :: System :: Hardware :: Hardware Drivers',
      ],
      keywords='SDR UHD USRP',
      author='Ettus Research',
      author_email='[email protected]',
      url='https://www.ettus.com/',
      license='GPLv3',
      package_dir={'': 'C:/Users/bcollins/UHD_PY/uhd/host/build/python'}, 
      package_data={'uhd': ['*.so']},
      zip_safe=False,
      packages=['uhd'],
      install_requires=['numpy'])

I execute the script using the command

python setup.py install

I do this from the directory that contains the setup.py file.

This returns the following error

error: package directory 'C:Users\bcollins\UHD_PY\uhd\host\build\python\uhd' does not exist

There is a folder called "uhd" at that location though. The folder contains the __init__.py file

If the script isn't looking for this folder, what is it looking for?

I'm not exactly experienced in this area but my best guess is that its looking for a .so file within the "uhd" folder at that location, but I'm not sure.

I am using python 2.7.

like image 901
b.collins Avatar asked Nov 29 '18 21:11

b.collins


People also ask

What is Package_dir in setup py?

package_dir = {'': 'lib'} in your setup script. The keys to this dictionary are package names, and an empty package name stands for the root package. The values are directory names relative to your distribution root.

How do I run Python setup py?

Installing Python Packages with Setup.py To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.

What is the use of setup py?

Use of Setup.py It primarily serves two purposes: It includes choices and metadata about the program, such as the package name, version, author, license, minimal dependencies, entry points, data files, and so on. Secondly, it serves as the command line interface via which packaging commands may be executed.


2 Answers

This doesn't answer the original question, but it's how I fixed the same error.

I had:

from setuptools import setup, find_packages

setup(
    ...
    packages=find_packages('src', exclude=['test']),
    ...
)

I had added the src argument because my packages are located in src, but it turns out find_packages is smart enough on it's own.

Remove the first argument:

from setuptools import setup, find_packages

setup(
    ...
    packages=find_packages(exclude=['test']),
    ...
)

This was on Python 3.5, but I imagine it applies to most other versions.

like image 71
kelloti Avatar answered Oct 12 '22 13:10

kelloti


package_dir has to be a relative path, not an absolute path. The distutils layer under setuptools tries to reject absolute paths, but the C: confuses it. It ends up converting your path to

C:Users\bcollins\UHD_PY\uhd\host\build\python\uhd

Note the missing backslash between C: and Users. This path is relative to your current working directory on the C drive (windows drive handling is weird), and relative to your working directory, this path is invalid.

like image 26
user2357112 supports Monica Avatar answered Oct 12 '22 15:10

user2357112 supports Monica