Python setup.py call makefile don't include binaries

前端 未结 1 583
谎友^
谎友^ 2021-01-13 09:05

Some context: I have some C code that when compiled I can call in the terminal like this: ./my_excec -params It generates some files that I am using in python t

相关标签:
1条回答
  • 2021-01-13 09:49

    I was able to find a really easy solution.

    As I said my main problem was that I was packaging the compiled files. To exclude those files form the tarball/zip just had to put this on MANIFEST.in: prune bin.

    Then just need to call the makefile from setup.py:

    directory = 'bin'
    if not os.path.exists(directory):
        os.makedirs(directory)
    
    subprocess.call(['make', '-C', 'src'])
    

    With that when someone does pip install whatever is going to call the make file and put the binaries on bin (have to specify this on the make file).

    Then just need to say the setup to copy those files:

    setup(
    ...
    data_files=[('bin', ['bin/binaries'])],
    )
    

    Done! Hopefuly someone find this usefull :)

    0 讨论(0)
提交回复
热议问题