Building a ctypes-“based” C library with distutils

The distutils documentation here states that: A C extension for CPython is a shared library (e.g. a .so file on Linux, .pyd on Windows), which exports an initialization function. So the only difference regarding a plain shared library seems to be the initialization function (besides a sensible file naming convention I don’t think you have … Read more

How can one fully replace distutils, which is deprecated in 3.10?

Yes setuptools can fully replace distutils for everything distutils.core.setup maps to setuptools.setup distutils.core.Extension maps to setuptools.Extension setuptools is not part of the standard library (hence its absence from the doc) but it is part of the standard python.org distribution. some distributions choose to separate setuptools and pip from the default python package because they don’t … Read more

What keyword arguments does setuptools.setup() accept?

setuptools.setup() calls distutils.core.setup() and passes it’s own **kwargs as the only parameter, so any keywords that distutils accepts will also be accepted by setuptools. If we go look at distutils setup_keywords = (‘distclass’, ‘script_name’, ‘script_args’, ‘options’, ‘name’, ‘version’, ‘author’, ‘author_email’, ‘maintainer’, ‘maintainer_email’, ‘url’, ‘license’, ‘description’, ‘long_description’, ‘keywords’, ‘platforms’, ‘classifiers’, ‘download_url’, ‘requires’, ‘provides’, ‘obsoletes’, ) Most … Read more

Finding a file in a Python module distribution [duplicate]

Try using pkg_resources, which is part of setuptools (and available on all of the pythons I have access to right now): >>> import pkg_resources >>> pkg_resources.resource_filename(__name__, “foo.config”) ‘foo.config’ >>> pkg_resources.resource_filename(‘tempfile’, “foo.config”) ‘/usr/lib/python2.4/foo.config’ There’s more discussion about using pkg_resources to get resources on the eggs page and the pkg_resources page. Also note, where possible it’s probably … Read more

How can I add post-install scripts to easy_install / setuptools / distutils?

It depends on how the user installs your package. If the user actually runs “setup.py install”, it’s fairly easy: Just add another subcommand to the install command (say, install_vim), whose run() method will copy the files you want in the places where you want them. You can add your subcommand to install.sub_commands, and pass the … Read more

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

1) Distributing libbig.so This is a problem that python isn’t going to help you with. Who are you targeting? If it’s linux, can you request that they install it with their package manager? If libbig isn’t distributed through a package manager or it’s not linux and you’re targeting multiple architectures, you might have to distribute … Read more

Execute a Python script post install using distutils / setuptools

The way to address these deficiences is: Get the full path to the Python interpreter executing setup.py from sys.executable. Classes inheriting from setuptools.Command (such as setuptools.command.install.install which we use here) implement the execute method, which executes a given function in a “safe way” i.e. respecting the dry-run flag. Note however that the –dry-run option is … Read more

Python setup.py: How to get find_packages() to identify packages in subdirectories

This is like using the src-layout for the “foo” and “bar” packages, but the flat layout for “baz”. It’s possible, but requires some custom configuration in the setup.py. Setuptools’ find_packages supports a “where” keyword (docs), you can use that. setup( … packages=( find_packages() + find_packages(where=”./bar-pack”) + find_packages(where=”./foo-pack”) ), … ) Since find_packages returns a plain … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)