distutils

“error: Unable to find vcvarsall.bat” when compiling Cython code

こ雲淡風輕ζ 提交于 2019-11-29 01:34:25
问题 As suggested here, I have succesfully installed Microsoft Visual C++ Compiler for Python 2.7 to compile some Cython code, but: from distutils.core import setup from Cython.Build import cythonize setup(ext_modules = cythonize("module1.pyx")) still produces: error: Unable to find vcvarsall.bat How to compile Cython code with Python 2.7 (for example on Windows 7 x64)? Note: I already carefully read the question error: Unable to find vcvarsall.bat but the main answers (including modifying

2 techniques for including files in a Python distribution: which is better?

天大地大妈咪最大 提交于 2019-11-29 01:19:57
问题 I'm working on packaging a small Python project as a zip or egg file so that it can be distributed. I've come across 2 ways to include the project's config files, both of which seem to produce identical results. Method 1: Include this code in setup.py: from distutils.core import setup setup(name='ProjectName', version='1.0', packages=['somePackage'], data_files = [('config', ['config\propFiles1.ini', 'config\propFiles2.ini', 'config\propFiles3.ini'])] ) Method 2: Include this code in setup.py

Finding a file in a Python module distribution

你。 提交于 2019-11-29 01:05:29
I've written a Python package that includes a bsddb database of pre-computed values for one of the more time-consuming computations. For simplicity, my setup script installs the database file in the same directory as the code which accesses the database (on Unix, something like /usr/lib/python2.5/site-packages/mypackage/). How do I store the final location of the database file so my code can access it? Right now, I'm using a hack based on the __file__ variable in the module which accesses the database: dbname = os.path.join(os.path.dirname(__file__), "database.dat") It works, but it seems...

Determining the location of distutils data files programmatically in Python

荒凉一梦 提交于 2019-11-28 23:37:12
I'm trying to include data files in distutils for my package and then refer to them using relative paths (following http://docs.python.org/distutils/setupscript.html#distutils-additional-files ) My dir structure is: myproject/ mycode.py data/ file1.dat the code in mycode.py , which is actually a script in the package. It relies on accessing data/file1.dat , refer to it using that relative path. In setup.py , I have: setup( ... scripts = "myproject/mycode.py" data_files = [('data', 'myproject/data/file1.dat')] ) suppose the user now uses: python setup.py --prefix=/home/user/ Then mycode.py will

Python packages installation in Windows

故事扮演 提交于 2019-11-28 23:25:48
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 as above, plus it takes care of any dependencies required, all fetched from PyPi Then there is also pip

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

僤鯓⒐⒋嵵緔 提交于 2019-11-28 22:19:22
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, Setuptools 0.6c11, Distribute 0.6.14. My setup config looks like: {'author': 'Jonathan Hartley', 'author

Distribute a Python package with a compiled dynamic shared library

送分小仙女□ 提交于 2019-11-28 21:31:42
How do I package a Python module together with a precompiled .so library? Specifically, how do I write setup.py so that when I do this in Python >>> import top_secret_wrapper It can easily find top_secret.so without having to set LD_LIBRARY_PATH ? In my module development environment, I have the following file structure: . ├── top_secret_wrapper │ ├── top_secret.so │ └── __init__.py └── setup.py Inside __init__.py , I have something like: import top_secret Here's my setup.py from setuptools import setup, Extension setup( name = 'top_secret_wrapper', version = '0.1', description = 'A Python

Speeding up build process with distutils

删除回忆录丶 提交于 2019-11-28 21:10:13
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 be the case or might I be doing something wrong here? In case it helps, here are some of the files

Can a Python package depend on a specific version control revision of another Python package?

本小妞迷上赌 提交于 2019-11-28 18:57:37
Some useful Python packages are broken on pypi, and the only acceptable version is a particular revision in a revision control system. Can that be expressed in setup.py e.g requires = 'svn://example.org/useful.package/trunk@1234' ? You need to do two things. First, require the exact version you want, e.g.: install_requires = "useful.package==1.9dev-r1234" and then include a dependency_links setting specifying where to find it: dependency_links = ["svn://example.org/useful.package/trunk@1234#egg=useful.package-1.9dev-r1234"] Note that the version #egg= part of the dependency_links URL must

pypi UserWarning: Unknown distribution option: 'install_requires'

主宰稳场 提交于 2019-11-28 16:55:48
问题 Does anybody encounter this warning when executing python setup.py install of a PyPI package? install_requires defines what the package requires. A lot of PyPI packages have this option. How can it be an "unknown distribution option"? 回答1: python setup.py uses distutils which doesn't support install_requires. setuptools does, also distribute (its successor), and pip (which uses either) do. But you actually have to use them. I.e. call setuptools through the easy_install command or pip install