mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 09:09:03 -04:00
fix pip installation for cffi
This commit is contained in:
parent
d6ea511d15
commit
34936d5f25
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,6 +1,7 @@
|
|||||||
/build/
|
/build/
|
||||||
doc/examples/book
|
doc/examples/book
|
||||||
obj-x86_64-linux-gnu
|
obj-x86_64-linux-gnu
|
||||||
|
cffi/include
|
||||||
python/.eggs/
|
python/.eggs/
|
||||||
python/build/
|
python/build/
|
||||||
python/dist/
|
python/dist/
|
||||||
|
1
cffi/MANIFEST.in
Normal file
1
cffi/MANIFEST.in
Normal file
@ -0,0 +1 @@
|
|||||||
|
recursive-include include *.h
|
@ -1,11 +1,28 @@
|
|||||||
from setuptools import setup
|
from setuptools import setup
|
||||||
from setuptools.command.install import install
|
from setuptools.command.install import install
|
||||||
|
from setuptools.command.sdist import sdist
|
||||||
|
from distutils.command.build import build
|
||||||
import os
|
import os
|
||||||
import sys
|
import shutil
|
||||||
|
|
||||||
|
here = os.path.dirname(__file__) or '.'
|
||||||
|
|
||||||
|
|
||||||
|
def read(fname):
|
||||||
|
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
||||||
|
|
||||||
|
|
||||||
|
def copy_include_dir():
|
||||||
|
src = os.path.join(here, "../include")
|
||||||
|
dst = os.path.join(here, "include")
|
||||||
|
if os.path.exists(src):
|
||||||
|
if os.path.exists(dst):
|
||||||
|
shutil.rmtree(dst)
|
||||||
|
shutil.copytree(src, dst)
|
||||||
|
|
||||||
|
|
||||||
class ManPageGenerator(install):
|
class ManPageGenerator(install):
|
||||||
def run(self):
|
def run(self):
|
||||||
here = os.path.dirname(__file__) or '.'
|
|
||||||
files = []
|
files = []
|
||||||
outfile = 'notcurses-pydemo.1'
|
outfile = 'notcurses-pydemo.1'
|
||||||
pypandoc.convert_file(os.path.join(here, 'notcurses-pydemo.1.md'), 'man', outputfile=outfile, extra_args=['-s'])
|
pypandoc.convert_file(os.path.join(here, 'notcurses-pydemo.1.md'), 'man', outputfile=outfile, extra_args=['-s'])
|
||||||
@ -19,18 +36,25 @@ class ManPageGenerator(install):
|
|||||||
print("data_files: ", self.distribution.data_files)
|
print("data_files: ", self.distribution.data_files)
|
||||||
super().run()
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
class SdistCommand(sdist):
|
||||||
|
def run(self):
|
||||||
|
copy_include_dir()
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
class BuildCommand(build):
|
||||||
|
def run(self):
|
||||||
|
copy_include_dir()
|
||||||
|
super().run()
|
||||||
|
|
||||||
|
|
||||||
|
cmdclass = {"sdist": SdistCommand, "build": BuildCommand}
|
||||||
try:
|
try:
|
||||||
import pypandoc
|
import pypandoc
|
||||||
|
cmdclass["install"] = ManPageGenerator
|
||||||
except ImportError:
|
except ImportError:
|
||||||
print("warning: pypandoc module not found, won't generate man pages")
|
print("warning: pypandoc module not found, won't generate man pages")
|
||||||
manpageinstaller=dict()
|
|
||||||
else:
|
|
||||||
manpageinstaller=dict(
|
|
||||||
install=ManPageGenerator,
|
|
||||||
)
|
|
||||||
|
|
||||||
def read(fname):
|
|
||||||
return open(os.path.join(os.path.dirname(__file__), fname)).read()
|
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="notcurses",
|
name="notcurses",
|
||||||
@ -61,5 +85,5 @@ setup(
|
|||||||
'Programming Language :: Python',
|
'Programming Language :: Python',
|
||||||
],
|
],
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
cmdclass=manpageinstaller
|
cmdclass=cmdclass,
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ ffibuild.set_source(
|
|||||||
libraries=["notcurses"],
|
libraries=["notcurses"],
|
||||||
)
|
)
|
||||||
|
|
||||||
with open('../include/notcurses/notcurses.h') as fp:
|
with open('include/notcurses/notcurses.h') as fp:
|
||||||
lines = fp.read().splitlines()
|
lines = fp.read().splitlines()
|
||||||
# remove initial #includes and #ifdefs
|
# remove initial #includes and #ifdefs
|
||||||
first = next(i for i, line in enumerate(lines) if 'notcurses_version' in line)
|
first = next(i for i, line in enumerate(lines) if 'notcurses_version' in line)
|
||||||
@ -21,7 +21,7 @@ with open('../include/notcurses/notcurses.h') as fp:
|
|||||||
del lines[last:]
|
del lines[last:]
|
||||||
|
|
||||||
# same with direct.h
|
# same with direct.h
|
||||||
with open('../include/notcurses/direct.h') as fp:
|
with open('include/notcurses/direct.h') as fp:
|
||||||
direct_lines = fp.read().splitlines()
|
direct_lines = fp.read().splitlines()
|
||||||
first = next(i for i, line in enumerate(direct_lines) if '#define ALLOC' in line)
|
first = next(i for i, line in enumerate(direct_lines) if '#define ALLOC' in line)
|
||||||
del direct_lines[:first+1]
|
del direct_lines[:first+1]
|
||||||
@ -29,7 +29,7 @@ with open('../include/notcurses/direct.h') as fp:
|
|||||||
del direct_lines[last:]
|
del direct_lines[last:]
|
||||||
|
|
||||||
# and also nckeys.key
|
# and also nckeys.key
|
||||||
with open('../include/notcurses/nckeys.h') as fp:
|
with open('include/notcurses/nckeys.h') as fp:
|
||||||
nckeys_lines = fp.read().splitlines()
|
nckeys_lines = fp.read().splitlines()
|
||||||
first = next(i for i, line in enumerate(nckeys_lines) if '#define NCKEY_' in line)
|
first = next(i for i, line in enumerate(nckeys_lines) if '#define NCKEY_' in line)
|
||||||
del nckeys_lines[:first]
|
del nckeys_lines[:first]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user