distutils

Python Daemon Packaging Best Practices

人走茶凉 提交于 2019-12-02 16:47:38
I have a tool which I have written in python and generally should be run as a daemon. What are the best practices for packaging this tool for distribution, particularly how should settings files and the daemon executable/script be handled? Relatedly are there any common tools for setting up the daemon for running on boot as appropriate for the given platform (i.e. init scripts on linux, services on windows, launchd on os x)? To answer one part of your question, there are no tools I know of that will do daemon setup portably even across Linux systems let alone Windows or Mac OS X. Most Linux

Distributing a shared library and some C code with a Cython extension module

寵の児 提交于 2019-12-02 16:37:38
I'm trying to take some functions from a large C++ shared library (libbig.so) and expose them to Python via Cython. To do so, I've got a little C++ file (small.cpp) that provides a thin wrapper around the functionality from the shared library that I need, in a way that makes it easy to call via Cython (pysmall.pyx). libbig.so -> small.cpp, small.h -> libsmall.so -> pysmall.pyx -> pysmall.cpp -> pysmall.so I can build and run this extension module on my own computer: I just compile small.cpp into libsmall.so, and then say "libraries=['small']" in the Extension object in setup.py to build the

What is the proper way to work with shared modules in Python development?

浪子不回头ぞ 提交于 2019-12-02 16:33:59
I'm working toward adopting Python as part of my team's development tool suite. With the other languages/tools we use, we develop many reusable functions and classes that are specific to the work we do. This standardizes the way we do things and saves a lot of wheel re-inventing. I can't seem to find any examples of how this is usually handled with Python. Right now I have a development folder on a local drive, with multiple project folders below that, and an additional "common" folder containing packages and modules with re-usable classes and functions. These "common" modules are imported by

How can I run a Makefile in setup.py?

夙愿已清 提交于 2019-12-02 15:48:44
I need to compile ICU using it's own build mechanism. Therefore the question: How can I run a Makefile from setup.py ? Obviously, I only want it to run during the build process, not while installing. Walter The method I normally use is to override the command in question: from distutils.command.install import install as DistutilsInstall class MyInstall(DistutilsInstall): def run(self): do_pre_install_stuff() DistutilsInstall.run(self) do_post_install_stuff() ... setup(..., cmdclass={'install': MyInstall}, ...) This took me quite a while to figure out from the distutils documentation and source

What's the minimal directory structure to make setuptools work with one_file.py?

南笙酒味 提交于 2019-12-02 08:46:04
问题 one_file.py contains some general functions, classes, and a main() . I'd like to make it pip installable with a command line script that calls the main() function. What's a directory structure and setup.py that will do this? 回答1: You can get away with this with just a setup.py and your module--no additional directories. In your setup.py just use setup(..., py_modules=['one_file'], ...) (you might want to check on the exact spelling). To install the script you can use the console_scripts entry

How do I require Tkinter with distutils?

允我心安 提交于 2019-12-02 06:25:59
问题 I'm trying to compile a program using distutils but I want to make sure that the user has Tkinter installed before installing my package. My Google searches have failed to turn up any useful info, any clue how I'd do this? Thanks, Wayne 回答1: You can have a class that inherits from install and then do this: from distutils.command.install import install class Install(install): def run(self): if not check_dependencies(): # Tkinter was not installed, handle this here install.run(self) # proceed

What's the minimal directory structure to make setuptools work with one_file.py?

梦想的初衷 提交于 2019-12-02 06:20:12
one_file.py contains some general functions, classes, and a main() . I'd like to make it pip installable with a command line script that calls the main() function. What's a directory structure and setup.py that will do this? You can get away with this with just a setup.py and your module--no additional directories. In your setup.py just use setup(..., py_modules=['one_file'], ...) (you might want to check on the exact spelling). To install the script you can use the console_scripts entry-point: from setuptools import setup setup( name='one-file', version='1.0', py_modules=['one_file'], entry

How do I require Tkinter with distutils?

大兔子大兔子 提交于 2019-12-02 01:32:27
I'm trying to compile a program using distutils but I want to make sure that the user has Tkinter installed before installing my package. My Google searches have failed to turn up any useful info, any clue how I'd do this? Thanks, Wayne You can have a class that inherits from install and then do this: from distutils.command.install import install class Install(install): def run(self): if not check_dependencies(): # Tkinter was not installed, handle this here install.run(self) # proceed with the installation def check_dependencies(): try: return __import__('Tkinter') except ImportError: return

Creating swig wrapper for C++ (pointers) to python

好久不见. 提交于 2019-12-02 00:18:13
问题 I a very new to swig and I am trying to create a swig wrapper in order to use a few C++ files in python. I have the following C++ class. The following is a snippet of the code that I am trying to convert: /*packet_buffer.h*/ class CPacketBuffer { public: // construct based on given buffer, data is not copied CPacketBuffer(uint8_t* data, uint32_t length) { mpBuffer = data; mLength = length; mHead = 0; mTail = length; } uint8_t* GetBuffer() { return (mpBuffer + mHead); } void Add(const uint8_t*

Creating swig wrapper for C++ (pointers) to python

落花浮王杯 提交于 2019-12-01 20:22:44
I a very new to swig and I am trying to create a swig wrapper in order to use a few C++ files in python. I have the following C++ class. The following is a snippet of the code that I am trying to convert: /*packet_buffer.h*/ class CPacketBuffer { public: // construct based on given buffer, data is not copied CPacketBuffer(uint8_t* data, uint32_t length) { mpBuffer = data; mLength = length; mHead = 0; mTail = length; } uint8_t* GetBuffer() { return (mpBuffer + mHead); } void Add(const uint8_t* data, uint32_t length) { if ((mTail + length) > mLength) { length = (mLength - mTail); } //.... } I