I have written a python package I'm trying to install. With a structure:
packagename
|
|--- setup.py
|--- module_name
|
|--- library.c
The library.c file has been successfully installed outside of this package using:
gcc library.c -Wall -pedantic -o spec_conv -lm -O2
My setup.py file looks like:
from setuptools import setup, Extension
with open("README.md", "r") as fh:
long_description = fh.read()
module = Extension('library',
sources = ['module_name/library.c'],
extra_compile_args=['-Wall', '-pedantic', '-o', 'library', '-lm', '-O2'])
setup(
name="module_name", # Replace with your own username
version="0.0.1",
author="",
author_email="",
description="",
long_description=long_description,
long_description_content_type="text/markdown",
packages=setuptools.find_packages(),
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires='>=3.6',
install_requires=[
'pandas',
'pexpect'],
#cmdclass={'install': CustomInstall},
#include_package_data=True,
ext_modules=[module],
)
When I run pip install -e . the compile returns an error message:
https://pastebin.com/hMLA95G9
Following on from @9769953's comment I've tried to edit the setup.py to directly link to the full path of the file:
from pathlib import Path
ROOT_PATH = Path(__file__).parent.resolve()
module = Extension('spec_con',
sources = ['spec_conv/spec_con.c'],
extra_compile_args=['-Wall', '-pedantic', '-o', f'{ROOT_PATH}/module_name/library', '-lm', '-O2'],
library_dirs=["/home/alletro/python_packages"])
But I still get the same error.
'-o', 'library'items from theextra_compile_argslist. Distutils and gcc should already do the right thing. Why do you want to include this option?