A Real Talk About Python Software Distribution [closed] - python

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I know this is a hot topic and many people ask this question but I have the feeling I am missing something. What is the proper way to make a python application for end-users? Like, old-school offline .exe and so on. Many users won't touch the terminal/shell and to be honest most software these days is incredibly easy to install. What I know so far:
There are packages out there that can make your software ready for redistribution like
pyinstaller, cx_freeze, py2exe
I wrote my fairly complex software in like 2 weeks and going crazy for days over making pyinstaller work with my external packages. Is this pain normal? Have I made a mistake by relying on an interpreted language? Because compiling this stuff is mean business. In many other languages you just build the stuff within the IDE and there you go, built.
I am not concerned that my code might be decompiled, so what I have tried is to just create a .bat file with commands to execute my script with my virtual environment(!) python. Can I just manage to have the Python venv in place with my scripts without the user having to install it himself?
Or what is the "usual" way to do this? Use Cython? Or pyinstaller? Praying to the lord of code?
FYI: I am using Python 3.6.8, Windows 8 (don't you dare making fun of me :D) and Pycharm 2019.2
However thank you in advance for your time, regards,
Arjaan

There is no correct or established way of how to create an executable file for your Python project. It's opinion-based.
And how you want to distribute your software is entirely up to you. It can be source code, compiled, as a docker image, through Heroku One-Click deployment, debian package, all of the above, ???.
Having choices is nice. Some people need a really simple solution then Heroku or an exe file is nice. Some people are Docker power users, then a multi-arch docker image is nice. Some people want to modify the source code than having the source code is nice. Some people like debian packages and want your project with a systemd service file automatically enabled and started.
You might also not put into the work of getting docker/debian/heroku to work and just tell them a step by step guide on how to get it to run.
Debian and Heroku route might require some periodic maintenance due to the Linux distros updating to newer versions.
There is so much to it and it is an endless discussion where noone is right or wrong.

Related

Understanding python development environments ide's, text editors etc [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 1 year ago.
Improve this question
So today I spent hours trying to understand why the package I installed using pip install in terminal was giving me an "module not found" error. Which I know is a file path problem. After a lot of tinkering around I eventually pip installed the library on powershell. Like magic it works. To avoid these headaches in the future and to gain a deeper understanding of all things programming does anyone have a book or class they could recommend to understand the circus of ide's, text editors, file paths, kernals, interpreters, compilers etc. I have no idea where to begin and it's really hard trying to troubleshoot these issues when I've never been given any formal instruction on how all these things work together. Is this something learning a language like C would help me understand? FYI Or does this just take pain and years of experience to navigate. FYI I've only taken a few basic college level python courses.
No, this has little to do with the programming language. It’s about knowing your way around your operating system. As such it’s not a good SO question; perhaps you should try superuser or one of the OS-specific StackExchange sites.
But what helps is understanding the command line. When you run “pip”, you need to make sure that the program pip - which is just a Python script - is being run by the same Python interpreter that you’ll be using later when you try to import the module.
Basic advice: find all the “python” and “python3” executables on your system. Pick the one you want, or install a new one. Either way, make sure that the directory containing it comes before any of the others in your command search path, and both names (with and without the 3) are there and point to the same binary file. That way you always know what you’re getting when you run “python” at the shell prompt. Make sure you configure your IDE to use the same one, too. And instead of typing “pip”, type “python -mpip” so that you know it’s at least installing into the same environment you get when you type “python”.

How to quit Jupyter and become a better programmer? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I am a self-taught programmer coming from a scientific (non-programming) background. I discovered Jupyter early after I started using Python. And although I greatly enjoy using it (Jupyter), I feel that it somewhat hindered my ability to think ahead and write code that will be easy to maintain and interact with in the future.
I inevitably end up with these endless notebooks that are impossible to navigate and mostly consist of redundant code. I then tuck away some of the functions into text files. Make a copy of the notebook, delete a bunch of cells, and start over. Until the notebook becomes unmanageable again, then semi-refactor, make a copy, prune cells, and so on.
I feel that at this point I should learn some basic software design principles and practices (like version control and code organization). Is there a course or a lecture series you can recommend that might help me with that? I feel that any advice from you will be helpful. Thanks!
This will help in learning version control from official Git Documentation
This will also help in Software development philosophies from wikipedia
Try sublime text editor. It is not an IDE but it is really good for coding and has a bunch of useful coding plugins. It is not free but has an unlimited free trial, in which you get all the features, and an occasional popup asking you to buy it. If you download it, you should also use some plugins to help you code python
I personally use these plugins:
Origami, Terminus, Kite & Anaconda
I f you don't like sublime or using a plain text editor, check out visual studio code, idle or thonny.
They are full IDEs (not code editors), and will thus have more features.
IDLE & thonny are beginner's IDEs and Visual Studio Code is a lot more powerful & complex
Now you have your Jupyter notebook replacement on to the version control
Instead of using git, use github. It is built on top of git, and is a lot easier.
If you don't already have a github account then create one. Now you have a version control system going. I am not going to go any deeper because i am not very good at github version control so check out this site

What is best practice for working on a Python library package? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
Basically we have a Python library with modules and functions that we use in many of our programs. Currently, we checkout the SVN repository directly into C:\Python27\Lib so that the library is in the Python path. When someone make modifications to the library, everyone will update to get those modifications.
Some of our programs are frozen (using cx-Freeze) and delivered so we have to keep tracking of the library version used in the deliveries, but cx-Freeze automatically packages the modules imported in the code.
I don't think it is a good idea to rely on people to verify that they have no uncommitted local changes in the library or that they are up to date before freezing any program importing it.
The only version tracking we have is the commit number of the library repository, which is not linked anywhere to the program delivery version, and which should not be used as a delivery version of the library in my opinion.
I was thinking about using a setup.py to build a distribution of a specific version of that library and then indicate that version in a requirements.txt file in the project folder of the program importing it, but then it becomes complicated if we want to make modifications to that library because we would have to build and install a distribution each time we want to test it. It is not that complicated but I think someone will freeze a program with a test version of that library and it comes back to the beginning...
I kept looking for a best practice for that specific case but I found nothing, any ideas?
Ultimately you're going to have to trust your users to follow what development process you establish. You can create tools to make that easier, but you'll always end up having some trust.
Things that have been helpful to a number of people include:
All frozen/shipped builds of an executable are built on a central machine by something like BuildBot or Jenkins, not by individual developers. That gives you a central point for making sure that builds are shipped from clean checkouts.
Provide scripts that do the build and error out if there are uncommitted changes.
Where possible it is valuable to make it possible to point PYTHONPATH at your distribution's source tree and have things work even if there is a setup.py that can build the distribution. That makes tests easier. As always, make sure that your tools for building shipped versions check for this and fail if it happens.
I don't personally think that a distribution has a lot of value over a clean tagged subversion checkout for a library included in closed-source applications.
You can take either approach, but I think you will find that the key is in having good automation for whichever approach you choose, not in the answer to distribution vs subversion checkout

Python for Android [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
I had a look at Kivy,but the problem is it needs a virtual machine to run apps. Isn't there a way where python codes are directly converted to java bytecode which can be run by android without any virtual machine? What are the merits/demerits in terms of performance?
May be something in jython which would help?
Try SL4A for running Python code directly on your device. It requires no compiling, conversion to bytecode or virtual machines.
More information Here
Also, you can download an IDE (I've used Eclipse, like in the tutorial you will find on the site), installed a plug-in, created my source files there and then uploaded them to my phone, if you're uncomfortable with writing code on your device.
This page has full instructions on how to package a Kivy app into an APK: http://kivy.org/docs/guide/packaging-android.html
I think some one mislead you a lot or you are confused about how things work with kivy.
I'll take this opportunity to try and make things a bit more clear.
Kivy can be used to build stand alone apk, only if you had searched kivy in google play. This link shows a list of apps that mention kivy, there are a lot more apps there that use kivy and just don't mention that. There is also a partial user maintained list you can look at. You can install the apps from google play and you'd see that they are self contained and don't require you to download anything extra.
There are very easy instructions available on how to build a apk in the link mentioned by #Marcins.
Every python code passes through the python interpreter usually pre-compiled to pyc, that's how python works even Java uses a virtual machine JVM, Android's implementation uses Dalvik VM. You can learn more about the VirtualMachines used in the languages like java/python here. The python interpreter/vm consumes the code and executes it natively, it doesn't convert it to java byte code.
if you need to make something that needs more performance then you can even use cython with kivy to get more speed.

Android Python Programming [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Can I program for Android using Python? I seem to have stumbled upon many links while searching... however neither of them is concrete.
Any suggestions? I want to write apps for Android but really don't want to get into Java for all this.
PS: My question is whether I can write proper, full fledged apps for Android.
Checkout Kivy. They have done a really great job so far, and I am a big fan of their work. It is still lacking some providers, but they keep adding new stuff to it everyday. First thing you need to do is to check your requirement against what they can offer based on their documentation. They have create an amazing framework for input such as multi-touch or pen handling. They use OpenGL ES internally, as a result complex graphics and visualizations can run very fast when interacting with the the application. Their process for creating an apk is also very straight forward.
Check the new Python for Android project.
Edit: This is not Kivy, this is a seperate project, intended to be a toolchain usable for other toolkit. The architecture is modular, and you can include new recipe for including new python extensions (as brew, macports, cygwin etc.).
Edit: This is not Py4A, but python-for-android.
This is great for starters:
Embed Python 2.7 interpreter and your scripts into an Android APK
No, not currently. ASE (Android Scripting Environment) allows you to do simple script apps, but you can only write proper Android apps in Java.
Yep, you can.
Check ASE
Edit:
Ok, after comments:
I haven't read the question properly. No you can't write write proper, full fledged apps for Android, but anyway check ASE. It is really cool project.

Categories

Resources