Portable executable on OSX

2022-10-20 Thread wdamn
hi all,

I would like to have a portable executable of python3 on OSX.

I google a lot about it, but I could not find any solution.
Am I missing something or is it simply not possible?

thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Portable executable on OSX

2022-10-20 Thread Cameron Simpson

On 20Oct2022 03:01, wdamn  wrote:

I would like to have a portable executable of python3 on OSX.

I google a lot about it, but I could not find any solution.
Am I missing something or is it simply not possible?


I'm not sure what you mean. My Mac comes presupplied with Python 3, and 
I'd expect any modern Mac to be the same. So a python 3 programme should 
work on any Mac.


If you mean: "how do I write a Python script to use python 3?" the usual 
approach is to start the script with a shebang line like this:


#!/usr/bin/env python3

On _any_ UNIX or UNIXlike system (OSX/MacOS is a BSD derived UNIX) this 
will run the script with your usual "python3" command if you invoke the 
script as a command.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


Re: Portable executable on OSX

2022-10-20 Thread Thomas Passin
"Portable executable" usually means that the program resides on 
removable media, like a USB stick.  You can go to a computer, plug the 
stick in, and run the program.  If it's Python, then the installation on 
the removable medium needs to set up all the paths and directories 
correctly before actually running Python. That would typically be done 
with batch files setting paths and environmental variables.


I got this working for Python on Windows some years ago.  Here is the 
setup batch file I used - it gets executed when the user types "pyth37":


@echo off
setlocal
: Find effective drive for this file.
set ed=%~d0
path %ed%\python37\Scripts;%ed%\python37;%PATH%
set PYTHONUSERBASE=%ed%\user\python
set HOME=%ed%\user\python
call python %*
endlocal

It might need to be be more complex on MacOS, but it gives you the idea. 
 The odd-looking line "set ed=%~d0" is a Windows-specific way to get 
the drive of the command file being run.


On 10/20/2022 4:53 PM, Cameron Simpson wrote:

On 20Oct2022 03:01, wdamn  wrote:

I would like to have a portable executable of python3 on OSX.

I google a lot about it, but I could not find any solution.
Am I missing something or is it simply not possible?


I'm not sure what you mean. My Mac comes presupplied with Python 3, and 
I'd expect any modern Mac to be the same. So a python 3 programme should 
work on any Mac.


If you mean: "how do I write a Python script to use python 3?" the usual 
approach is to start the script with a shebang line like this:


     #!/usr/bin/env python3

On _any_ UNIX or UNIXlike system (OSX/MacOS is a BSD derived UNIX) this 
will run the script with your usual "python3" command if you invoke the 
script as a command.


Cheers,
Cameron Simpson 


--
https://mail.python.org/mailman/listinfo/python-list


Re: Portable executable on OSX

2022-10-20 Thread Chris Angelico
On Fri, 21 Oct 2022 at 08:50, Thomas Passin  wrote:
>
> "Portable executable" usually means that the program resides on
> removable media, like a USB stick.  You can go to a computer, plug the
> stick in, and run the program.  If it's Python, then the installation on
> the removable medium needs to set up all the paths and directories
> correctly before actually running Python. That would typically be done
> with batch files setting paths and environmental variables.
>
> I got this working for Python on Windows some years ago.  Here is the
> setup batch file I used - it gets executed when the user types "pyth37":
>
> @echo off
> setlocal
> : Find effective drive for this file.
> set ed=%~d0
> path %ed%\python37\Scripts;%ed%\python37;%PATH%
> set PYTHONUSERBASE=%ed%\user\python
> set HOME=%ed%\user\python
> call python %*
> endlocal
>
> It might need to be be more complex on MacOS, but it gives you the idea.
>   The odd-looking line "set ed=%~d0" is a Windows-specific way to get
> the drive of the command file being run.
>

Basic idea looks sound. Might actually be _easier_ on OSX, since it's
Unix-like and you should be able to depend on /bin/bash. The notation
`dirname $0` should give you the path to the current script, from
which everything else can be calculated.

(Caveat: Never actually done this on a Mac, and only did cursory web
searching to check that it wasn't a ridiculous idea.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Third round of the Smart Iterator Challenge: September-October 2022

2022-10-20 Thread dn

Challenge-week 3: Generalising the solution, starts today!
Details from the Meetup site: 
https://www.meetup.com/nzpug-auckland/events/288813734/
A virtual event run by the Auckland Branch of the New Zealand Python 
Users' Group.



It's Week 3 of the Smart Iterator Challenge! Time to see how modules and 
namespaces provide building-blocks which enable us to cope with change. 
Can you anticipate and manage change? The tutorial demonstrates SOLID's 
SRP (and a bit of OCP) for those who want to learn more than Python-coding.


This Challenge will interest Python-Journeymen, and Python-Apprentices 
ready to move-on from ‘the basics’. There is a separate-but-related 
question for Python-Masters and any advanced Journeymen who are finding 
the main Challenge too-easy (available upon personal request), in 
recognition of being prepared to help others.


We start with a review of Challenge-week 2 and a sample-answer to 
download and compare with your own efforts. Challenge-week 3 starts with 
either your own or a provided template-script, so you don't have to have 
completed Challenge-weeks 1 and 2 (but it will help). Again, there is a 
tutorial in case you haven't met namespaces before. Followed by multiple 
specifications to implement.


In many ways, the challenge is not so much writing code, as it is 
designing a code-solution. Putting code-modules together, something like 
a jig-saw puzzle!



Challenge Schedule: Generalising the solution
Starting: Sat 22 Oct Office Hours: 1830*, Wed 26 Oct Concluding: 
midnight after Sun 30 Oct

* all times NZDT (UTC+13)


Are you up for a challenge?
Regards =dn (for Pete and DJ)
--
https://mail.python.org/mailman/listinfo/python-list