Unverified Commit 2b39f1e8 authored by Nikita Shulga's avatar Nikita Shulga Committed by GitHub
Browse files

Do not build unless setup.py is top-level scope (#2969)

I.e. put all file system altering operations under `if __name__ == "__main__":`
parent 052edcec
...@@ -44,7 +44,6 @@ if os.getenv('BUILD_VERSION'): ...@@ -44,7 +44,6 @@ if os.getenv('BUILD_VERSION'):
version = os.getenv('BUILD_VERSION') version = os.getenv('BUILD_VERSION')
elif sha != 'Unknown': elif sha != 'Unknown':
version += '+' + sha[:7] version += '+' + sha[:7]
print("Building wheel {}-{}".format(package_name, version))
def write_version_file(): def write_version_file():
...@@ -57,10 +56,6 @@ def write_version_file(): ...@@ -57,10 +56,6 @@ def write_version_file():
f.write(" cuda = _check_cuda_version()\n") f.write(" cuda = _check_cuda_version()\n")
write_version_file()
readme = open('README.rst').read()
pytorch_dep = 'torch' pytorch_dep = 'torch'
if os.getenv('PYTORCH_VERSION'): if os.getenv('PYTORCH_VERSION'):
pytorch_dep += "==" + os.getenv('PYTORCH_VERSION') pytorch_dep += "==" + os.getenv('PYTORCH_VERSION')
...@@ -397,30 +392,38 @@ class clean(distutils.command.clean.clean): ...@@ -397,30 +392,38 @@ class clean(distutils.command.clean.clean):
distutils.command.clean.clean.run(self) distutils.command.clean.clean.run(self)
setup( if __name__ == "__main__":
# Metadata print("Building wheel {}-{}".format(package_name, version))
name=package_name,
version=version, write_version_file()
author='PyTorch Core Team',
author_email='soumith@pytorch.org', with open('README.rst') as f:
url='https://github.com/pytorch/vision', readme = f.read()
description='image and video datasets and models for torch deep learning',
long_description=readme, setup(
license='BSD', # Metadata
name=package_name,
# Package info version=version,
packages=find_packages(exclude=('test',)), author='PyTorch Core Team',
package_data={ author_email='soumith@pytorch.org',
package_name: ['*.dll', '*.dylib', '*.so'] url='https://github.com/pytorch/vision',
}, description='image and video datasets and models for torch deep learning',
zip_safe=False, long_description=readme,
install_requires=requirements, license='BSD',
extras_require={
"scipy": ["scipy"], # Package info
}, packages=find_packages(exclude=('test',)),
ext_modules=get_extensions(), package_data={
cmdclass={ package_name: ['*.dll', '*.dylib', '*.so']
'build_ext': BuildExtension.with_options(no_python_abi_suffix=True), },
'clean': clean, 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,
}
)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment