Skip to content

Commit

Permalink
Add MANIFEST.in (pytorch#52908)
Browse files Browse the repository at this point in the history
Summary:
Do not build PyTorch if `setup.py` is called with  'sdist' option
Regenerate bundled license while sdist package is being built
Refactor `check_submodules` out of `build_deps` and check that submodules project are present during source package build stage.

Test that sdist package is configurable during `asan-build` step

Fixes pytorch#52843

Pull Request resolved: pytorch#52908

Reviewed By: walterddr

Differential Revision: D26685176

Pulled By: malfet

fbshipit-source-id: 972a40ae36e194c0b4e0fc31c5e1af1e7a815185
  • Loading branch information
malfet authored and facebook-github-bot committed Mar 2, 2021
1 parent b5ae8e6 commit 272dfc7
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 8 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ caffe2/version.py
# setup.py intermediates
.eggs
caffe2.egg-info
MANIFEST

# Atom/Watchman required file
.watchmanconfig
Expand Down
10 changes: 10 additions & 0 deletions .jenkins/pytorch/build-asan.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,14 @@ CC="clang" CXX="clang++" LDSHARED="clang --shared" \
USE_ASAN=1 USE_CUDA=0 USE_MKLDNN=0 \
python setup.py install


# Test building via the sdist source tarball
python setup.py sdist
mkdir -p /tmp/tmp
pushd /tmp/tmp
tar zxf "$(dirname "${BASH_SOURCE[0]}")/../../dist/"*.tar.gz
cd torch-*
python setup.py build --cmake-only
popd

assert_git_not_dirty
28 changes: 28 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
include MANIFEST.in
include CMakeLists.txt
include CITATION
include LICENSE
include NOTICE
include .gitmodules
include mypy.ini
include requirements.txt
include version.txt
recursive-include android *.*
recursive-include aten *.*
recursive-include binaries *.*
recursive-include c10 *.*
recursive-include caffe2 *.*
recursive-include cmake *.*
recursive-include torch *.*
recursive-include tools *.*
recursive-include test *.*
recursive-include docs *.*
recursive-include ios *.*
recursive-include third_party *
recursive-include test *.*
recursive-include benchmarks *.*
recursive-include scripts *.*
recursive-include mypy_plugins *.*
recursive-include modules *.*
prune */__pycache__
global-exclude *.o *.so *.dylib *.a .git *.pyc *.swp
28 changes: 20 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@
import setuptools.command.build_ext
import setuptools.command.install
import distutils.command.clean
import distutils.command.sdist
import distutils.sysconfig
import filecmp
import shutil
Expand Down Expand Up @@ -238,7 +239,7 @@
break
if arg == '-q' or arg == '--quiet':
VERBOSE_SCRIPT = False
if arg == 'clean' or arg == 'egg_info':
if arg in ['clean', 'egg_info', 'sdist']:
RUN_BUILD_DEPS = False
filtered_args.append(arg)
sys.argv = filtered_args
Expand Down Expand Up @@ -286,10 +287,8 @@ def report(*args):

cmake = CMake()

# all the work we need to do _before_ setup runs
def build_deps():
report('-- Building version ' + version)

def check_submodules():
def check_file(f):
if bool(os.getenv("USE_SYSTEM_LIBS", False)):
return
Expand All @@ -310,6 +309,12 @@ def check_file(f):
check_file(os.path.join(third_party_path, 'onnx', 'third_party',
'benchmark', 'CMakeLists.txt'))


# all the work we need to do _before_ setup runs
def build_deps():
report('-- Building version ' + version)

check_submodules()
check_pydep('yaml', 'pyyaml')

build_caffe2(version=version,
Expand Down Expand Up @@ -599,7 +604,7 @@ def run(self):

class install(setuptools.command.install.install):
def run(self):
setuptools.command.install.install.run(self)
super().run()


class clean(distutils.command.clean.clean):
Expand All @@ -623,8 +628,14 @@ def run(self):
except OSError:
shutil.rmtree(filename, ignore_errors=True)

# It's an old-style class in Python 2.7...
distutils.command.clean.clean.run(self)
super().run()


class sdist(distutils.command.sdist.sdist):
def run(self):
with concat_license_files():
super().run()


def configure_extension_build():
r"""Configures extension build options according to system environment and user's choice.
Expand Down Expand Up @@ -762,10 +773,11 @@ def make_relative_rpath_args(path):
)

cmdclass = {
'bdist_wheel': wheel_concatenate,
'build_ext': build_ext,
'clean': clean,
'install': install,
'bdist_wheel': wheel_concatenate,
'sdist': sdist,
}

entry_points = {
Expand Down

0 comments on commit 272dfc7

Please sign in to comment.