distutils

How do I distribute fonts with my python package?

人走茶凉 提交于 2019-12-05 04:03:16
问题 I have created a package called clearplot that wraps around matplotlib. I have also created a nice font that I want to distribute with my package. I consulted this section of the Python Packaging User guide, and determined that I should use the data_files keyword. I chose data_files instead of package_data since I need to install the font in a matplotlib directory that is outside of my package. Here is my first, flawed, attempt at a setup.py file: from distutils.core import setup import os,

Directly call distutils' or setuptools' setup() function with command name/options, without parsing the command line?

假如想象 提交于 2019-12-05 02:58:37
I'd like to call Python's distutils' or setuptools' setup() function in a slightly unconventional way, but I'm not sure whether distutils is meant for this kind of usage. As an example, let's say I currently have a 'setup.py' file, which looks like this (lifted verbatim from the distutils docs--the setuptools usage is almost identical): from distutils.core import setup setup(name='Distutils', version='1.0', description='Python Distribution Utilities', author='Greg Ward', author_email='gward@python.net', url='http://www.python.org/sigs/distutils-sig/', packages=['distutils', 'distutils.command'

Get the commands distutils passes to the compiler

落爺英雄遲暮 提交于 2019-12-05 01:19:53
Lets say I have this Python code in a setup.py script to build a C extension: from distutils.core import setup, Extension module1 = Extension('demo', sources = ['demo.c']) setup (name = 'PackageName', version = '1.0', description = 'This is a demo package', ext_modules = [module1]) Easy enough. Now I call the setup.py script with this line: C:/> python setup.py build_ext --compiler=mingw32 Ok, but whats the question? When distutils calls mingw32 and passes all the necessary and operating system independant flags and options to it, how does it figure those flags out? Where does distutils keep

Building Python extension module with distutils

拥有回忆 提交于 2019-12-05 01:18:09
问题 I'm using distutils to build a Python extension module written in C++. The problem I have is that in order to compile the extension module, I need to link with a certain shared library. This requires setting an additional compiler flag. So, I searched through the Python docs and found out about the extra_compile_args property of the Extension object. So I tried the following: from distutils.core import setup, Extension module = Extension('test', sources = ['test.cpp']) module.extra_compile

How does `setup.py sdist` work?

强颜欢笑 提交于 2019-12-04 18:09:46
问题 I'm trying to make a source distribution of my project with setup.py sdist . I already have a functioning setup.py that I can install with. But when I do the sdist , all I get is another my_project folder inside my my_project folder, a MANIFEST file I have no interest in, and a zip file which contains two text files, and not my project. What am I doing wrong? Where is the documentation on sdist ? Update: Here's my setup.py : #!/usr/bin/env python import os from distutils.core import setup

How to create namespace packages in Python?

心不动则不痛 提交于 2019-12-04 16:33:14
I have a Python 3 project with the following structure: project/ | +--root/ | +--__init__.py | +--sub/ | +--__init__.py | +--actualcode.py I want to use "namespace packages" so that my lib shares a common namespace with other related libs in separate projects. The import statement should look like this: from root.sub.actualcode import something The __init__.py file in the root folder contains the following statement to create a namespace package: from pkgutil import extend_path __path__ = extend_path(__path__, __name__) But I cannot reference the code when I import root.sub . It works only

Automate compilation of protobuf specs into python classes in setup.py

不想你离开。 提交于 2019-12-04 12:55:58
I have a python project that uses google protobufs as a message format for communicating over the network. Generating python files from the .proto files is straight-forward using the protoc program. How can I configure my setup.py file for the project so that it automatically calls the protoc command? In a similar situation, I ended up with this code (setup.py, but written in a way to allow extraction into some external Python module for reuse). Note that I took the generate_proto function and several ideas from the setup.py file of the protobuf source distribution. from __future__ import

Python distutils error: “[directory]… doesn't exist or not a regular file”

我是研究僧i 提交于 2019-12-04 08:54:11
问题 Let's take the following project layout: $ ls -R . .: package setup.py ./package: __init__.py dir file.dat module.py ./package/dir: tool1.dat tool2.dat And the following content for setup.py : $ cat setup.py from distutils.core import setup setup(name='pyproj', version='0.1', packages=[ 'package', ], package_data={ 'package': [ '*', 'dir/*', ], }, ) As you can see, I want to include all non-Python files in package/ and package/dir/ directories. However, running setup.py install would raise

Python 3.4: compile cython module for 64-bit windows

隐身守侯 提交于 2019-12-04 08:34:39
问题 I have a .pyx module that I've been trying to compile for use with 64-bit python 3.4 on Windows through various means but with no success. After a lot of trial and error, it does compile with python setup.py build_ext --inplace --compiler=mingw32 but of course, that won't work with 64-bit python. With msvc as the compiler, the error is File "C:\Python34\lib\distutils\msvc9compiler.py", line 287, in query_vcvarsall raise ValueError(str(list(result.keys()))) ValueError: ['path'] Windows 7

How to add PyPi dependencies to DEB package

狂风中的少年 提交于 2019-12-04 07:39:57
I created some python app using autobahn and packaged it using baazar builddeb . In python setup.py file I added requires tag with all the required dependencies. Is it possible to tell debian package installer to install these packages? I added some of deps to debian/control>Depends but: dpkg -i my_package does not install dependencies. Just shows the error and I need to install these deps manually. some packages does not exists in standard Ubuntu repos. For example autobahn. And in general I'd like to have installed all python dependencies by pip/easy_install I am using DistUtilsExtra.auto