How to package dependencies with a Python application? - python

I have a Python application that I'm distributing with the standard setup.py. I need to package the dependencies too because the audience I'm distributing do not have network access. I have downloaded the packages from PyPi but am stuck where to place them so when someone does "python setup.py install", they will get installed.
Any ideas?
EDIT: Forgot to mention, I'm trying to achieve this on a Unix platform and without using other tools such as pip.

Related

How can I add to my python wheel package an external required software?

We are packaging a bioinformatics project that uses samtools so we can upload it to PyPI.
In setup.py there are options to add python packages OS specification, but is there a way to require a general program?
Alternatively, it can be sufficient to query conda or venv for such installation.
(Potentially I'm mixing up terms, edits are welcome)

Lambda package includes pip, setuptools

I followed the AWS guide to prepare a deployment package for my lambda function. The generated zip file is around 9 - 10MB which includes pip, setuptools, pylint. Are they really required?
Here are the commands.
virtualenv v-env
source v-env/bin/activate
pip install xmltodict
pip install requests
deactivate
cd v-env/lib/python3.7/site-packages/
zip -r9 ../../../../function.zip .
Edit: Remove installing boto as it is provided by AWS already
Well, as you may see the guides provide standars and, obviously, guidance for a clean and nice coding or project deployment.
Pylint has a lot of features that help you out while using Python as your programming language, such as checking coding standars, error detection, refactoring help in order to prevend duplicated code, among other tools.
Setuptools is really useful too. Is a development process library designed to facilitate packaging Python projects by enhancing the Python standard library distribution utilities, I encourage you to use it in order to wrap your processes and models in order to have a strong modular project.
And pip is a Package Manager for python packages or modules. You can add, download, delete and a lot more things with it by simple using few words on a line of code. This package manager is useful, you can download wheels, zip's and modules from the internet and easily install them by just using
pip install <module or library name>
So, by answering your question, if you downloaded and installed a package for AWS supported in Python and it installed those libraries I must think those are being used across the modules you want to use.
You can always check the source code in order to be sure.
If the libraries aren't really being used, they aren't necessary since there are several libraries and packages that do what those libraries do.
Hope it helps, happy coding.

Can setuptools install dependencies when packaging as .exe?

I'm an author of a pure Python library that aims to be also convenient to use from a command line. For Windows users it would be nice just installing the package from an .exe or .msi package.
However I cannot get the installer to install package dependencies (especially the dependency on setuptools itself, so that running the software fails with an import error on pkg_resources). I don't believe that providing an easy .exe installer makes much sense, if the user then needs to manually install setuptools and other libraries on top. I'd rather tell them how to add easy_install to their PATH and go through this way (http://stackoverflow.com/questions/1449494/how-do-i-install-python-packages-on-windows).
I've build .exe packages in the past, but don't remember if that ever worked the way I'd preferred it to.
It is quite common to distribute packages that have dependencies, especially those as you have, but I understand your wish to make installation as simple as possible.
Have a look at deployment bootstrapper, a tool dedicated to solving the problem of delivering software including its prerequisites.
Regardless of what packaging method you eventually choose, maintain your sanity by staying away from including MSIs in other MSI in any way. That just does not work because of transactional installation requirements and locking of the Windows Installer database.

setup.py and source control repository

I am about to build a new python lib and I was seeking information concerning packaging in Python.
I understand that "setup.py" is the script that controls everything. I wonder how to deal with it when there are external libraries in svn for instance.
How to download automatically a given version from the repository using "setup.py" ?
docs for this are at the cheese shop
use the requires keyword
I may not have understood the problem correctly.
For any additional dependencies, you mention them in setup.py as
install_requires=['module1 >= 1.3', 'module2 >=1.8.2']
When you use setuptools, easy_install oo pip, these external dependencies will get installed during setup, if required. These should also be available in package repositories for download.

Packaging a Jython Library

I have a Python library I've written that interfaces with a Java application. Note that this is specifically a library for other developers to use, there is no main() involved. I've found plenty of information on packaging Jython web applications into jars to be deployed on application servers, but I can't seem to find anything on packaging a library to be installed for others to use.
This is a pretty simple scenario of a single package with 4 modules. Effectively what I'm looking for is the standard CPython methodology of having a setup.py using distutils and running:
python setup.py sdist
How can I accomplish the same via Jython?
If it matters:
jython --version
Jython 2.2.1 on java1.6.0_20
There is an implementation of disutils in jython but it doesn't work for me. For now you might have to write a script to copy your python files into jython/Lib/site-packages, which I don't think will be too hard if you're just installing python source, see shutil.copytree.
it's strongly recommend to use virtualenv so you can get most up-to-date setuptools and other utils by pip.
I also suggest you to take a look at jip, which will help you to define java dependencies in setup.py. The dependencies will be resolved automatically when user install your module with:
pip install ...
or
jython setup.py install
Please upgrade to jython 2.5.x to run it.

Categories

Resources