Skip to content

Commit

Permalink
ensuring cpp code is included in the src dist package
Browse files Browse the repository at this point in the history
  • Loading branch information
ftomassetti committed May 7, 2015
1 parent 6ce7e02 commit 5be8bc5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 10 deletions.
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

3 changes: 2 additions & 1 deletion pybindings/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
venv
venv
cpp_src
1 change: 1 addition & 0 deletions pybindings/MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
recursive-include cpp_src *.hpp
30 changes: 24 additions & 6 deletions pybindings/setup.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,40 @@
from setuptools import setup, Extension, Command
import os
import shutil

def ensure_clean_dir(f):
if os.path.exists(f):
shutil.rmtree(f)
os.makedirs(f)

current_dir = os.path.dirname(__file__)
parent_dir = os.path.join(current_dir, os.pardir)
cpp_src_dir = os.path.abspath(os.path.join(parent_dir, "src"))
def copy_dir_contents(src, dst):
src_files = os.listdir(src)
for file_name in src_files:
full_file_name = os.path.join(src, file_name)
if (os.path.isfile(full_file_name)):
shutil.copy(full_file_name, dst)

# If we are compiling from inside the tree we need to move the C++ source code
# to cpp_src, otherwise if building from a source directory the C++ source code
# should be already there
cpp_src_dir = "cpp_src"

if os.path.exists("../src"):
ensure_clean_dir(cpp_src_dir)
copy_dir_contents("../src", cpp_src_dir)

# We add all .cpp files to the sources
sources = [ 'platec_src/platecmodule.cpp']
for f in os.listdir(cpp_src_dir):
if f.endswith(".cpp"):
sources.append("%s/%s" % (cpp_src_dir, f))
print(sources)

pyplatec = Extension('platec',
sources = sources,
language='c++')

setup (name = 'PyPlatec',
version = '1.3.1',
version = '1.3.2',
author = "Federico Tomassetti",
author_email = "f.tomassetti@gmail.com",
url = "https://github.com/Mindwerks/pyplatec",
Expand All @@ -39,4 +56,5 @@
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Topic :: Software Development :: Libraries :: Python Modules',
])
]
)

0 comments on commit 5be8bc5

Please sign in to comment.