Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73492

Re: How to distribute python console program

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'scripts': 0.03; '(using': 0.07; 'installed.': 0.07; 'imported': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:How': 0.10; 'python': 0.11; 'stored': 0.12; '__init__.py': 0.16; 'earlier.': 0.16; 'elsewhere,': 0.16; 'folder,': 0.16; 'folder.': 0.16; 'helps.': 0.16; 'path.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'script,': 0.16; 'simplest': 0.16; 'slight': 0.16; 'subject:program': 0.16; 'whatever,': 0.16; 'subject:python': 0.16; 'folder': 0.16; ':-)': 0.16; 'wrote:': 0.18; 'module': 0.19; 'basically': 0.19; 'machine': 0.22; 'installation': 0.23; 'header:User-Agent:1': 0.23; 'fine': 0.24; 'environment': 0.24; 'script': 0.25; 'mention': 0.26; 'possibly': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'installed': 0.27; 'wondering': 0.29; 'related': 0.29; 'getting': 0.31; "skip:' 10": 0.31; 'that.': 0.31; '(on': 0.31; 'file': 0.32; 'option': 0.32; 'run': 0.32; 'another': 0.32; '(i.e.': 0.33; 'projects.': 0.33; 'could': 0.34; 'something': 0.35; 'prepare': 0.35; 'but': 0.35; 'add': 0.35; 'located': 0.36; 'described': 0.36; 'machine.': 0.36; 'done': 0.36; 'possible': 0.36; 'similar': 0.36; 'should': 0.36; 'two': 0.37; 'clear': 0.37; 'easily': 0.37; 'configured': 0.38; 'e.g.': 0.38; 'generic': 0.38; 'whatever': 0.38; 'to:addr:python-list': 0.38; 'files': 0.38; 'anything': 0.39; 'does': 0.39; 'bad': 0.39; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'hope': 0.61; 'strictly': 0.61; 'from:charset:utf-8': 0.61; 'simply': 0.61; 'simple': 0.61; 'making': 0.63; 'organization': 0.63; 'refer': 0.63; 'more': 0.64; 'side': 0.67; 'risk': 0.72; 'export': 0.74; 'introduce': 0.78; 'as:': 0.81; 'installer': 0.84; 'received:31': 0.91; 'hand,': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Jurko Gospodnetić <jurko.gospodnetic@pke.hr>
Subject Re: How to distribute python console program
Date Sun, 22 Jun 2014 11:56:40 +0200
Organization PKE sistemi d.o.o.
References <bc95879a-5f0b-4b79-bfc9-71a3d61fc224@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 31.217.107.68
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0
In-Reply-To <bc95879a-5f0b-4b79-bfc9-71a3d61fc224@googlegroups.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11183.1403431014.18130.python-list@python.org> (permalink)
Lines 76
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1403431014 news.xs4all.nl 2884 [2001:888:2000:d::a6]:34955
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73492

Show key headers only | View raw


   Hi Nicholas.

On 22.6.2014. 4:51, Nicholas Cannon wrote:
> I have a simple program that is ran in the console with
> 2 modules and i was wondering how i could like export it
> so i could give it to someone to use as like a utlitie
> in the console?

   Assumptions:
     * You have one script - script.py, using two additional module - 
module1.py & module2.py.
     * You want to hold the script in some generic Utility folder (on 
your system path or wherever). Let's refer to that folder as 
'D:\Utility', just to make it seem more realistic.
     * Target machine already has the desired Python environment installed.


   The simplest 'all in one' solution would be to simply copy script.py, 
module1.py & module2.py into the 'D:\Utility' folder. Then you can run 
script.py as a script (using whatever Python environment you prefer) and 
its folder (i.e. 'D:\Utility') will automatically be added to the Python 
path, ergo module1.py & module2.py can be easily imported using 'import 
module1' & 'import module2' respectively.

   One possible bad side to this organization is that the user does not 
necessarily know what module1.py & module2.py files are - they are 
stored together with other utility scripts but need not be runnable 
scripts by themselves. If they can be run as standalone scripts then 
that is all fine and well but if they are not - user does now know that 
they should not be and possibly what they are related to.


   A slight variation making it clear which scripts should be runnable 
directly and which should not would be to move module1.py & module.py 
under some 'D:\Utility\script_details' folder and add an empty 
__init__.py file to that folder as well.

   Then module1.py & module2.py can be imported as:
     'import script_details.module1'
   and:
     'import script_details.module2'
   respectively.


   Another addition is to prepare a packaged installer that installs your
files in one of the aforementioned structures as any other application, 
e.g. under '/usr/bin', 'C:\Program Files' or whatever, but that's 
strictly an addition to what was described earlier.


   If the script and the modules you mention are self-contained and are 
not intended to be reused elsewhere, then I don't think you need 
anything more complex than that. If they are not then you have an option 
to place the implementation module in some shared Python environment 
folder, e.g. a specific Python environment's 'site-packages' folder. 
That would allow you to easily reuse those modules from other scripts 
located in other folders, but it would also introduce additional 
complications - with it you need to make sure the folder you placed them 
on has indeed been configured to be located on the used Python 
environment's Python path.


   Another variation is to package an installer that basically installs 
a stand-alone Python distribution together with your script, e.g. like 
something done by cx_Freeze or similar projects. Then your target 
machine does not need to have Python installed separately, but on the 
other hand, the installation is much larger and you risk getting 
multiple Python installations all over the same machine. :-)


   Hope this helps.

   Best regards,
     Jurko Gospodnetić

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to distribute python console program Nicholas Cannon <nicholascannon1@gmail.com> - 2014-06-21 19:51 -0700
  Re: How to distribute python console program Jurko Gospodnetić <jurko.gospodnetic@pke.hr> - 2014-06-22 11:56 +0200
  Re: How to distribute python console program Nicholas Cole <nicholas.cole@gmail.com> - 2014-06-22 10:58 +0100
  Re: How to distribute python console program Terry Reedy <tjreedy@udel.edu> - 2014-06-22 14:25 -0400

csiph-web