I wrote a program in python 3.6.2 .
I converted .py to a setup file.
I want in python program or want to write a function which downloads the newer version of program and installs it automatically and removes Old version.
I searched it in internet but not found a good solution.
Is there anyone who can help me with this?
Have you looked at Setuptools?
From their website:
"Automatically find/download/install/upgrade dependencies at build time using the EasyInstall tool, which supports downloading via HTTP, FTP, Subversion, and SourceForge, and automatically scans web pages linked from PyPI to find download links. (It’s the closest thing to CPAN currently available for Python.)"
http://setuptools.readthedocs.io/en/latest/setuptools.html
Related
I have tried to use pip download for downloading wheels but the problem was that I needed to download all platform wheels that means:
I am using Windows 10
The package I want is having wheels built for Linux, OS X, Windows
I want to download all platform wheels but only for a specific version of project
For example:
I want to download pygame==2.0.0 with wheels for all platforms so I can later use them. Also I want to download All dependenies of it recursively like that.
EDIT
I just found the json api and works great with pypi, thanks.
You can scrape all links on the "Download files" tab of pygame 2.0.0.
Or you can use the JSON api endpoint for pygame 2.0.0. Look for the urls list on the return JSON object. [doc]
There are probably tools, libraries that can help with that.
Also I want to download All dependenies of it recursively like that.
In general, this is quite a different story. You would need to know in advance the details of each platform you are targeting: operating system, python implementation, python interpreter version, CPU bitness. And maybe you could build commands such as:
python -m pip download pygame==2.0.0 --only-binary=:all: --platform win32 --python-version 37
But unless I am mistaken (I did not check thoroughly), it seems to me like pygame does not have dependencies.
I want to distribute a python program on, say, Windows and/or Mac, but I don't want to give the user the headache of ensuring there is an appropriate python runtime installed on their machine. And i don't want to interfere with their machine's configuration by, let's say, requesting root privileges and installing a system-wide python runtime on their system that suits my program specifically because it's too invasive and might cause compatibility collisions with other installed versions of the runtime.
I would much rather have a self-contained executable that could be, for example, stored on a USB flash-drive, inserted into the system, and then maybe with a stepping-stone binary executable that just invokes the device-portable runtime on a python script that I provide, I could then run the program as if it were a self-contained binary executable (with only standard-library dependencies).
A link to this binary executable could be published into main-menu program lists, docks, or desktops. And it could be invoked by shell scripts or other executed-by-proxy mechanisms. Such a no-install/self-contained python program could potentially be a first-class user-invokable application. This is what I want to achieve.
I googled around for projects that provided a device-portable/mobile python installation and so far I've only found portablepython.com. Unfortunately it says the project is discontinued and no download link for the project is provided. it listed some similar projects but they all seemed defunkt or with a very different focus.
Does anyone know of an active project that is or includes such an independent/portable/mobile/no-install distribution for python?
or is there some way i could configure python's build system to build a noinstall-friendly product?
any ideas welcome. thanks for your input!
After more searching I found that Python.org publishes its own standalone-python distribution called the embeddable zip file.
This is exactly what I was searching for. It's a basic python standalone runtime that requires relatively few megabytes of storage.
I started with this embeddable distro and then cajoled a standalone copy of pip to work with it. Problem solved.
Improving upon #oreus2020's answer, you can download the embeddable zip file from here. Then, unzip the compressed file to a folder of your choice. Go to the root of your install and find python._pth file and open it in a text editor. Remove the "#" before import site(This file is the one which manages the environment of the portable install. If you want anything to be recognized by the portable python interpreter, just throw the path in here and that's it!). If you want pip, go to this page and save it in the root of your portable install and run it using the portable python interpreter like ./python get-pip.py from a commandline opened at the root of your install. Pip installed! To use the pip, do ./python -m pip <commands> from the commandline opened at the root of your install and then open the python._pth file and insert the following below the "." ./Lib/site-packages ./Scripts. Voila, you got yourself a python portable install!
My python._pth file looks like:
python39.zip
.
# Uncomment to run site.main() automatically
./Repo
./Repo/Code
./Repo/Code/cogs
./Lib/site-packages
./Scripts
import site
If you are still wondering, here is the link to the one I made for myself.
P.S. Pardon my bad English
I searched this and it's always about Linux operating systems and I'm unable to see any videos or tutorial sites.
I have windows 10 64x based os and I plan to use Python 3.4.x (https://www.python.org/downloads/) for me to use the old cx_freeze (https://sourceforge.net/projects/cx-freeze/files/4.3.3/) since I have this video tutorial in youtube I am currently following https://www.youtube.com/watch?v=XHcDHSWRCRQ which is a python 3 tutorial to create exe file.
The latest cx_freeze file uses .whl files that is so inconvenient for me and I won’t be able to follow the youtube tutorial mentioned above to create a .exe file for my python, thus went on the old cx_freeze that works https://sourceforge.net/projects/cx-freeze/files/4.3.3/ where latest version is for python 3.4. The tutorial on the video has the same cx_freeze process to create a .exe file even if it's for python 3.2.
Also, I don't see any installer of Python 3.4 on it's official page but TGZ files only. I searched about how to use TGZ files on Windows but it's just about extracting and nothing else, while other tutorials on how to install it are all linux based.
How do install it?
This legacy Python website has official downloads for 3.4.0 including a Windows installer. You should be able to grab the .msi from there and that will fix your issue!
I am a hobbyist programmer trying to integrate the SteamworksForPython API into a Python-based game. This API is a Python wrapper of the Steamworks API, which only officially supports C++. I am working on MacOS Sierra 10.12.6.
Blindly following the documentation, I have done the following:
I have downloaded the SteamworksForPython repo.
I have added the steam header directory from the Steamworks SDK (/sdk/public/steam) to that repo.
I have added to that repo the Steam API file appropriate to my operating system (in my case, libsteam_api.dylib from /sdk/redistributable_bin/osx32).
The next step listed in the documentation is to create a new dylib file. Unfortunately, the steps to do this haven't been described for MacOS yet.
Looking at the process for Linux and Windows, it seems like I need to create this dynamic library file using the repo's SteamworksPy.cpp file and the steam_api.h header file from the Steamworks SDK.
I have researched how to create a dylib file using Xcode and am currently trying to do it. The process seems similar to the one described by the documentation for Windows using Visual Studio.
I have done the following:
I have created a new Xcode project of type plain C++ dynamic library.
I have added SteamworksPy.cpp into the Compile Sources list.
I have added steam_api.h to the Headers list (under public, not private or project).
I have added libsteam_api.dylib to the Link Binary With Libraries section.
I am getting an error when I try to build, however. Here is a screenshot:
And here is a more explicit screenshot of the linker error:
After reading this, this, and this, I think the problem is that Xcode doesn't know where to look for the library I'm trying to link to, so I need to tell it where to look. This should be simple, but I can't manage to do it.
Can anyone give me advice on how to proceed?
Similar questions that were helpful, but didn't lead me to a solution:
How do I create a dynamic library (dylib) with Xcode?
Building and Using a DYLIB in Xcode
ld: library not found
ld: library not found for -lgsl
xcode library not found
I managed to solve this problem.
Xcode couldn't find the location of the library I was trying to link to.
I noticed that under Build Settings I could specify Path to Link Map File. I tried to hardcode the path to where my library (libsteam_api.dylib) resided, but I got the same error described above.
Then I did something that worked.
I deleted the reference to the library in the Link Binary With Libraries section.
Then I moved the library from its original location into my Xcode project directory.
Then I used the file selection pane in the Link Binary With Libraries section to reselect the library from the Xcode directory.
When I built, everything worked fine.
I'm in desperate need of a cross platform framework as I have vast numbers of .NET products that I'm trying to port to Linux. I have started to work with Python/pyQt and the standard library and all was going well until I try to import non-standard libraries. I'm hearing about pip and easy_install and I'm completely confused about this.
My products need to ship with everything required to execute them, so in the .NET world I simply package my DLLs (or licensed DLLs) with my product.
As a test bed I'm trying to import this library called requests: https://github.com/kennethreitz/requests
I've got an __init__.py file and the library source in my program directory but it isn't working. Please tell me that there is a simple way to include libraries without needing any kind of extra package installer.
I would suggest you start by familiarizing yourself with python packages (see the distutils docs. Pip is simply a manager that install packages directly from the internet repository, so that you don't need to manually go and download them. So for, example, as stated under "Installing" on the requests homepage, you simply run pip install requests in a terminal, without manually downloading anything.
Packaging your product is a different story, and the way you do it depends on the target system. On windows, the easiest might be to create an installer using NSIS which will install all dependencies. You might also want to use cx-freeze to pull all the dependencies (including the python interpreter) into a single package.
On linux, many of the dependencies will already be including in most distributions. so you should just list them as requirements when creating your package (e.g. deb for ubuntu). Other dependencies might not be included in the distro's repo, but you can still list them as requirements in setup.py.
I can't really comment on Mac, since I've never used python on one, but I think that it would be similar to the linux approach.