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.
Related
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.
VTK library cannot be installed via pip.
Though, it can be compiled and installed from sources.
My Python project depends on VTK.
I want it to install VTK automatically by calling pip install . from root directory of the project.
In this case setup.py file should be able to
download VTK sources of needed version from GitHub
call cmake in order to prepare build
compile sources and create Python bindings
install needed files into currently used site-packages (e. g., it should not be installed into /usr/local/lib/python3/site-packages if I use virtualenv, pipenv or pyenv)
Is it possible?
If yes, how can I do this?
In principle, you can include any executable code in the setup file. However, nowhere in the setuptools documentation could I find information that would solve the problem here.
Also, the installation procedure for vtk is a bit complex which is why kitware uses cmake in the first place.
So, the short answer would be "no" or "don't do that".
Further, the problems you will encounter:
Users will expect a transparent install. But achieving a cross-platform build process on the basis of the cmake build instructions for vtk will prevent you from setting the customization (path to vtk, path to the Python interpreter, platform-specific C flags).
The install process will be harder to debug. Users will come to you for VTK build problems.
Kitware themselve do not propose vtk on pypi. This suggests that it is too much time intensive, impossible or too fragile to maintain to achieve this goal.
If you wish to see a popular Python project that relies on vtk, there is mayavi. The installation instructions request to install vtk beforehand.
Looks like VTK has presented their official binding via pypi, so I can use it in setup.py file simply by appending it to install_requires list.
Works well in my project, doesn't need compilation anymore.
Though, there is a caution in the mayavi documentation
The latest VTK wheels are available on all the major platforms
(Windows, MacOS, and Linux), but only for 64 bit machines. Python 3.x
is fully supported on all these operating systems and Python 2.7.x on
MacOS and Linux. If you are out of luck, and your platform is not
supported then you will need to install VTK yourself using your
particular distribution as discussed in the General Build and
Installation instructions
I am packaging a python application that depends on several C libraries through gobject introspection. I would like to make sure that, at least, the python module from the glib is installed (that is the gi module, packaged as python-gi in Debian, I am not talking about the deprecated PyGObject module). Adding it as a regular dependency makes the install fail, since it is not in Pypi.
How should I declare this ? I looked a setuptool doc and nothing I see quite does the trick.
Thanks.
Related question:
Bundling GTK3+ with py2exe
You cannot specify non-Python dependencies using setuptools (AFAIK, that is ...).
The install_requires keywords to setuptools.setup can specify Python-style dependencies only; it targets the Python packaging infrastructure. Python-style installer programs (either pip, easy_install or python setup.py install) will resolve such dependencies using strategies to find and resolve Python-style packages only. One of those strategies is using a package index like PyPI.
If you want to create a package that has Debian-style dependencies, which are resolved by Debian-style installers, using Debian package repos, you have to create a Debian package. There are tools that support creating Debian packages from Python projects, for example easydeb and stdeb. However, most people recommend going the extra-mile and explicitly create a Debian package.
In the general case, packaging for and distributing Python projects via PyPI should be the way to go. It's platform and distro independent, and plays nicely with Python-specific installers like pip and tools like virtualenv or buildout. Having a dependency to PyGI would involve documenting the fact to users, like e.g. the pydbus packages does in its README:
It’s based on PyGI, the Python GObject Introspection bindings, which
is the recommended way to use GLib from Python. Unfortunately, PyGI is
not packaged on pypi, so you need to install it from your
distribution’s repository (usually called python-gi, python-gobject or
pygobject3).
Your project could also be defensive when importing from PyGI, presenting users a digestible error message like "please sudo apt-get install python-gi" or so, when the import fails.
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.
I noticed that Twisted has a dependency on Zope. I found that when I tried to install Zope, after running, ./configure it tells me I need to use python2.4 (not python 2.5+ which I would like to be using).
However, I have seen some tutorials and guides that suggested using python 2.5 for Twisted. So I'm just generally confused. Has anyone set this up and ran some of the twsited web examples that use zope? What version of python did you use? Was there an installation guide you followed somewhere?
Twisted doesn't have a dependency on full zope. It's just zope.interface, which is a small pure-python module packaged separately from all zope.
You can download the .tar.gz version and run the usual python setup.py install, that should work. Or if your operational system includes a package management system, you could check it for a easy-to-install package. Example, in debian/ubuntu you could do:
apt-get install python-zopeinterface
or even
apt-get install python-twisted
directly.
If you install twisted with pip install or easy_install it will download and install zope.install for you as well.