Skip to content

Commit 272dfc7

Browse files
malfetfacebook-github-bot
authored andcommitted
Add MANIFEST.in (pytorch#52908)
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
1 parent b5ae8e6 commit 272dfc7

File tree

4 files changed

+59
-8
lines changed

4 files changed

+59
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ caffe2/version.py
237237
# setup.py intermediates
238238
.eggs
239239
caffe2.egg-info
240+
MANIFEST
240241

241242
# Atom/Watchman required file
242243
.watchmanconfig

.jenkins/pytorch/build-asan.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,14 @@ CC="clang" CXX="clang++" LDSHARED="clang --shared" \
3636
USE_ASAN=1 USE_CUDA=0 USE_MKLDNN=0 \
3737
python setup.py install
3838

39+
40+
# Test building via the sdist source tarball
41+
python setup.py sdist
42+
mkdir -p /tmp/tmp
43+
pushd /tmp/tmp
44+
tar zxf "$(dirname "${BASH_SOURCE[0]}")/../../dist/"*.tar.gz
45+
cd torch-*
46+
python setup.py build --cmake-only
47+
popd
48+
3949
assert_git_not_dirty

MANIFEST.in

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
include MANIFEST.in
2+
include CMakeLists.txt
3+
include CITATION
4+
include LICENSE
5+
include NOTICE
6+
include .gitmodules
7+
include mypy.ini
8+
include requirements.txt
9+
include version.txt
10+
recursive-include android *.*
11+
recursive-include aten *.*
12+
recursive-include binaries *.*
13+
recursive-include c10 *.*
14+
recursive-include caffe2 *.*
15+
recursive-include cmake *.*
16+
recursive-include torch *.*
17+
recursive-include tools *.*
18+
recursive-include test *.*
19+
recursive-include docs *.*
20+
recursive-include ios *.*
21+
recursive-include third_party *
22+
recursive-include test *.*
23+
recursive-include benchmarks *.*
24+
recursive-include scripts *.*
25+
recursive-include mypy_plugins *.*
26+
recursive-include modules *.*
27+
prune */__pycache__
28+
global-exclude *.o *.so *.dylib *.a .git *.pyc *.swp

setup.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,7 @@
194194
import setuptools.command.build_ext
195195
import setuptools.command.install
196196
import distutils.command.clean
197+
import distutils.command.sdist
197198
import distutils.sysconfig
198199
import filecmp
199200
import shutil
@@ -238,7 +239,7 @@
238239
break
239240
if arg == '-q' or arg == '--quiet':
240241
VERBOSE_SCRIPT = False
241-
if arg == 'clean' or arg == 'egg_info':
242+
if arg in ['clean', 'egg_info', 'sdist']:
242243
RUN_BUILD_DEPS = False
243244
filtered_args.append(arg)
244245
sys.argv = filtered_args
@@ -286,10 +287,8 @@ def report(*args):
286287

287288
cmake = CMake()
288289

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

291+
def check_submodules():
293292
def check_file(f):
294293
if bool(os.getenv("USE_SYSTEM_LIBS", False)):
295294
return
@@ -310,6 +309,12 @@ def check_file(f):
310309
check_file(os.path.join(third_party_path, 'onnx', 'third_party',
311310
'benchmark', 'CMakeLists.txt'))
312311

312+
313+
# all the work we need to do _before_ setup runs
314+
def build_deps():
315+
report('-- Building version ' + version)
316+
317+
check_submodules()
313318
check_pydep('yaml', 'pyyaml')
314319

315320
build_caffe2(version=version,
@@ -599,7 +604,7 @@ def run(self):
599604

600605
class install(setuptools.command.install.install):
601606
def run(self):
602-
setuptools.command.install.install.run(self)
607+
super().run()
603608

604609

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

626-
# It's an old-style class in Python 2.7...
627-
distutils.command.clean.clean.run(self)
631+
super().run()
632+
633+
634+
class sdist(distutils.command.sdist.sdist):
635+
def run(self):
636+
with concat_license_files():
637+
super().run()
638+
628639

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

764775
cmdclass = {
776+
'bdist_wheel': wheel_concatenate,
765777
'build_ext': build_ext,
766778
'clean': clean,
767779
'install': install,
768-
'bdist_wheel': wheel_concatenate,
780+
'sdist': sdist,
769781
}
770782

771783
entry_points = {

0 commit comments

Comments
 (0)