distutils

Managing resources in a Python project

纵然是瞬间 提交于 2019-11-27 17:42:16
I have a Python project in which I am using many non-code files. Currently these are all images, but I might use other kinds of files in the future. What would be a good scheme for storing and referencing these files? I considered just making a folder "resources" in the main directory, but there is a problem; Some images are used from within sub-packages of my project. Storing these images that way would lead to coupling, which is a disadvantage. Also, I need a way to access these files which is independent on what my current directory is. You may want to use pkg_resources library that comes

Python distutils, how to get a compiler that is going to be used?

守給你的承諾、 提交于 2019-11-27 17:37:23
For example, I may use python setup.py build --compiler=msvc or python setup.py build --compiler=mingw32 or just python setup.py build , in which case the default compiler (say, bcpp ) will be used. How can I get the compiler name inside my setup.py (e. g. msvc , mingw32 and bcpp , respectively)? UPD.: I don't need the default compiler, I need the one that is actually going to be used, which is not necessarily the default one. So far I haven't found a better way than to parse sys.argv to see if there's a --compiler... string there. This is an expanded version of Luper Rouch's answer that

Python distutils not using correct version of gcc

若如初见. 提交于 2019-11-27 16:42:35
问题 I am trying to compile a package on Mac OSX 10.6.5. The package's install script relies on distutils. The problem is that the computer's default gcc is version 4.2 (I determined this by just running gcc --version in a terminal window) but when I run 'python setup.py build', I see from the output that the distutils is choosing gcc-4.0 instead of 4.2 This is a big problem because the code I am using require gcc >= 4.2. I do not have admin rights on this machine, so as a workaroud, I created

Python packages installation in Windows

穿精又带淫゛_ 提交于 2019-11-27 14:58:44
问题 I recently began learning Python, and I am a bit confused about how packages are distributed and installed. I understand that the official way of installing packages is distutils : you download the source tarball, unpack it, and run: python setup.py install , then the module will automagically install itself I also know about setuptools which comes with easy_install helper script. It uses eggs for distribution, and from what I understand, is built on top of distutils and does the same thing

Why does “python setup.py sdist” create unwanted “PROJECT-egg.info” in project root directory?

*爱你&永不变心* 提交于 2019-11-27 14:17:53
问题 When I run python setup.py sdist it creates an sdist in my ./dist directory. This includes a "PROJECT-egg.info" file in the zip inside my "dist" folder, which I don't use, but it doesn't hurt me, so I just ignore it. My question is why does it also create a "PROJECT-egg.info" folder in my project root directory? Can I make it stop creating this? If not, can I just delete it immediately after creating the sdist? I'm using the 'setup' function imported from setuptools. WindowsXP, Python2.7,

Speeding up build process with distutils

陌路散爱 提交于 2019-11-27 13:34:11
问题 I am programming a C++ extension for Python and I am using distutils to compile the project. As the project grows, rebuilding it takes longer and longer. Is there a way to speed up the build process? I read that parallel builds (as with make -j ) are not possible with distutils. Are there any good alternatives to distutils which might be faster? I also noticed that it's recompiling all object files every time I call python setup.py build , even when I only changed one source file. Should this

Using setuptools to create a cython package calling an external C library

梦想与她 提交于 2019-11-27 12:19:31
问题 I am trying to compile, install and run a package that we'll call myPackage . It contains a *.pyx file that calls the function fftw_set_timelimit() from library fftw . Currently, when I run a script clientScript.py that imports the package I obtain the following error message : Traceback (most recent call last): File "clientScript.py", line 5, in <module> import myPackage.myModule ImportError: /usr/local/lib/python2.7/dist-packages/myPackage/myModule.so: undefined symbol: fftw_set_timelimit

How to copy directory recursively in python and overwrite all?

扶醉桌前 提交于 2019-11-27 11:18:13
I'm trying to copy /home/myUser/dir1/ and all its contents (and their contents, etc.) to /home/myuser/dir2/ in python. Furthermore, I want the copy to overwrite everything in dir2/ . It looks like distutils.dir_util.copy_tree might be the right tool for the job, but not sure if there's anything easier/more obvious to use for such a simple task. If it is the right tool, how do I use it? According to the docs there are 8 parameters that it takes. Do I have to pass all 8 are just src , dst and update , and if so, how (I'm brand new to Python). If there's something out there that's better, can

distutils: How to pass a user defined parameter to setup.py?

拥有回忆 提交于 2019-11-27 11:01:00
Please prompt me how to pass a user-defined parameter both from the command line and setup.cfg configuration file to distutils' setup.py script. I want to write a setup.py script, which accepts my package specific parameters. For example: python setup.py install -foo myfoo Thank you, Mher Cerin As Setuptools/Distuils are horribly documented, I had problems finding the answer to this myself. But eventually I stumbled across this example. Also, this similar question was helpful. Basically, a custom command with an option would look like: from distutils.core import setup, Command class

Combine --user with --prefix error with setup.py install

China☆狼群 提交于 2019-11-27 10:28:52
I was trying to install Python packages a system I recently gained access to. I was trying to take advantage of Python's relatively new per user site-packages directory , and the new option --user . (The option is currently undocumented , however it exists for Python 2.6+; you can see the help by running python setup.py install --help .) When I tried running python setup.py install --user on any package I downloaded, I always got the following error: error: can't combine user with with prefix/exec_prefix/home or install_(plat)base The error was extremely perplexing because, as you can see, I