Skip to content

Commit

Permalink
Do not build unless setup.py is top-level scope (#2969)
Browse files Browse the repository at this point in the history
I.e. put all file system altering operations under `if __name__ == "__main__":`
  • Loading branch information
malfet authored Nov 9, 2020
1 parent 052edce commit 2b39f1e
Showing 1 changed file with 35 additions and 32 deletions.
67 changes: 35 additions & 32 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ def get_dist(pkgname):
version = os.getenv('BUILD_VERSION')
elif sha != 'Unknown':
version += '+' + sha[:7]
print("Building wheel {}-{}".format(package_name, version))


def write_version_file():
Expand All @@ -57,10 +56,6 @@ def write_version_file():
f.write(" cuda = _check_cuda_version()\n")


write_version_file()

readme = open('README.rst').read()

pytorch_dep = 'torch'
if os.getenv('PYTORCH_VERSION'):
pytorch_dep += "==" + os.getenv('PYTORCH_VERSION')
Expand Down Expand Up @@ -397,30 +392,38 @@ def run(self):
distutils.command.clean.clean.run(self)


setup(
# Metadata
name=package_name,
version=version,
author='PyTorch Core Team',
author_email='soumith@pytorch.org',
url='https://github.com/pytorch/vision',
description='image and video datasets and models for torch deep learning',
long_description=readme,
license='BSD',

# Package info
packages=find_packages(exclude=('test',)),
package_data={
package_name: ['*.dll', '*.dylib', '*.so']
},
zip_safe=False,
install_requires=requirements,
extras_require={
"scipy": ["scipy"],
},
ext_modules=get_extensions(),
cmdclass={
'build_ext': BuildExtension.with_options(no_python_abi_suffix=True),
'clean': clean,
}
)
if __name__ == "__main__":
print("Building wheel {}-{}".format(package_name, version))

write_version_file()

with open('README.rst') as f:
readme = f.read()

setup(
# Metadata
name=package_name,
version=version,
author='PyTorch Core Team',
author_email='soumith@pytorch.org',
url='https://github.com/pytorch/vision',
description='image and video datasets and models for torch deep learning',
long_description=readme,
license='BSD',

# Package info
packages=find_packages(exclude=('test',)),
package_data={
package_name: ['*.dll', '*.dylib', '*.so']
},
zip_safe=False,
install_requires=requirements,
extras_require={
"scipy": ["scipy"],
},
ext_modules=get_extensions(),
cmdclass={
'build_ext': BuildExtension.with_options(no_python_abi_suffix=True),
'clean': clean,
}
)

0 comments on commit 2b39f1e

Please sign in to comment.