2

I have a project structure as below:

project
|--invoices
 |--abc_company
 |--xyc_company
|--scripts
 |-- __init__.py
 |-- extract_xyz_data.py
 |-- extract_abc_data.py
 |-- extract_data.py
 |-- utilities.py
 |-- abc_validation.py
 |-- xyz_validation.py
|--main.py 

The main script that runs everything is main.py which is run on terminal and takes few argumensts via arg parser.

The invoices folder contains data. This data wud be changed every time the script is run. So data in this folder doesn't remain static or same. Think different pdfs every month.

I want to transfer this whole project and code base to a very less technical person in such a way that they don't have to deal with python a lot.

They do need to pass a few arguments in terminal but once they do that and change the data folder contents, it should run automatically.

Is asking them to run

python main.py arg1  arg2 arg3

efery time is the best way or can be package this whole project as an exec which just ask them to pass some arguments?

Can't use docker currenly.

Baktaawar
  • 7,086
  • 24
  • 81
  • 149

1 Answers1

0

https://docs.python.org/3/faq/windows.html

How do I make Python scripts executable? On Windows, the standard Python installer already associates the .py extension with a file type (Python.File) and gives that file type an open command that runs the interpreter (D:\Program Files\Python\python.exe "%1" %*). This is enough to make scripts executable from the command prompt as ‘foo.py’. If you’d rather be able to execute the script by simple typing ‘foo’ with no extension you need to add .py to the PATHEXT environment variable.

There isn't a big difference in effort between typing python main.py args, vs calling main.py (omitting the word python). If you follow the above, you could omit the requirement for adding .py ...

If you really want to make an executable, you can do this:

https://docs.python.org/3/faq/windows.html

How do I make an executable from a Python script? See cx_Freeze for a distutils extension that allows you to create console and GUI executables from Python code. py2exe, the most popular extension for building Python 2.x-based executables, does not yet support Python 3 but a version that does is in development.

For 3.x you can use pyinstaller

https://www.pyinstaller.org

https://pyinstaller.readthedocs.io/en/stable/operating-mode.html

PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files – including the active Python interpreter! – and puts them with your script in a single folder, or optionally in a single executable file.

Rahul Iyer
  • 19,924
  • 21
  • 96
  • 190
  • i mean wud pyinstaller give an option where one doesn't need to manually install all python libraries used in the project and they can also pass arguments to the exec? – Baktaawar Aug 19 '20 at 05:01
  • @Baktaawar Updated my answer :). According to their webpage it Does. Yes you can pass arguments. See https://stackoverflow.com/questions/25984395/after-compiling-python-program-how-to-input-arguments – Rahul Iyer Aug 19 '20 at 05:04
  • how does pyinstaller help me install all python packages automatically? Like if a new user needs to run my cli, they need to hv python 3 installed, pandas, nuympy, bunch of other packages installed before they can run it. crude way is to give them requirements.txt file and ask them to run to install all those stuff. I was wondering if instead of asking them to install all this on their system, if we can give them an exec which also allows them to pass arguments and new data. Does pyinstaller do all of that > – Baktaawar Aug 19 '20 at 05:16
  • @Baktaawar Yes. It packages the interpreter and all required packages together. – Rahul Iyer Aug 19 '20 at 05:32