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


Groups > comp.lang.python > #90722 > unrolled thread

How to deploy a custom common module?

Started byzljubisicmob@gmail.com
First post2015-05-15 21:38 -0700
Last post2015-05-17 04:32 +0200
Articles 3 — 3 participants

Back to article view | Back to comp.lang.python


Contents

  How to deploy a custom common module? zljubisicmob@gmail.com - 2015-05-15 21:38 -0700
    Re: How to deploy a custom common module? Jason Friedman <jsf80238@gmail.com> - 2015-05-16 20:06 -0600
      Re: How to deploy a custom common module? Irmen de Jong <irmen.NOSPAM@xs4all.nl> - 2015-05-17 04:32 +0200

#90722 — How to deploy a custom common module?

Fromzljubisicmob@gmail.com
Date2015-05-15 21:38 -0700
SubjectHow to deploy a custom common module?
Message-ID<05d4eec1-1590-41ae-9315-7bb3cd2b22ee@googlegroups.com>
While working on one python script (test.py), I developed some functions that I will probably need in my future projects, so I decided to put such functions in another python file (cmn_funcs.py).

So in my test.py there is import cmn_funcs in order to use common functions and everything works well.

When I deploy test.py on another computer, I put (rsync) both test.py and cmn_funcs.py in the same remote directory.

If I create another python project (test2.py) in new directory, that needs common functions, what should I do with cmn_funcs.py?

Cmn_funcs.py should be in some shared directory accessible by my every current and future python project.

Furthermore, I would like to preserve simplicity of using rsync for upgrading these three python files on remote computers. 

How to deploy custom a custom common module?
Where to put it?
How to use it?
How to upgrade it?

[toc] | [next] | [standalone]


#90764

FromJason Friedman <jsf80238@gmail.com>
Date2015-05-16 20:06 -0600
Message-ID<mailman.88.1431828418.17265.python-list@python.org>
In reply to#90722
> When I deploy test.py on another computer, I put (rsync) both test.py and cmn_funcs.py in the same remote directory.
>
> If I create another python project (test2.py) in new directory, that needs common functions, what should I do with cmn_funcs.py?

I put my shared code in a separate folder, named something like
/path/to/module_dir.

I then add to /etc/profile.d/something.sh:

export PYTHONPATH=$PYTHONPATH:/path/to/module_dir

[toc] | [prev] | [next] | [standalone]


#90765

FromIrmen de Jong <irmen.NOSPAM@xs4all.nl>
Date2015-05-17 04:32 +0200
Message-ID<5557fda6$0$2961$e4fe514c@news.xs4all.nl>
In reply to#90764
On 17-5-2015 4:06, Jason Friedman wrote:
>> When I deploy test.py on another computer, I put (rsync) both test.py and cmn_funcs.py in the same remote directory.
>>
>> If I create another python project (test2.py) in new directory, that needs common functions, what should I do with cmn_funcs.py?
> 
> I put my shared code in a separate folder, named something like
> /path/to/module_dir.
> 
> I then add to /etc/profile.d/something.sh:
> 
> export PYTHONPATH=$PYTHONPATH:/path/to/module_dir
> 


I think you could use the user site packages directory as well for this... then you
should not have to change the PYTHONPATH.

https://docs.python.org/3.5/library/site.html#site.USER_SITE

(if you don't want to or cannot install into to the system's site-packages directory)


Irmen

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web