-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify setup.py by removing regex search for version, moving out so…
…me functions to new file tools.py (not setuptools.py because module named this)
- Loading branch information
Showing
3 changed files
with
48 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import glob | ||
import os | ||
|
||
def glob_files(path, excludes, extension="*.cpp"): | ||
files = [] | ||
for srcfile in glob.glob(os.path.join(path, extension)): | ||
filename = os.path.basename(srcfile) | ||
if not filename in tuple(excludes): | ||
files.append(srcfile) | ||
return files | ||
|
||
|
||
class BuildError(Exception): | ||
pass | ||
|
||
|
||
|
||
def get_user_module_sources(folder): | ||
print('Found User Module: {}'.format(folder)) | ||
user_sources = glob.glob(folder + '/*.pyx') | ||
print('\tFound Cython sources: {}'.format(user_sources)) | ||
|
||
if len(user_sources) != 1: | ||
raise BuildError("User Modules are only allowed one Cython .pyx file") | ||
|
||
filename_string = user_sources[0].split('/')[-1][:-4] | ||
if filename_string != module_name: | ||
print(filename_string, module_name) | ||
raise BuildError("The Cython source file in {} must match the folder name - i.e. it must be {}.pyx".format(module_name, module_name)) | ||
cfilename = filename_string + '.cpp' | ||
print(cfilename) | ||
user_sources += glob_files(folder, excludes=[cfilename]) | ||
|
||
return user_sources |