I am researching for a way to distribute a python module as a single egg-file. Supposing I have a python module called my_module and I want to write a python script that generates an egg-file for my module. So I found setuptools.
from setuptools import setup
setup(
name="my_module",
packages=[my_package],
version="1.0",
)
And I've had some disadvantages regarding these issues:
- This script should be run as
python setup.py install. In other words, I need to specify command line arguments. Instead I want to generate my egg-file automatically during my python code, that has its own control over the command line arguments. - The result files are outputed into the setup's file directory. I would like to control the output directory path in the script.
- The script create
buildanddistfolders that I don't actually need. Probably, I could solve it by removing the folders after callingsetup.
How should I use setuptools for my purposes covering the issues above?
And also how can I load my module from given egg-file?
Supposing I have a following module:
# my_module.py
class MyClass:
def __init__(self):
self._x = None
def set_x(self, x):
self._x = x
def get_x(self):
return self._x
I wrote this script to create an egg-file:
# create_egg.py
from setuptools import setup
setup(
name="my_module",
packages=['my_module'],
version="1.0",
)
I get such error, when I run creage_egg.py:
$ python3 create_egg.py
usage: create_egg.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
or: create_egg.py --help [cmd1 cmd2 ...]
or: create_egg.py --help-commands
or: create_egg.py cmd --help
error: no commands supplied