distutils

How do I write a setup.py for a twistd/twisted plugin that works with setuptools, distribute, etc?

人盡茶涼 提交于 2019-11-28 16:29:13
问题 The Twisted Plugin System is the preferred way to write extensible twisted applications. However, due to the way the plugin system is structured (plugins go into a twisted/plugins directory which should not be a Python package), writing a proper setup.py for installing those plugins appears to be non-trivial. I've seen some attempts that add 'twisted.plugins' to the 'packages' key of the distutils setup command, but since it is not really a package, bad things happen (for example, an __init__

setuptools vs. distutils: why is distutils still a thing?

旧街凉风 提交于 2019-11-28 13:46:32
问题 Python has a confusing history of tools that can be used to package and describe projects: these include distutils in the Standard Library, distribute , distutils2 , and setuptools (and maybe more). It appears that distribute and distutils2 were discontinued in favor of setuptools , which leaves two competing standards. To my understanding setuptools offers far more options (e.g. declaring dependencies, tests, etc.) than distutils , however it is not included in the Python standard library

python distutils does not include data_files

时光毁灭记忆、已成空白 提交于 2019-11-28 11:55:50
I am new to distutils.. I am trying to include few data files along with the package.. here is my code.. from distutils.core import setup setup(name='Scrapper', version='1.0', description='Scrapper', packages=['app', 'db', 'model', 'util'], data_files=[('app', ['app/scrapper.db'])] ) The zip file created after executing python setup.py sdist does not include the scrapper.db file. I have scrapper.db file in the app directory.. thanks for the help. Carl Meyer You probably need to add a MANIFEST.in file containing "include app/scrapper.db" . It's a bug in distutils that makes this necessary:

Is it possible to express a platform-specific dependency in setup.py without building platform-specific versions of my egg?

最后都变了- 提交于 2019-11-28 09:45:32
We have a placeholder egg that contains no code and only exists for the sake of pulling down a list of dependent packages from our PyPi repository. Most of these dependent packages are platform-agnostic, however some are only used on Win32 platforms. Is it possible to somehow make the dependency platform-conditional, so that a given dependency in my install_requires list will only get pulled down when installing on Win32? Alternatively: Is it possible to specify a list of optional dependencies, that will be installed if available, but will not cause easy_install to fail if they are not? For

Hook to add commands to distutils build?

若如初见. 提交于 2019-11-28 09:13:47
I've added a custom distutils command to a setup.py script: from distutils.command.build_py import build_py cmdclass = {} cmdclass['build_qt'] = BuildQt cmdclass['build_py'] = build_py setup(..., cmdclass=cmdclass, ...) Is there a way to make it so that when running:: python setup.py build this first calls python setup.py build_qt automatically? You can override build : from distutils.command.build import build class my_build(build): def run(self): self.run_command("build_qt") build.run(self) cmdclass['build'] = my_build In order to add your own command, you can subclass the default build

What parts of a virtualenv need to be changed to relocate it? [duplicate]

耗尽温柔 提交于 2019-11-28 08:26:32
This question already has an answer here: Renaming a virtualenv folder without breaking it 8 answers So, I've got a Python program with a ridiculous number of addons/packages. I'd like to be able to distribute the program in its virtualenv, so that the packages come bundled. However, the program is for Windows, and the "relocatable" feature of virtualenvs is unsupported on Windows (as well as still being experimental). So, I'm looking at either writing a script, or just writing instructions to manually change absolute path names to relocate the virtualenv. My question is if anybody knows where

Changing console_script entry point interpreter for packaging

て烟熏妆下的殇ゞ 提交于 2019-11-28 07:43:19
I'm packaging some python packages using a well known third party packaging system, and I'm encountering an issue with the way entry points are created. When I install an entry point on my machine, the entry point will contain a shebang pointed at whatever python interpreter, like so: in /home/me/development/test/setup.py from setuptools import setup setup( entry_points={ "console_scripts": [ 'some-entry-point = test:main', ] } ) in /home/me/.virtualenvs/test/bin/some-entry-point : #!/home/me/.virtualenvs/test/bin/python # EASY-INSTALL-ENTRY-SCRIPT: 'test==1.0.0','console_scripts','some-entry

How to build a Python C Extension so I can import it from a module

岁酱吖の 提交于 2019-11-28 06:27:19
I have a Python project with many sub-modules that I package up with distutils. I would like to build some Python extensions in C to live in some of these sub-modules but I don't understand how to get the Python extension to live in a submodule. What follows is the simplest example of what I'm looking for: Here is my Python extension c_extension.c : #include <Python.h> static PyObject * get_answer(PyObject *self, PyObject *args) { return Py_BuildValue("i", 42); } static PyMethodDef Methods[] = { {"get_answer", get_answer, METH_VARARGS, "The meaning of life."}, {NULL, NULL, 0, NULL} };

Cleaning build directory in setup.py

ⅰ亾dé卋堺 提交于 2019-11-28 06:11:54
How could I make my setup.py pre-delete and post-delete the build directory? For pre-deletion, just delete it with distutils.dir_util.remove_tree before calling setup. For post-delete, I assume you only want to post-delete after selected commands. Subclass the respective command, override its run method (to invoke remove_tree after calling the base run), and pass the new command into the cmdclass dictionary of setup. Matt Ball Does this answer it? IIRC, you'll need to use the --all flag to get rid of stuff outside of build/lib : python setup.py clean --all This clears the build directory

How to include third party Python packages in Sublime Text 2 plugins

自闭症网瘾萝莉.ら 提交于 2019-11-28 04:31:54
I'm writing a sublime text 2 plugin that uses a module SEAPI.py which in itself imports the requests module . Since sublime text 2 uses it's own embedded python interpreter, it doesn't see the requests module installed in my ubuntu machine (I get the following error: ImportError: No module named requests). Best solution I could find so far was to copy the 'requests' module (the whole directory of files) from /usr/lib/python2.7/dist-packages/requests into my plugin directory in the sublime text packages dir. But after that, it says that it can't find the 'urllib3' module. Is there a better way