2017-05-02 19:12:56 +03:00
|
|
|
from distutils.cmd import Command
|
2016-08-11 00:26:05 +03:00
|
|
|
from distutils.core import setup, Extension
|
2017-02-24 01:03:02 +03:00
|
|
|
import distutils
|
2017-05-02 19:12:56 +03:00
|
|
|
import fnmatch
|
2016-07-08 15:15:42 +03:00
|
|
|
from glob import glob
|
|
|
|
|
2016-10-08 19:08:29 +03:00
|
|
|
import os, sys
|
2016-09-18 23:45:50 +03:00
|
|
|
|
2017-03-17 19:04:19 +03:00
|
|
|
iswindows = os.name == 'nt'
|
2017-04-06 01:00:31 +03:00
|
|
|
WERROR = "/WX" if iswindows else "-Werror"
|
|
|
|
WSTRICTPROTOTYPES = None if iswindows else "-Werror=strict-prototypes"
|
|
|
|
WALL = "/Wall" if iswindows else "-Wall"
|
|
|
|
STDC99 = "" if iswindows else "-std=c99"
|
|
|
|
STDCPP0X = "" if iswindows else "-std=c++0x"
|
|
|
|
WEXTRA = "" if iswindows else "-Wextra"
|
|
|
|
WCONVERSION = "" if iswindows else "-Wconversion"
|
|
|
|
PEDANTIC = "" if iswindows else "-pedantic"
|
|
|
|
NOOPTIMIZATION = "/Od" if iswindows else "-O0"
|
|
|
|
PRODUCEDEBUGSYMBOLS = "/DEBUG:FULL" if iswindows else "-g"
|
|
|
|
|
2016-10-08 19:08:29 +03:00
|
|
|
# --component allows the caller to specify what components they want. We can't
|
|
|
|
# use argparse like normal, because setup() at the bottom has it's own argument
|
|
|
|
# logic.
|
|
|
|
components = []
|
|
|
|
args = []
|
|
|
|
skip = False
|
|
|
|
for i, arg in enumerate(sys.argv):
|
|
|
|
if skip:
|
|
|
|
skip = False
|
|
|
|
continue
|
|
|
|
|
|
|
|
if arg == '--component' and len(sys.argv) > i + 1:
|
|
|
|
components.extend(sys.argv[i + 1].split(','))
|
|
|
|
skip = True
|
|
|
|
else:
|
|
|
|
args.append(arg)
|
|
|
|
|
|
|
|
sys.argv = args
|
2016-07-22 22:44:59 +03:00
|
|
|
|
2017-02-24 01:03:03 +03:00
|
|
|
cflags = []
|
|
|
|
|
2016-09-18 23:45:50 +03:00
|
|
|
# if this is set, compile all C extensions with -O0 -g for easy debugging. note
|
|
|
|
# that this is not manifested in any way in the Makefile dependencies.
|
|
|
|
# therefore, if you already have build products, they won't be rebuilt!
|
|
|
|
if os.getenv('FB_HGEXT_CDEBUG') is not None:
|
2017-04-06 01:00:31 +03:00
|
|
|
cflags.extend([NOOPTIMIZATION, PRODUCEDEBUGSYMBOLS])
|
2016-09-18 23:45:50 +03:00
|
|
|
else:
|
2017-04-06 01:00:31 +03:00
|
|
|
cflags.append(WERROR)
|
2016-09-18 23:45:50 +03:00
|
|
|
|
[setup.py] support parsing INCLUDE_DIRS and LIBRARY_DIRS environment variables
Summary:
Update the code to read additional include and library directories from the
INCLUDE_DIRS and LIBRARY_DIRS environment variables, if they are set.
This allows us to build the extensions using custom include/library paths.
While these could have been set through the CFLAGS and LDFLAGS variables,
distutils already includes many default settings in CFLAGS and LDFLAGS by
default (taken from the settings used to build python), and setting CFLAGS and
LDFLAGS ourself would override these defaults. We do still want all of the
flags in CFLAGS and LDFLAGS by default, so it is easier to add support for
separate INCLUDE_DIRS and LIBRARY_DIRS variables.
Test Plan: Tested building fb-mercurial-omnibus on CentOS.
Reviewers: ikostia, simonfar, ttung, durham, mbolin, wez, quark
Reviewed By: quark
Subscribers: ttung, net-systems-diffs@, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3916198
Signature: t1:3916198:1475091590:97904ef87a8a2b78e178c87d9d49bdadcce94e44
2016-09-29 02:08:21 +03:00
|
|
|
def get_env_path_list(var_name, default=None):
|
|
|
|
'''Get a path list from an environment variable. The variable is parsed as
|
|
|
|
a colon-separated list.'''
|
|
|
|
value = os.environ.get(var_name)
|
|
|
|
if not value:
|
|
|
|
return default
|
|
|
|
return value.split(os.path.pathsep)
|
|
|
|
|
|
|
|
include_dirs = get_env_path_list('INCLUDE_DIRS')
|
|
|
|
library_dirs = get_env_path_list('LIBRARY_DIRS')
|
|
|
|
|
2017-05-08 17:53:23 +03:00
|
|
|
def filter_existing_dirs(dirs):
|
|
|
|
'''Filters the given list and keeps only existing directory names.'''
|
|
|
|
return [d for d in dirs if os.path.isdir(d)]
|
|
|
|
|
[setup.py] support parsing INCLUDE_DIRS and LIBRARY_DIRS environment variables
Summary:
Update the code to read additional include and library directories from the
INCLUDE_DIRS and LIBRARY_DIRS environment variables, if they are set.
This allows us to build the extensions using custom include/library paths.
While these could have been set through the CFLAGS and LDFLAGS variables,
distutils already includes many default settings in CFLAGS and LDFLAGS by
default (taken from the settings used to build python), and setting CFLAGS and
LDFLAGS ourself would override these defaults. We do still want all of the
flags in CFLAGS and LDFLAGS by default, so it is easier to add support for
separate INCLUDE_DIRS and LIBRARY_DIRS variables.
Test Plan: Tested building fb-mercurial-omnibus on CentOS.
Reviewers: ikostia, simonfar, ttung, durham, mbolin, wez, quark
Reviewed By: quark
Subscribers: ttung, net-systems-diffs@, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3916198
Signature: t1:3916198:1475091590:97904ef87a8a2b78e178c87d9d49bdadcce94e44
2016-09-29 02:08:21 +03:00
|
|
|
# Historical default values.
|
|
|
|
# We should perhaps clean these up in the future after verifying that it
|
|
|
|
# doesn't break the build on any platforms.
|
|
|
|
#
|
|
|
|
# The /usr/local/* directories shouldn't actually be needed--the compiler
|
|
|
|
# should already use these directories when appropriate (e.g., if we are
|
|
|
|
# using the standard system compiler that has them in its default paths).
|
|
|
|
#
|
|
|
|
# The /opt/local paths may be necessary on Darwin builds.
|
|
|
|
if include_dirs is None:
|
2017-04-06 01:00:31 +03:00
|
|
|
if iswindows:
|
|
|
|
include_dirs = []
|
|
|
|
else:
|
2017-05-08 17:53:23 +03:00
|
|
|
include_dirs = filter_existing_dirs([
|
2017-04-06 01:00:31 +03:00
|
|
|
'/usr/local/include',
|
|
|
|
'/opt/local/include',
|
|
|
|
'/opt/homebrew/include/',
|
2017-05-08 17:53:23 +03:00
|
|
|
])
|
2017-02-24 01:03:02 +03:00
|
|
|
|
|
|
|
def distutils_dir_name(dname):
|
|
|
|
"""Returns the name of a distutils build directory"""
|
|
|
|
f = "{dirname}.{platform}-{version}"
|
|
|
|
return f.format(dirname=dname,
|
|
|
|
platform=distutils.util.get_platform(),
|
|
|
|
version=sys.version[:3])
|
|
|
|
|
[setup.py] support parsing INCLUDE_DIRS and LIBRARY_DIRS environment variables
Summary:
Update the code to read additional include and library directories from the
INCLUDE_DIRS and LIBRARY_DIRS environment variables, if they are set.
This allows us to build the extensions using custom include/library paths.
While these could have been set through the CFLAGS and LDFLAGS variables,
distutils already includes many default settings in CFLAGS and LDFLAGS by
default (taken from the settings used to build python), and setting CFLAGS and
LDFLAGS ourself would override these defaults. We do still want all of the
flags in CFLAGS and LDFLAGS by default, so it is easier to add support for
separate INCLUDE_DIRS and LIBRARY_DIRS variables.
Test Plan: Tested building fb-mercurial-omnibus on CentOS.
Reviewers: ikostia, simonfar, ttung, durham, mbolin, wez, quark
Reviewed By: quark
Subscribers: ttung, net-systems-diffs@, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3916198
Signature: t1:3916198:1475091590:97904ef87a8a2b78e178c87d9d49bdadcce94e44
2016-09-29 02:08:21 +03:00
|
|
|
if library_dirs is None:
|
2017-04-06 01:00:31 +03:00
|
|
|
if iswindows:
|
|
|
|
library_dirs = []
|
|
|
|
else:
|
2017-05-08 17:53:23 +03:00
|
|
|
library_dirs = filter_existing_dirs([
|
2017-04-06 01:00:31 +03:00
|
|
|
'/usr/local/lib',
|
|
|
|
'/opt/local/lib',
|
|
|
|
'/opt/homebrew/lib/',
|
2017-05-08 17:53:23 +03:00
|
|
|
])
|
2017-04-06 01:00:31 +03:00
|
|
|
library_dirs.append('build/' + distutils_dir_name('lib'))
|
[setup.py] support parsing INCLUDE_DIRS and LIBRARY_DIRS environment variables
Summary:
Update the code to read additional include and library directories from the
INCLUDE_DIRS and LIBRARY_DIRS environment variables, if they are set.
This allows us to build the extensions using custom include/library paths.
While these could have been set through the CFLAGS and LDFLAGS variables,
distutils already includes many default settings in CFLAGS and LDFLAGS by
default (taken from the settings used to build python), and setting CFLAGS and
LDFLAGS ourself would override these defaults. We do still want all of the
flags in CFLAGS and LDFLAGS by default, so it is easier to add support for
separate INCLUDE_DIRS and LIBRARY_DIRS variables.
Test Plan: Tested building fb-mercurial-omnibus on CentOS.
Reviewers: ikostia, simonfar, ttung, durham, mbolin, wez, quark
Reviewed By: quark
Subscribers: ttung, net-systems-diffs@, yogeshwer, mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D3916198
Signature: t1:3916198:1475091590:97904ef87a8a2b78e178c87d9d49bdadcce94e44
2016-09-29 02:08:21 +03:00
|
|
|
|
2017-02-24 01:03:02 +03:00
|
|
|
# Override the default c static library building code in distutils since it
|
|
|
|
# doesn't pass enough args, like libraries and extra args.
|
|
|
|
import distutils.command.build_clib
|
|
|
|
from distutils.errors import DistutilsSetupError
|
|
|
|
def build_libraries(self, libraries):
|
|
|
|
for (lib_name, build_info) in libraries:
|
|
|
|
sources = build_info.get('sources')
|
|
|
|
if sources is None or not isinstance(sources, (list, tuple)):
|
|
|
|
raise DistutilsSetupError(
|
|
|
|
"in 'libraries' option (library '%s'), " +
|
|
|
|
"'sources' must be present and must be " +
|
|
|
|
"a list of source filenames") % lib_name
|
|
|
|
sources = list(sources)
|
|
|
|
|
|
|
|
# First, compile the source code to object files in the library
|
|
|
|
# directory. (This should probably change to putting object
|
|
|
|
# files in a temporary build directory.)
|
|
|
|
macros = build_info.get('macros')
|
|
|
|
include_dirs = build_info.get('include_dirs')
|
|
|
|
extra_args = build_info.get('extra_args')
|
|
|
|
objects = self.compiler.compile(sources,
|
|
|
|
output_dir=self.build_temp,
|
|
|
|
macros=macros,
|
|
|
|
include_dirs=include_dirs,
|
|
|
|
debug=self.debug,
|
|
|
|
extra_postargs=extra_args)
|
|
|
|
|
|
|
|
# Now "link" the object files together into a static library.
|
|
|
|
# (On Unix at least, this isn't really linking -- it just
|
|
|
|
# builds an archive. Whatever.)
|
2017-02-24 01:03:03 +03:00
|
|
|
libraries = build_info.get('libraries', [])
|
2017-02-24 01:03:02 +03:00
|
|
|
for lib in libraries:
|
|
|
|
self.compiler.add_library(lib)
|
|
|
|
self.compiler.create_static_lib(objects, lib_name,
|
|
|
|
output_dir=self.build_clib,
|
|
|
|
debug=self.debug)
|
|
|
|
distutils.command.build_clib.build_clib.build_libraries = build_libraries
|
|
|
|
|
|
|
|
# Static c libaries
|
2017-03-17 19:04:19 +03:00
|
|
|
if iswindows:
|
2017-05-06 01:30:00 +03:00
|
|
|
availablelibraries = {}
|
2017-03-17 19:04:19 +03:00
|
|
|
else:
|
2017-05-06 01:30:00 +03:00
|
|
|
availablelibraries = {
|
|
|
|
'datapack': {
|
2017-03-17 19:04:19 +03:00
|
|
|
"sources" : ["cdatapack/cdatapack.c"],
|
|
|
|
"include_dirs" : ["clib"] + include_dirs,
|
sha1: switch to new implementation
Summary:
This diff changes our code to use the new SHA1 library. See the previous diff
for why we do this.
Test Plan:
Run related tests manually:
```
$ make local PYTHON=python2
$ rt test-remotefilelog-*.t
.........................
# Ran 25 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-treemanifest*.t
........
# Ran 8 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-fastmanifest*.t
.........
# Ran 9 tests, 0 skipped, 0 warned, 0 failed.
```
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4945025
Signature: t1:4945025:1493154873:844e55a51ab250354fc08163e0949eed47b0a861
2017-04-26 00:53:32 +03:00
|
|
|
"libraries" : ["lz4", "sha1"],
|
2017-04-06 01:00:31 +03:00
|
|
|
"extra_args" : filter(None,
|
|
|
|
[STDC99, WALL, WERROR, WSTRICTPROTOTYPES] + cflags),
|
2017-05-06 01:30:00 +03:00
|
|
|
},
|
|
|
|
'mpatch': {
|
2017-03-17 19:04:19 +03:00
|
|
|
'sources': ['cstore/mpatch.c']
|
2017-05-06 01:30:00 +03:00
|
|
|
},
|
|
|
|
"sha1": {
|
sha1: switch to new implementation
Summary:
This diff changes our code to use the new SHA1 library. See the previous diff
for why we do this.
Test Plan:
Run related tests manually:
```
$ make local PYTHON=python2
$ rt test-remotefilelog-*.t
.........................
# Ran 25 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-treemanifest*.t
........
# Ran 8 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-fastmanifest*.t
.........
# Ran 9 tests, 0 skipped, 0 warned, 0 failed.
```
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4945025
Signature: t1:4945025:1493154873:844e55a51ab250354fc08163e0949eed47b0a861
2017-04-26 00:53:32 +03:00
|
|
|
"sources" : ["clib/sha1/sha1.c", "clib/sha1/ubc_check.c"],
|
|
|
|
"include_dirs" : ["clib/sha1"] + include_dirs,
|
|
|
|
"extra_args" : filter(None,
|
|
|
|
[STDC99, WALL, WERROR, WSTRICTPROTOTYPES] + cflags),
|
2017-05-06 01:30:00 +03:00
|
|
|
},
|
|
|
|
}
|
2017-02-24 01:03:02 +03:00
|
|
|
|
2017-04-03 20:40:31 +03:00
|
|
|
# modules that are single files in hgext3rd
|
2016-10-08 19:08:29 +03:00
|
|
|
hgext3rd = [
|
|
|
|
p[:-3].replace('/', '.')
|
|
|
|
for p in glob('hgext3rd/*.py')
|
|
|
|
if p != 'hgext3rd/__init__.py'
|
|
|
|
]
|
|
|
|
|
2017-04-04 21:48:27 +03:00
|
|
|
# packages that are directories in hgext3rd
|
|
|
|
hgext3rdpkgs = [
|
2017-04-03 20:40:31 +03:00
|
|
|
p[:-12].replace('/', '.')
|
|
|
|
for p in glob('hgext3rd/*/__init__.py')
|
2017-04-04 21:48:27 +03:00
|
|
|
]
|
2017-04-03 20:40:31 +03:00
|
|
|
|
2017-04-04 21:48:27 +03:00
|
|
|
availablepymodules = hgext3rd + ['statprof']
|
2016-10-08 19:08:29 +03:00
|
|
|
|
2017-04-04 21:48:27 +03:00
|
|
|
availablepackages = hgext3rdpkgs + [
|
2016-10-08 19:08:29 +03:00
|
|
|
'infinitepush',
|
|
|
|
'phabricator',
|
|
|
|
'sqldirstate',
|
|
|
|
'remotefilelog',
|
|
|
|
]
|
|
|
|
|
2017-03-23 14:14:33 +03:00
|
|
|
if not iswindows:
|
2017-03-17 19:04:19 +03:00
|
|
|
availablepackages += [
|
|
|
|
'fastannotate',
|
|
|
|
'fastmanifest',
|
|
|
|
'treemanifest',
|
|
|
|
'linelog',
|
|
|
|
]
|
|
|
|
|
2017-02-24 01:03:03 +03:00
|
|
|
def distutils_dir_name(dname):
|
|
|
|
"""Returns the name of a distutils build directory"""
|
|
|
|
f = "{dirname}.{platform}-{version}"
|
|
|
|
return f.format(dirname=dname,
|
|
|
|
platform=distutils.util.get_platform(),
|
|
|
|
version=sys.version[:3])
|
|
|
|
|
2017-03-17 19:04:19 +03:00
|
|
|
if iswindows:
|
2016-12-14 04:20:13 +03:00
|
|
|
# The modules that successfully compile on Windows
|
|
|
|
availableextmodules = {}
|
|
|
|
else:
|
|
|
|
availableextmodules = {
|
2017-02-24 01:03:02 +03:00
|
|
|
'cstore' : [
|
|
|
|
Extension('cstore',
|
2016-12-14 04:20:13 +03:00
|
|
|
sources=[
|
2017-02-24 01:03:03 +03:00
|
|
|
'cstore/datapackstore.cpp',
|
2017-02-24 01:03:02 +03:00
|
|
|
'cstore/py-cstore.cpp',
|
2017-03-07 22:39:46 +03:00
|
|
|
'cstore/pythonutil.cpp',
|
2017-02-24 01:03:03 +03:00
|
|
|
'cstore/uniondatapackstore.cpp',
|
2016-12-14 04:20:13 +03:00
|
|
|
'ctreemanifest/manifest.cpp',
|
|
|
|
'ctreemanifest/manifest_entry.cpp',
|
|
|
|
'ctreemanifest/manifest_fetcher.cpp',
|
|
|
|
'ctreemanifest/treemanifest.cpp',
|
|
|
|
],
|
|
|
|
include_dirs=[
|
sha1: switch to new implementation
Summary:
This diff changes our code to use the new SHA1 library. See the previous diff
for why we do this.
Test Plan:
Run related tests manually:
```
$ make local PYTHON=python2
$ rt test-remotefilelog-*.t
.........................
# Ran 25 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-treemanifest*.t
........
# Ran 8 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-fastmanifest*.t
.........
# Ran 9 tests, 0 skipped, 0 warned, 0 failed.
```
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4945025
Signature: t1:4945025:1493154873:844e55a51ab250354fc08163e0949eed47b0a861
2017-04-26 00:53:32 +03:00
|
|
|
'ctreemanifest',
|
2017-02-24 01:03:03 +03:00
|
|
|
'cdatapack',
|
sha1: switch to new implementation
Summary:
This diff changes our code to use the new SHA1 library. See the previous diff
for why we do this.
Test Plan:
Run related tests manually:
```
$ make local PYTHON=python2
$ rt test-remotefilelog-*.t
.........................
# Ran 25 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-treemanifest*.t
........
# Ran 8 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-fastmanifest*.t
.........
# Ran 9 tests, 0 skipped, 0 warned, 0 failed.
```
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4945025
Signature: t1:4945025:1493154873:844e55a51ab250354fc08163e0949eed47b0a861
2017-04-26 00:53:32 +03:00
|
|
|
'clib',
|
2017-02-24 01:03:03 +03:00
|
|
|
'cstore',
|
2016-12-14 04:20:13 +03:00
|
|
|
] + include_dirs,
|
2017-02-24 01:03:03 +03:00
|
|
|
library_dirs=[
|
|
|
|
'build/' + distutils_dir_name('lib'),
|
|
|
|
] + library_dirs,
|
2016-12-14 04:20:13 +03:00
|
|
|
libraries=[
|
2017-02-24 01:03:03 +03:00
|
|
|
'datapack',
|
|
|
|
'lz4',
|
2017-05-09 04:35:53 +03:00
|
|
|
'mpatch',
|
sha1: switch to new implementation
Summary:
This diff changes our code to use the new SHA1 library. See the previous diff
for why we do this.
Test Plan:
Run related tests manually:
```
$ make local PYTHON=python2
$ rt test-remotefilelog-*.t
.........................
# Ran 25 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-treemanifest*.t
........
# Ran 8 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-fastmanifest*.t
.........
# Ran 9 tests, 0 skipped, 0 warned, 0 failed.
```
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4945025
Signature: t1:4945025:1493154873:844e55a51ab250354fc08163e0949eed47b0a861
2017-04-26 00:53:32 +03:00
|
|
|
'sha1',
|
2016-12-14 04:20:13 +03:00
|
|
|
],
|
2017-04-06 01:00:31 +03:00
|
|
|
extra_compile_args=filter(None, [STDCPP0X, WALL] + cflags),
|
2016-12-14 04:20:13 +03:00
|
|
|
),
|
|
|
|
],
|
|
|
|
'cfastmanifest' : [
|
|
|
|
Extension('cfastmanifest',
|
|
|
|
sources=['cfastmanifest.c',
|
|
|
|
'cfastmanifest/bsearch.c',
|
|
|
|
'clib/buffer.c',
|
|
|
|
'cfastmanifest/checksum.c',
|
|
|
|
'cfastmanifest/node.c',
|
|
|
|
'cfastmanifest/tree.c',
|
|
|
|
'cfastmanifest/tree_arena.c',
|
|
|
|
'cfastmanifest/tree_convert.c',
|
|
|
|
'cfastmanifest/tree_copy.c',
|
|
|
|
'cfastmanifest/tree_diff.c',
|
|
|
|
'cfastmanifest/tree_disk.c',
|
|
|
|
'cfastmanifest/tree_iterator.c',
|
|
|
|
'cfastmanifest/tree_path.c',
|
|
|
|
],
|
|
|
|
include_dirs=[
|
|
|
|
'cfastmanifest',
|
|
|
|
'clib',
|
|
|
|
] + include_dirs,
|
|
|
|
library_dirs=library_dirs,
|
sha1: switch to new implementation
Summary:
This diff changes our code to use the new SHA1 library. See the previous diff
for why we do this.
Test Plan:
Run related tests manually:
```
$ make local PYTHON=python2
$ rt test-remotefilelog-*.t
.........................
# Ran 25 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-treemanifest*.t
........
# Ran 8 tests, 0 skipped, 0 warned, 0 failed.
$ rt test-fastmanifest*.t
.........
# Ran 9 tests, 0 skipped, 0 warned, 0 failed.
```
Reviewers: #sourcecontrol, durham
Reviewed By: durham
Subscribers: mjpieters
Differential Revision: https://phabricator.intern.facebook.com/D4945025
Signature: t1:4945025:1493154873:844e55a51ab250354fc08163e0949eed47b0a861
2017-04-26 00:53:32 +03:00
|
|
|
libraries=['sha1'],
|
2017-04-06 01:00:31 +03:00
|
|
|
extra_compile_args=filter(None, [
|
|
|
|
STDC99,
|
|
|
|
WALL,
|
|
|
|
WSTRICTPROTOTYPES,
|
|
|
|
] + cflags),
|
2016-12-14 04:20:13 +03:00
|
|
|
),
|
|
|
|
],
|
|
|
|
'linelog' : [
|
|
|
|
Extension('linelog',
|
|
|
|
sources=['linelog/pyext/linelog.pyx'],
|
2017-04-06 01:00:31 +03:00
|
|
|
extra_compile_args=filter(None, [
|
|
|
|
STDC99, WALL, WEXTRA, WCONVERSION, PEDANTIC,
|
|
|
|
]),
|
2016-12-14 04:20:13 +03:00
|
|
|
),
|
|
|
|
],
|
2017-03-16 04:55:48 +03:00
|
|
|
'patchrmdir': [
|
|
|
|
Extension('hgext3rd.patchrmdir',
|
|
|
|
sources=['hgext3rd/patchrmdir.pyx'],
|
2017-04-06 01:00:31 +03:00
|
|
|
extra_compile_args=filter(None, [
|
|
|
|
STDC99, WALL, WEXTRA, WCONVERSION, PEDANTIC,
|
|
|
|
]),
|
2017-03-16 04:55:48 +03:00
|
|
|
),
|
|
|
|
],
|
2016-12-14 04:20:13 +03:00
|
|
|
}
|
2016-10-08 19:08:29 +03:00
|
|
|
|
2017-04-04 23:41:54 +03:00
|
|
|
allnames = availablepackages + availableextmodules.keys() + availablepymodules
|
|
|
|
COMPONENTS = sorted(name.split('.')[-1] for name in allnames)
|
2016-10-08 19:08:29 +03:00
|
|
|
|
|
|
|
if not components:
|
|
|
|
components = COMPONENTS
|
|
|
|
|
|
|
|
dependencies = {
|
|
|
|
'absorb' : ['linelog'],
|
2017-02-24 01:03:03 +03:00
|
|
|
'cstore' : ['ctreemanifest', 'cdatapack'],
|
2016-10-08 19:08:29 +03:00
|
|
|
'fastannotate' : ['linelog'],
|
2016-11-21 11:53:37 +03:00
|
|
|
'infinitepush' : ['extutil'],
|
2017-02-24 01:03:02 +03:00
|
|
|
'remotefilelog' : ['cstore', 'extutil'],
|
2017-02-24 01:03:03 +03:00
|
|
|
'treemanifest' : ['cstore'],
|
2016-10-08 19:08:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
processdep = True
|
|
|
|
while processdep:
|
|
|
|
processdep = False
|
|
|
|
for name, deps in dependencies.iteritems():
|
|
|
|
if name in components:
|
|
|
|
for dep in deps:
|
|
|
|
if dep not in components:
|
|
|
|
components.append(dep)
|
|
|
|
processdep = True
|
|
|
|
|
2017-03-17 19:04:19 +03:00
|
|
|
if iswindows:
|
2016-12-14 04:20:13 +03:00
|
|
|
# The modules that successfully compile on Windows
|
|
|
|
cythonmodules = []
|
|
|
|
else:
|
|
|
|
cythonmodules = [
|
|
|
|
'linelog',
|
2017-03-16 04:55:48 +03:00
|
|
|
'patchrmdir',
|
2016-12-14 04:20:13 +03:00
|
|
|
]
|
2016-10-08 19:08:29 +03:00
|
|
|
for cythonmodule in cythonmodules:
|
|
|
|
if cythonmodule in components:
|
|
|
|
module = availableextmodules[cythonmodule]
|
2017-04-28 22:26:03 +03:00
|
|
|
try:
|
|
|
|
from Cython.Build import cythonize
|
|
|
|
availableextmodules[cythonmodule] = cythonize(module)
|
|
|
|
except Exception: # ImportError or Cython.Compiler.Errors.CompileError
|
|
|
|
sys.stderr.write(
|
|
|
|
'+------------------------------------------------+\n'
|
|
|
|
'| Failed to run cythonize. |\n'
|
|
|
|
'| Make sure you have Cython >= 0.21.1 installed. |\n'
|
|
|
|
'+------------------------------------------------+\n')
|
|
|
|
raise SystemExit(255)
|
2016-10-08 19:08:29 +03:00
|
|
|
|
|
|
|
packages = []
|
|
|
|
for package in availablepackages:
|
2017-04-04 21:48:27 +03:00
|
|
|
if package.split('.')[-1] in components:
|
2016-10-08 19:08:29 +03:00
|
|
|
packages.append(package)
|
|
|
|
|
2017-05-06 01:30:00 +03:00
|
|
|
librarynames = set()
|
2016-10-08 19:08:29 +03:00
|
|
|
ext_modules = []
|
|
|
|
for ext_module in availableextmodules:
|
|
|
|
if ext_module in components:
|
2017-05-06 01:30:00 +03:00
|
|
|
modules = availableextmodules[ext_module]
|
|
|
|
ext_modules.extend(modules)
|
|
|
|
librarynames.update(l for m in modules for l in m.libraries)
|
|
|
|
|
|
|
|
libraries = [(n, availablelibraries[n])
|
|
|
|
for n in librarynames if n in availablelibraries]
|
2016-10-08 19:08:29 +03:00
|
|
|
|
2017-02-24 01:03:02 +03:00
|
|
|
# Dependencies between our native libraries means we need to build in order
|
|
|
|
ext_order = {
|
|
|
|
'libdatapack' : 0,
|
|
|
|
'cstore' : 3,
|
|
|
|
}
|
|
|
|
ext_modules = sorted(ext_modules, key=lambda k: ext_order.get(k.name, 999))
|
|
|
|
|
2016-10-08 19:08:29 +03:00
|
|
|
requires = []
|
|
|
|
requireslz4 = ['remotefilelog', 'cdatapack']
|
|
|
|
if any(c for c in components if c in requireslz4):
|
|
|
|
requires.append('lz4')
|
|
|
|
|
|
|
|
py_modules = []
|
|
|
|
for module in availablepymodules:
|
2017-04-04 21:48:27 +03:00
|
|
|
if module.split('.')[-1] in components:
|
|
|
|
py_modules.append(module)
|
2016-10-08 19:08:29 +03:00
|
|
|
|
2017-05-02 19:12:56 +03:00
|
|
|
# Extra clean command cleaning up non-Python extensions
|
|
|
|
class CleanExtCommand(Command):
|
|
|
|
description = 'remove extra build files'
|
|
|
|
user_options = []
|
|
|
|
|
|
|
|
def initialize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def finalize_options(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
root = os.path.dirname(os.path.abspath(__file__))
|
|
|
|
os.chdir(root)
|
|
|
|
|
|
|
|
# removed counter (ext: count)
|
|
|
|
removed = {}
|
|
|
|
|
|
|
|
def removepath(path):
|
|
|
|
try:
|
|
|
|
os.unlink(path)
|
|
|
|
except OSError: # ENOENT
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
ext = path.split('.')[-1]
|
|
|
|
removed.setdefault(ext, 0)
|
|
|
|
removed[ext] += 1
|
|
|
|
|
|
|
|
# remove *.o not belonging to Python extensions, and .py[cdo], .so files
|
|
|
|
for pat in ['*.o', '*.py[cdo]', '*.so']:
|
|
|
|
for path in self._rglob(pat):
|
|
|
|
removepath(path)
|
|
|
|
|
|
|
|
# remove .c generated from Cython .pyx
|
|
|
|
for path in self._rglob('*.pyx'):
|
|
|
|
cpath = '%s.c' % path[:-4]
|
|
|
|
removepath(cpath)
|
|
|
|
|
|
|
|
# print short summary
|
|
|
|
if removed:
|
|
|
|
summary = 'removed %s files' % (
|
|
|
|
', '.join('%s .%s' % (count, ext)
|
|
|
|
for ext, count in sorted(removed.iteritems())))
|
|
|
|
self.announce(summary, level=distutils.log.INFO)
|
|
|
|
|
|
|
|
def _rglob(self, patten):
|
|
|
|
# recursive glob
|
|
|
|
for dirname, dirs, files in os.walk('.'):
|
|
|
|
for name in fnmatch.filter(files, patten):
|
|
|
|
yield os.path.join(dirname, name)
|
|
|
|
|
2013-06-20 23:16:36 +04:00
|
|
|
setup(
|
2013-06-20 23:57:57 +04:00
|
|
|
name='fbhgext',
|
2016-08-26 16:27:59 +03:00
|
|
|
version='1.0',
|
|
|
|
author='Facebook Source Control Team',
|
|
|
|
maintainer='Facebook Source Control Team',
|
|
|
|
maintainer_email='sourcecontrol-dev@fb.com',
|
|
|
|
url='https://bitbucket.org/facebook/hg-experimental/',
|
|
|
|
description='Facebook mercurial extensions',
|
2013-06-20 23:16:36 +04:00
|
|
|
long_description="",
|
2016-08-26 16:27:59 +03:00
|
|
|
keywords='facebook fb hg mercurial shallow remote filelog',
|
|
|
|
license='GPLv2+',
|
2016-10-08 19:08:29 +03:00
|
|
|
packages=packages,
|
|
|
|
install_requires=requires,
|
|
|
|
py_modules=py_modules,
|
|
|
|
ext_modules = ext_modules,
|
2017-02-24 01:03:03 +03:00
|
|
|
libraries=libraries,
|
2017-05-02 19:12:56 +03:00
|
|
|
cmdclass={
|
|
|
|
'clean_ext': CleanExtCommand,
|
|
|
|
}
|
2013-06-20 23:16:36 +04:00
|
|
|
)
|