Don't include libiomp with conda install on MacOS (#78632)

Fixes #78490

Following command:
```
conda install pytorch torchvision torchaudio -c pytorch-nightly
```

Installs libiomp . Hence we don't want to package libiomp with conda installs. However, we still keep it for libtorch and wheels.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/78632
Approved by: https://github.com/malfet
This commit is contained in:
Andrey Talman
2022-06-01 22:06:16 +00:00
committed by PyTorch MergeBot
parent 6671b504f7
commit ca7f948806

View File

@ -310,6 +310,7 @@ cmake_python_include_dir = sysconfig.get_path("include")
# Version, create_version_file, and package_name
################################################################################
package_name = os.getenv('TORCH_PACKAGE_NAME', 'torch')
package_type = os.getenv('PACKAGE_TYPE', 'wheel')
version = get_torch_version()
report("Building wheel {}-{}".format(package_name, version))
@ -430,8 +431,7 @@ class build_ext(setuptools.command.build_ext.build_ext):
# Copy libiomp5.dylib inside the wheel package on OS X
def _embed_libiomp(self):
if not IS_DARWIN:
return
lib_dir = os.path.join(self.build_lib, 'torch', 'lib')
libtorch_cpu_path = os.path.join(lib_dir, 'libtorch_cpu.dylib')
if not os.path.exists(libtorch_cpu_path):
@ -523,7 +523,8 @@ class build_ext(setuptools.command.build_ext.build_ext):
# It's an old-style class in Python 2.7...
setuptools.command.build_ext.build_ext.run(self)
self._embed_libiomp()
if IS_DARWIN and package_type != 'conda':
self._embed_libiomp()
# Copy the essential export library to compile C++ extensions.
if IS_WINDOWS: