WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: making python package extensions  (Read 124 times)

Offline JustinCB

  • WikiUser
  • *
  • Posts: 17
making python package extensions
« on: September 27, 2017, 06:50:54 AM »
Making python extensions isn't particularly difficult, but there are a few tricks to doing it(these steps are made to be used with the creating extensions wiki page):
  • use tce-load to load python and python-setuptools.  You might also need compiletc.  You will also need squashfs-tools , submitqc , and the other tools used for creating extensions.
  • run python setup.py build
  • run sudo python setup.py install This is very verbose.  If it said it was installing anything into a directory other than /usr/local/lib/python2.7/site-packages/, make a note of that.  You will need those paths later.
  • Replace package-name with the name of the package.  do mkdir -p /tmp/package-name/usr/local/lib/python2.7/stie-packages If the installer installed files to additional directories, make them under /tmp/package-name/.  For example if the package installed package-program to /usr/local/bin/, you will need to do mkdir -p /tmp/package-name/usr/local/bin/.
  • Copy the package files. You can do ls /usr/local/lib/python2.7/site-packages/, and see what files there are there that have package-name in their filenames.  you will need to do cp /usr/local/lib/python2.7/site-packages/package-file-name.ext /tmp/package-name/usr/local/lib/python2.7/site-packages/ for each of them.  If things were installed to different directories you will need to install them there, for example if it had /usr/local/bin/package-program, you would do cp /usr/local/bin/package-program /tmp/package-name/usr/local/bin/.
  • run less /usr/local/lib/python2.7/site-packages/easy-install.pth.  If any of the lines has a filename with package-name in it, you will need to copy that line and use it.
  • If it added a line in /usr/local/lib/python2.7/site-packages/easy-install.pth, you will need to make a startup script to do that when it loads itself.  do mkdir -p /tmp/package-name/usr/local/tce.installed. Then do vi /tmp/package-name/usr/local/tce.installed/package-name.  You will need to make the file like this:

    echo '<easy-install.pth_line>' >> /usr/local/lib/python2.7/site-packages/easy-install.pth

    replace <easy-install.pth_line> with the line you copied from easy-install.pth.
  • if the package you were compiling had a LICENSE, COPYING, or other similar file, you can do mkdir -p /tmp/package-name/usr/local/share/package-name/, than copy the file to it.  Note that you still have to mention what license it is in the .tcz.info file(possibly with a note to see /usr/local/share/package-name/COPYING, with COPYING being whatever the name of the license file is.
  • Do steps 4-7 in the wiki guide.