Reputation: 19075
I am using setuptools (version 0.6c11) on Windows, and I specify console scripts to be installed via console_scripts
entry point. It works fine on Linux, but under Windows, using the MinGW compiler, there are no scripts installed. I don't see any realted message in the install output.
Other packages, like ipython, are doing just fine and have working .exe files after running setup.py install
.
Can someone suggest a way to debug that?
import setuptools
setup(
# ...
entry_points={
'console_scripts':[
'myprog = myMod:main'
]
}
)
UPDATE:
Based on the examples posed by Vinay (thanks!), I was able to isolate the problem: if a module is installed in nested subdirectory, script is not created:
import setuptools, os.path, shutil
SOURCE = '''
def main():
print('Hello, world!')
'''
### ERROR: when level of subdir is > 1, script is not created
subdir='subdir/subdir2'
### OK: with single-level subdirectory, everything works just fine
# subdir='subdir'
def prepare():
# remove previous source
if os.path.exists('subdir'): shutil.rmtree('subdir')
# create subdirs as necessary
os.makedirs(subdir)
with open(subdir+'/my_mod.py', 'w') as f: f.write(SOURCE)
prepare()
setuptools.setup(
name = 'myprog',
version = '0.1',
url = 'http://dummy.com/',
author = 'Me',
author_email = '[email protected]',
py_modules=['my_mod'],
package_dir={'':subdir},
entry_points={
'console_scripts':['myprog = my_mod:main']
},
zip_safe=False
)
Am I misunderstanding what is package_dir
for?
Upvotes: 2
Views: 3653
Reputation: 99385
Well, this works for me:
# This file is setup.py
import setuptools
SOURCE = '''
def main():
print('Hello, world!')
'''
def prepare():
with open('my_mod.py', 'w') as f:
f.write(SOURCE)
prepare()
setuptools.setup(
name = 'woo',
version = '0.1',
url = 'http://dummy.com/',
author = 'Me',
author_email = '[email protected]',
py_modules=['my_mod'],
entry_points={
'console_scripts':['myprog = my_mod:main']
}
)
when I run it in a virtualenv:
(venv) C:\temp\exemplar>python setup.py install
running install
running bdist_egg
running egg_info
writing woo.egg-info\PKG-INFO
writing top-level names to woo.egg-info\top_level.txt
writing dependency_links to woo.egg-info\dependency_links.txt
writing entry points to woo.egg-info\entry_points.txt
reading manifest file 'woo.egg-info\SOURCES.txt'
writing manifest file 'woo.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_py
creating build
creating build\lib
copying my_mod.py -> build\lib
creating build\bdist.win32
creating build\bdist.win32\egg
copying build\lib\my_mod.py -> build\bdist.win32\egg
byte-compiling build\bdist.win32\egg\my_mod.py to my_mod.pyc
creating build\bdist.win32\egg\EGG-INFO
copying woo.egg-info\PKG-INFO -> build\bdist.win32\egg\EGG-INFO
copying woo.egg-info\SOURCES.txt -> build\bdist.win32\egg\EGG-INFO
copying woo.egg-info\dependency_links.txt -> build\bdist.win32\egg\EGG-INFO
copying woo.egg-info\entry_points.txt -> build\bdist.win32\egg\EGG-INFO
copying woo.egg-info\top_level.txt -> build\bdist.win32\egg\EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating 'dist\woo-0.1-py2.7.egg' and adding 'build\bdist.win32\egg' to it
removing 'build\bdist.win32\egg' (and everything under it)
Processing woo-0.1-py2.7.egg
creating c:\temp\venv\lib\site-packages\woo-0.1-py2.7.egg
Extracting woo-0.1-py2.7.egg to c:\temp\venv\lib\site-packages
Adding woo 0.1 to easy-install.pth file
Installing myprog-script.py script to C:\temp\venv\Scripts
Installing myprog.exe script to C:\temp\venv\Scripts
Installed c:\temp\venv\lib\site-packages\woo-0.1-py2.7.egg
Processing dependencies for woo==0.1
Finished processing dependencies for woo==0.1
(venv) C:\temp\exemplar>pip uninstall woo
Uninstalling woo:
c:\temp\venv\lib\site-packages\woo-0.1-py2.7.egg
c:\temp\venv\scripts\myprog-script.py
c:\temp\venv\scripts\myprog.exe
Proceed (y/n)? y
Successfully uninstalled woo
(venv) C:\temp\exemplar>
Update:
Your problem is not using the correct path separator: using
subdir='subdir\\subdir2'
worked for me. Of course, you should probably use os.path.join()
.
Upvotes: 4