This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: setup.py bdist_egg --without-source-files does not allow console_script to run as expected
Type: behavior Stage: resolved
Components: Build Versions: Python 3.6, Python 3.5
process
Status: closed Resolution: third party
Dependencies: Superseder:
Assigned To: Nosy List: berker.peksag, dmiyakawa
Priority: normal Keywords:

Created on 2016-11-07 08:21 by dmiyakawa, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg280190 - (view) Author: Daisuke Miyakawa (dmiyakawa) * Date: 2016-11-07 08:21
I'm trying to prepare an egg file "without source code".
I works mostly, while console_script does not.

Here's a sample project for it, in which the function "greeting.greeting.greeting()" prints "Greeting!".

https://github.com/dmiyakawa/python_greeting

First, I tried creating an egg with source code, which worked perfectly as a standalone script (console_script).

--
$ python --version
Python 3.5.2
$ python setup.py bdist_egg
..
$ easy_install dist/greeting-1.0.0-py3.5.egg
..
$ greeting
Greeting!
$ pip unistnall greeting
(it uninstalls, but with some exception..)
--

Next,  I tried creating an egg without source code, which is what I want to do.
The package was installed but did not work as a standalone script (console_script).
Note that I can use it from interactive shell.

--
$ python setup.py bdist_egg --exclude-source-files
..
$ easy_install dist/greeting-1.0.0-py3.5.egg
..
$ greeting
Traceback (most recent call last):
  File "/Users/dmiyakawa/.pyenv/versions/3.5.2/bin/greeting", line 9, in <module>
    load_entry_point('greeting==1.0.0', 'console_scripts', 'greeting')()
  File "/Users/dmiyakawa/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py", line 542, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/Users/dmiyakawa/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2569, in load_entry_point
    return ep.load()
  File "/Users/dmiyakawa/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2229, in load
    return self.resolve()
  File "/Users/dmiyakawa/.pyenv/versions/3.5.2/lib/python3.5/site-packages/pkg_resources/__init__.py", line 2235, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
ImportError: No module named 'greeting'
$ python
Python 3.5.2 (default, Oct 24 2016, 21:47:12)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from greeting.greeting import greeting
>>> greeting()
Greeting!
--

I saw this behavior both on Mac (Siera), Windows (64bits), and Linux (Debian Jessie).

With pyenv, I tried the same thing with Python 3.6.0b3 (on Mac). Same there.
msg280214 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2016-11-07 17:35
console_script is a feature of setuptools. I'd suggest reporting this to https://github.com/pypa/setuptools We can reopen this if the problem is really in distutils. Thanks!
History
Date User Action Args
2022-04-11 14:58:39adminsetgithub: 72816
2016-11-07 17:35:06berker.peksagsetstatus: open -> closed

nosy: + berker.peksag
messages: + msg280214

resolution: third party
stage: resolved
2016-11-07 08:21:23dmiyakawacreate