Pkg iter_module for different versions of python
as a sysadmin I've written several small tools as python command line apps that get installed with python setup.py install. I would now like to create another tool that would quickly list out all of my custom tools that may be installed on the system. so that others can get a quick menu of what commands are available. I believe I have a working app that uses the iter_modules function to list out all of the names and then I just filter based on names that I know to be mine. My problem.. This works if everyone of my tools is only written in python 3 or 2, but not both. Are there any tricks to getting iter_modules to return both python 3 and 2 installed modules? J -- https://mail.python.org/mailman/listinfo/python-list
Fwd: Pkg iter_module for different versions of python
Might anyone know of a root place where python modules get saved to for
both python2 and 3. I assume I'm looking for all of the places where
"site-packages" can be written to.
J
-- Forwarded message -----
From: J A
Date: Sun, 9 Feb 2020 at 17:56
Subject: Re: Pkg iter_module for different versions of python
To: DL Neil
Ya.. perhaps it would make more sense to start with "dirty" knowledge. I.e.
a list of package/module names and then make sure they have the required
entry points, therefore "validating" that they belong to me.
Is there a valid directory structure to start from that is universal?
perhaps from there I could parse through site-packages/**/MODULE_name.whl
or something?
and yes no more python 2 however a few of my commands are/were wrapping
third party tool api's that are python 2 :/
J
On Sun, 9 Feb 2020 at 17:05, DL Neil via Python-list
wrote:
> On 10/02/20 4:46 AM, J A wrote:
> > as a sysadmin I've written several small tools as python command line
> apps
> > that get installed with python setup.py install. I would now like to
> create
> > another tool that would quickly list out all of my custom tools that may
> be
> > installed on the system. so that others can get a quick menu of what
> > commands are available. I believe I have a working app that uses the
> > iter_modules function to list out all of the names and then I just filter
> > based on names that I know to be mine.
> >
> > My problem.. This works if everyone of my tools is only written in
> python 3
> > or 2, but not both. Are there any tricks to getting iter_modules to
> return
> > both python 3 and 2 installed modules?
>
>
> Is the issue with iter_modules?
>
> Remember that different Python versions are installed with separate
> libraries/paths. Accordingly, this lap-top's /usr/lib64 has both
> python2.7/ and python3.7/ sub-directories.
>
> When an application is running under one* or the other, the sys.path
> changes accordingly (assuming the pkgutil.iter_modules(path=None) option).
>
> (in case needed) Remember also that different installation methods may
> install packages in different directories anyway, eg personal
> installation or system-wide. So, even 'this' sys.path may not reveal
> what is present on 'this system'.
>
> Might it be worth reversing the strategy and starting from a list of
> your modules, search likely portions of the directory-structure for
> 'your stuff'?
> (from a perspective of complete ignorance of the problem domain)
>
> * requisite notice about not using deprecated Python2.n these days!
> ("Do as I say, but not as I do"? I suspect/hope that this system's 2.7
> is 'legacy' and no longer used for anything, including the OpSys)
> --
> Regards =dn
> --
> https://mail.python.org/mailman/listinfo/python-list
>
--
https://mail.python.org/mailman/listinfo/python-list
Application setup like windows msi
I was wondering g if there was a way to distribute an application that took advantage of user input like a windows .msi does. On linux of course. -- https://mail.python.org/mailman/listinfo/python-list
Re: executable builder
I am having some issues compiling an exe myself but most of that stems from the version of python I am using. That being said, try using GUI2EXE http://code.google.com/p/gui2exe this program makes the setup file go a lot easier, also it will tie in a few different tools like py2exe which is what I have been working with, also it does include py2app (the mac version). If you decide to go this route please pay careful attention to http://py2exe.org/index.cgi/Tutorial#Step52 if using python26, this bit of instruction could have saved me hours of banging my head on my desk. > On Thursday, July 01, 2010 3:16 AM King wrote: > Hi, > > I am trying to build python a cross platform python executable builder > to deploy python app. I tried various tools such as py2exe, > pyinstaller, cx_freeze but some how they are not upto the mark except > py2exe. Unfortunately py2exe is working only on windows based systems. > > The task is divide into 3 steps: > 1. Collect all the modules(.pyo, .pyd, .dll, etc) required for your > project. > 2. set up temporary environment for python > 3. run main.py using :python.exe main.py > > Initially I will not be creating an executable using main.py. I would be > using shell scripting to execute the main.py. > > Q1. Which is most efficient way to fine all the modules required by > your "main.py". > Q2. For example, I have copied all the modules in "d:\project\lib\*.*" > python.exe, python.dll, ms*.dll, main.py are copied to "d: > \project". > Before executing "python.exe main.py", I have to set up an > environment var and point it to "d:\project\lib", so > that python.exe can find the path for searching/loading > modules. How do I do that? > Q3. How do you convert your "main.py" into an executable? > > Prashant -- http://mail.python.org/mailman/listinfo/python-list
How to find parent function/class of generators?
Hello all. I think I should explain my problem in detail, so everyone understands what I'm trying to do and why. There may be a better approach to the whole problem then I am using. I am working on a game, with most of my AI code & such divided up into generator functions (really coroutines that don't take any input) stored in a dictionary called Director.tasks, and handled by a simple cooperative multitasking engine. The dictionary key is the generator object to be advanced, and the value is the frame number at which it should next be executed. The generator objects yield the delay before their next execution. def realtick(self): Director.frame += 1 for task in Director.tasks.items(): if task[1] <= Director.frame: try: result = task[0].next() if result == -1: Director.tasks.pop(task[0]) else: Director.tasks[task[0]] = Director.frame + result except: Director.tasks.pop(task[0]) Why did I use a dictionary? Originally I had a list of lists, but I thought converting it to a dictionary would make removing tasks from the queue easier, the main difficulty I'm having. But it didn't, because I can't identify the Due to the framework I'm using, I think (or possibly just the Python language?) in-game objects aren't actually destroyed when they're removed from the game world. Thus, when an enemy or something with associated tasks 'dies', the tasks merrily continue executing... and the game will have a bunch of enemies who no longer have sprites, movement abilities or collision checks, but otherwise are none the worse for wear for having been destroyed. It's a big mess. So I need a way to remove all tasks associated with a game object from the queue, upon the object's 'destruction'. Unfortunately, generator objects don't seem to include any information about the parent object or function that created them. I ran the dir() builtin on a sample generator object, created from an object method, and got this: ['__class__', '__delattr__', '__doc__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__str__', 'close', 'gi_frame', 'gi_running', 'next', 'send', 'throw'] __class__ just contains . If __doc__'s the docstring, I suppose I could use that to identify the generator object, but it seems hackish nothing else in that list looks likely. Is this python's message to me that I'm abusing generators for entirely the wrong purpose? In any case, since I can't figure out how to determine which generator object corresponds to which game object, I'm stuck. I'd appreciate any pointers or suggestions. :) I might have missed something very obvious, since I'm no pythonista and have generally been working on this in short spurts late at night. If so, sorry for making you read all of this! -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: eric3 3.9.0 released
Detlev Offenbach wrote: > Hi, > > this is to inform you of the release of eric3 3.9.0. This version > includes support for Qt4 and PyQt4. Hi, I'm getting a "Segmentation fault" error when trying to execute eric3 although I've installed Qt-3.3.4, QSCintilla-1.65, sip-4.4.3 and PyQt-3.16, in that order, as recommended, using Slackware 10.2 with kernel 2.6.15.3 and gcc-3.3.6. Do you know what could be going wrong? Thanks, -- jagm -- http://mail.python.org/mailman/listinfo/python-list
Re: ANN: eric3 3.9.0 released
Petr Jakes wrote: > I think you can get the answer on > http://www.die-offenbachs.de/detlev/eric3-mailinglist.html > rather then here. > > HTH > > Petr Jakes Thanks Petr, I've got help there. To those interested, the problem was PyKDE was missing. Best regards, -- jagm -- http://mail.python.org/mailman/listinfo/python-list
