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.
|