Bas
Bas

Reputation: 13

Windows python setup.py install does not distribute module python files

Ive searched the web for hours but I am not able to find out what im doing wrong. I install my own package through python setup.py install. This works, although im not able to import mymodule anywhere on the system.

This is how the directory looks like:

C:\PyDev\simple_test\mymodule
C:\PyDev\simple_test\setup.py
C:\PyDev\simple_test\mymodule\__init__.py

With: __init__.py

def sayhello():
    print("Hello")

setup.py

from setuptools import setup
setup(
    name='mymodule'
)

commandline: python setup.py install

It does that without raising any error. But when I look at the installed .egg file in the site-packages, it only contains an EGG-INFO directory, and no source files whatsoever...

This is the output of the install command:

(venv) C:\PyDev\simple_test>python setup.py install
running install
running bdist_egg
running egg_info
creating mymodule.egg-info
writing mymodule.egg-info\PKG-INFO
writing dependency_links to mymodule.egg-info\dependency_links.txt
writing top-level names to mymodule.egg-info\top_level.txt
writing manifest file 'mymodule.egg-info\SOURCES.txt'
reading manifest file 'mymodule.egg-info\SOURCES.txt'
writing manifest file 'mymodule.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
warning: install_lib: 'build\lib' does not exist -- no Python modules to install

creating build
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\EGG-INFO
copying mymodule.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying mymodule.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying mymodule.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying mymodule.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist\mymodule-0.0.0-py3.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing mymodule-0.0.0-py3.7.egg
Copying mymodule-0.0.0-py3.7.egg to c:\pydev\simple_test\venv\lib\site-packages
Adding mymodule 0.0.0 to easy-install.pth file

Installed c:\pydev\simple_test\venv\lib\site-packages\mymodule-0.0.0-py3.7.egg
Processing dependencies for mymodule==0.0.0
Finished processing dependencies for mymodule==0.0.0

If I run python setup.py develop it does seem to work. Then I can access the package throughout my whole system.

Upvotes: 1

Views: 2076

Answers (1)

Matthijs Brouns
Matthijs Brouns

Reputation: 2329

I'm not exactly sure what the cause is but two things stand out:

  • You don't have packages specified in your setup.py
  • The name of your module directory is different from the name of your main directory

I could imagine that the combination of these two factors result in setuptools not being able to find your source.

You could try renaming your src directory or changing your setup.py to

from setuptools import setup, find_packages

setup(name='mymodule',
      packages=find_packages()
)

Upvotes: 1

Related Questions