A bit more work on the python packaging. Currently broken, still a work in progress.

Signed-off-by: Ian Bell <ian.h.bell@gmail.com>
This commit is contained in:
Ian Bell
2014-08-02 19:52:36 +02:00
parent a8061032fb
commit 87aae7eef7
3 changed files with 41 additions and 31 deletions

View File

@@ -1,3 +1,4 @@
recursive-include ../../src *.*
recursive-include ../../include *.*
recursive-include ../../externals *.*
recursive-include src *.*
recursive-include include *.*
recursive-include externals *.*
include *.*

View File

@@ -1,35 +1,40 @@
def collect(tmp):
print('copying sources')
shutil.copytree(os.path.join('..','..','..','src'),os.path.join(tmp,'src'))
print('copying include')
shutil.copytree(os.path.join('..','..','..','include'),os.path.join(tmp,'include'))
print('copying externals')
shutil.copytree(os.path.join('..','..','..','externals'),os.path.join(tmp,'externals'))
print('copying python files')
shutil.copytree(os.path.join('..',name),os.path.join(tmp,name))
print('copying MANIFEST.in')
shutil.copy2(os.path.join('..','MANIFEST.in'),os.path.join(tmp,'MANIFEST.in'))
print('copying .version')
shutil.copy2(os.path.join('..','..','..','.version'),os.path.join(tmp,'.version'))
print('copying setup.py')
shutil.copy2(os.path.join('..','setup.py'),os.path.join(tmp,'setup.py'))
if __name__=='__main__':
import shutil, os, sys, subprocess
subprocess.check_call(['python','generate_headers.py'], shell = True, cwd=os.path.join('..','..','..','dev'))
subprocess.check_call(['python','generate_headers.py'], shell = True, cwd = os.path.join('..','..','..','dev'))
name = 'CoolProp5'
# Make a temporary directory in this folder
import tempfile
tmp = tempfile.mkdtemp(dir = '.')
def collect():
print('copying sources')
shutil.copytree(os.path.join('..','..','..','src'),os.path.join(tmp,'src'))
print('copying include')
shutil.copytree(os.path.join('..','..','..','include'),os.path.join(tmp,'include'))
print('copying externals')
shutil.copytree(os.path.join('..','..','..','externals'),os.path.join(tmp,'externals'))
print('copying python files')
shutil.copytree(os.path.join('..',name),os.path.join(tmp,name))
print('copying MANIFEST.in')
shutil.copy2(os.path.join('..','MANIFEST.in'),os.path.join(tmp,'MANIFEST.in'))
print('copying .version')
shutil.copy2(os.path.join('..','..','..','.version'),os.path.join(tmp,'.version'))
print('copying setup.py')
shutil.copy2(os.path.join('..','setup.py'),os.path.join(tmp,'setup.py'))
try:
collect()
collect(tmp)
# Try to make the source distro
subprocess.check_call(['python','setup.py','sdist','--pypi'], shell = True, cwd = tmp)
except BaseException as B:
#shutil.rmtree('collect')
raise
#shutil.rmtree(tmp)
raise
else:
pass
#shutil.rmtree('collect')
#shutil.rmtree(tmp)

View File

@@ -12,6 +12,9 @@ def remove_files():
if __name__=='__main__':
import subprocess, shutil, os, sys, glob
# Check if a sdist build for pypi
if '--pypi' in sys.argv:
sys.argv.remove('--pypi')
pypi = True
@@ -42,7 +45,7 @@ if __name__=='__main__':
else:
_profiling_enabled = False
import subprocess, shutil, os, sys, glob
# Determine the path to the root of the repository, the folder that contains the CMakeLists.txt file
# for normal builds, or the main directory for sdist builds
@@ -115,7 +118,8 @@ if __name__=='__main__':
[os.path.join('CoolProp5','CoolProp.pyx')]+sources,
**common_args)
copy_files()
if not pypi:
copy_files()
from setuptools import setup
from Cython.Distutils.extension import Extension
@@ -132,9 +136,7 @@ if __name__=='__main__':
ext_modules = cythonize([CoolProp_module, AbstractState_module]),
package_data = {'CoolProp5':['State.pxd',
'CoolProp.pxd',
'../../include',
'include/rapidjson/*.h',
'include/rapidjson/internal/*.h',
'include',
'CoolPropBibTeXLibrary.bib']},
cmdclass={'build_ext': build_ext},
@@ -149,7 +151,9 @@ if __name__=='__main__':
],
)
except BaseException as E:
remove_files()
if not pypi:
remove_files()
raise
else:
remove_files()
if not pypi:
remove_files()