Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help
Special pages
SBGrid Resources
SBGrid Consortium
SBGrid Data Bank
Software Webinars
PyMOL Webinar
PyMOL Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Advanced Scripting
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
==== Setup.py ==== The setup file needs to know the following (at the very least): what source files comprise the project, what include directories to scan, the project name. You can also add more metadata such as version number, author, author_email, url, etc. For this example, let's assume we have the following directory structure, <source lang="bash"> . |-- build |-- dist |-- doc | `-- funName |-- src | |-- etc | | `-- tnt | | |-- doxygen | | | `-- html | | `-- html | `-- tnt </source> and we want to include all the ''.cpp'' files from the '''src''' directory, and all the include files in '''tnt'''. We start setup.py as follows, <source lang="python"> # # -- setup.py -- your module's install file # # import distutils from distutils.core import setup, Extension # for pasting together file lists from glob import glob # for handling path names in a os independent way from os.path import join; # grab all of the .h and .cpp files in src/ and src/tnt srcList = [ x for x in glob(join("src", "*.cpp")) ] # set the include directories incDirs = [ join( "src", "tnt") ] </source> Ok, now Python knows which files to include. Now we need to create a new [http://docs.python.org/dist/module-distutils.extension.html Extension]. We can simply call, <source lang="python"> # create the extension given the function name, ''funName,'' the souce list and include directories. ccealignMods = Extension( 'funName', sources=srcList, include_dirs=incDirs ) </source> Lastly, all we have to do is call the final setup function, with the extension we just created and some metadata (if we want): <source lang="python"> setup( name="funName", version="0.1-alpha", description="funName: A simple example to show users how to make C/C++ modules for PyMOL", author="Your Name Here", author_email="Your Email Goes Here", url="The URL of your work", ext_modules=[ccealignMods] ) </source> And voila -- we're done. The users should now be able to execute, <source lang="bash"> python setup.py build # remove the brackets if you need to be root to install, see [Linux_Install#Installing_a_Script_Without_Superuser_Access Installing PyMOL w/o Superuser access] for an example. [sudo] python setup.py install </source>
Summary:
Please note that all contributions to PyMOL Wiki are considered to be released under the GNU Free Documentation License 1.2 (see
PyMOL Wiki:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
Advanced Scripting
(section)
Add topic