How to force a python wheel to be platform specific when building it?

Here’s the code that I usually look at from uwsgi The basic approach is: setup.py # … try: from wheel.bdist_wheel import bdist_wheel as _bdist_wheel class bdist_wheel(_bdist_wheel): def finalize_options(self): _bdist_wheel.finalize_options(self) self.root_is_pure = False except ImportError: bdist_wheel = None setup( # … cmdclass={‘bdist_wheel’: bdist_wheel}, ) The root_is_pure bit tells the wheel machinery to build a non-purelib (pyX-none-any) … Read more

How may I override the compiler (GCC) flags that setup.py uses by default?

Prepend CFLAGS=”-O0″ before you run setup.py: % CFLAGS=”-O0″ python ./setup.py The -O0 will be appended to CFLAGS while compiling, therefore will override previous -O2 setting. Another way is add -O0 to extra_compile_args in setup.py: moduleA = Extension(‘moduleA’, ….., include_dirs = [‘/usr/include’, ‘/usr/local/include’], extra_compile_args = [“-O0”], ) If you want to remove all default flags, use: … Read more

Src layout to dispense .src prefix in imports? Activate venv in PyCharm terminal for development installs

Update / Workaround One can follow the steps in this link to mark a folder as a source root. From the link: Source roots the Source root icon contain the actual source files and resources. PyCharm uses the source roots as the starting point for resolving imports This way we don’t have to install It … Read more

Python 3: ImportError “No Module named Setuptools”

Your setup.py file needs setuptools. Some Python packages used to use distutils for distribution, but most now use setuptools, a more complete package. Here is a question about the differences between them. To install setuptools on Debian: sudo apt-get install python3-setuptools For an older version of Python (Python 2.x): sudo apt-get install python-setuptools

python setup.py uninstall

Note: Avoid using python setup.py install use pip install . You need to remove all files manually, and also undo any other stuff that installation did manually. If you don’t know the list of all files, you can reinstall it with the –record option, and take a look at the list this produces. To record … Read more

What is setup.py?

setup.py is a python file, the presence of which is an indication that the module/package you are about to install has likely been packaged and distributed with Distutils, which is the standard for distributing Python Modules. This allows you to easily install Python packages. Often it’s enough to write: $ pip install . pip will … Read more