1

I have created a simple python3.7.1 command-line application using click in a conda virtual env that works fine when running as a module python -m.

End-goal:

To create a single command (binary) executable that can be shipped to somewhere on the filesystem that is preferably not dependent on a python/conda virtual environment.

Note that this question is likely closely tied to my complete lack of understanding of setuptools (I have read through the docs).

Project structure:

python_clean_repo/
├── README.md
├── conda-environment.yaml
├── setup.py
├── tests
│   └── test_basic.py
└── yourpackage
    ├── configs
    │   ├── app_config.yaml
    │   └── config.py
    ├── main.py
    └── scripts
        └── cmdline.py

When run with the -m option, everything works as expected:

$ python -m yourpackage.scripts.cmdline
Hello World!
here i am in main
config is {'key': 'value'}

The packaging appears to complete successfully:

$ pip install -e .
...
Successfully installed python-clean-repo

So I now have an executable in my virtual env called yourscript (which is the name of the entrypoint provided in setup.py) which works exactly as I would expect:

$ yourscript
Hello World!
here i am in main
config is {'key': 'value'}

The question is:

How do I "ship" this executable, that now appears directly tied to my virtual environment? I have also tried python setup.py sdist but for some reason the created tar.gz does not contain everything (there are no included .py modules, just a bunch of .txt files such as entry_points.txt and requires.txt

user9074332
  • 2,336
  • 2
  • 23
  • 39
  • Possible duplicate of [How to make a Python script standalone executable to run without ANY dependency?](https://stackoverflow.com/questions/5458048/how-to-make-a-python-script-standalone-executable-to-run-without-any-dependency) – phd Feb 21 '19 at 04:59
  • https://stackoverflow.com/search?q=%5Bpython%5D+standalone+script – phd Feb 21 '19 at 04:59
  • The "duplicate" suggestion references `pyinstaller` which doesnt seem to install into my conda env (tried with both pip and conda). I still don't have a good enough grasp of the build process around `setup.py` to fully understand if this is actually the thing I need to get the job done and I just dont understand *how* to use it. – user9074332 Feb 21 '19 at 05:21

0 Answers0