Skip to content

Commit 92811b9

Browse files
committed
fix-win
1 parent 7b3212a commit 92811b9

File tree

4 files changed

+75
-33
lines changed

4 files changed

+75
-33
lines changed

.github/workflows/nightly_build.yml

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -112,14 +112,8 @@ jobs:
112112
python3 -mpip install --upgrade pip
113113
- name: Install tensordict
114114
run: |
115-
if [[ "$OSTYPE" == "darwin"* ]]; then
116-
brew install cmake
117-
else
118-
sudo apt-get update
119-
sudo apt-get install -y cmake
120-
fi
121-
python3 -mpip install "pybind11[global]"
122-
python3 -mpip install git+https://github.com/pytorch/tensordict.git
115+
export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH"
116+
python3 -mpip install tensordict-nightly
123117
- name: Install test dependencies
124118
run: |
125119
export PATH="/opt/python/${{ matrix.python_version[1] }}/bin:$PATH"
@@ -278,15 +272,7 @@ jobs:
278272
- name: Install tensordict
279273
shell: bash
280274
run: |
281-
if ! choco -v &> /dev/null; then
282-
powershell -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
283-
fi
284-
# Install cmake using Chocolatey
285-
choco install cmake -y
286-
# Install necessary Python packages
287-
python -m pip install --upgrade pip
288-
python -m pip install "pybind11[global]"
289-
python3 -mpip install git+https://github.com/pytorch/tensordict.git
275+
python3 -mpip install tensordict-nightly
290276
- name: Download built wheels
291277
uses: actions/download-artifact@v4
292278
with:

build_nightly.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,16 @@ echo "$(date +%Y.%m.%d)" > version.txt
4040

4141
# Build the package
4242
echo "Building nightly package..."
43-
python -m build
43+
echo "DEBUG: Current working directory: $(pwd)"
44+
echo "DEBUG: Contents of current directory: $(ls -la)"
45+
echo "DEBUG: Contents of torchrl/csrc: $(ls -la torchrl/csrc 2>/dev/null || echo 'Directory not found')"
46+
echo "DEBUG: Python version: $(python --version)"
47+
echo "DEBUG: Platform: $(python -c 'import sys; print(sys.platform)')"
48+
49+
# Install build dependencies
50+
echo "Installing build dependencies..."
51+
python -m pip install wheel setuptools==65.3.0
52+
53+
python setup.py bdist_wheel
4454

4555
echo "Nightly build completed successfully!"

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["setuptools", "wheel", "torch", "ninja"]
2+
requires = ["setuptools", "wheel", "torch", "ninja", "numpy", "pybind11[global]", "cmake"]
33
build-backend = "setuptools.build_meta"
44

55
[project]

setup.py

Lines changed: 60 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,69 @@ def get_extensions():
1010
extension = CppExtension
1111

1212
extra_link_args = []
13-
extra_compile_args = {
14-
"cxx": [
15-
"-O3",
16-
"-std=c++17",
17-
"-fdiagnostics-color=always",
18-
]
19-
}
20-
debug_mode = os.getenv("DEBUG", "0") == "1"
21-
if debug_mode:
22-
logging.info("Compiling in debug mode")
13+
14+
# Debug output
15+
print(f"DEBUG: Platform detected: {sys.platform}")
16+
print(f"DEBUG: Platform == 'win32': {sys.platform == 'win32'}")
17+
18+
# Platform-specific compiler flags
19+
if sys.platform == "win32":
20+
print("DEBUG: Using MSVC flags for Windows")
21+
# MSVC flags for Windows
22+
extra_compile_args = {
23+
"cxx": [
24+
"/O2", # Optimization level 2 (equivalent to -O3)
25+
"/std:c++17", # C++17 standard
26+
"/EHsc", # Exception handling model
27+
]
28+
}
29+
debug_mode = os.getenv("DEBUG", "0") == "1"
30+
if debug_mode:
31+
logging.info("Compiling in debug mode")
32+
extra_compile_args = {
33+
"cxx": [
34+
"/Od", # No optimization (equivalent to -O0)
35+
"/Zi", # Generate debug info
36+
"/std:c++17", # C++17 standard
37+
"/EHsc", # Exception handling model
38+
]
39+
}
40+
extra_link_args = ["/DEBUG"]
41+
else:
42+
print("DEBUG: Using GCC/Clang flags for Unix-like systems")
43+
# GCC/Clang flags for Unix-like systems
2344
extra_compile_args = {
2445
"cxx": [
25-
"-O0",
26-
"-fno-inline",
27-
"-g",
46+
"-O3",
2847
"-std=c++17",
2948
"-fdiagnostics-color=always",
3049
]
3150
}
32-
extra_link_args = ["-O0", "-g"]
51+
debug_mode = os.getenv("DEBUG", "0") == "1"
52+
if debug_mode:
53+
logging.info("Compiling in debug mode")
54+
extra_compile_args = {
55+
"cxx": [
56+
"-O0",
57+
"-fno-inline",
58+
"-g",
59+
"-std=c++17",
60+
"-fdiagnostics-color=always",
61+
]
62+
}
63+
extra_link_args = ["-O0", "-g"]
64+
65+
print(f"DEBUG: Extra compile args: {extra_compile_args}")
66+
print(f"DEBUG: Extra link args: {extra_link_args}")
3367

3468
extensions_dir = "torchrl/csrc"
3569

3670
# Get just the filenames, not full paths
3771
cpp_files = glob.glob(os.path.join(extensions_dir, "*.cpp"))
3872
sources = [os.path.relpath(f) for f in cpp_files]
73+
print(f"DEBUG: C++ source files: {sources}")
74+
print(f"DEBUG: Extensions directory exists: {os.path.exists(extensions_dir)}")
75+
print(f"DEBUG: Contents of {extensions_dir}: {os.listdir(extensions_dir) if os.path.exists(extensions_dir) else 'Directory not found'}")
3976

4077
include_dirs = ["."]
4178
python_include_dir = os.getenv("PYTHON_INCLUDE_DIR")
@@ -51,14 +88,23 @@ def get_extensions():
5188
)
5289
]
5390

91+
print(f"DEBUG: Extension modules: {ext_modules}")
5492
return ext_modules
5593

5694
def main():
95+
print("DEBUG: Starting setup.py main function")
5796
setup_kwargs = {
5897
"ext_modules": get_extensions(),
5998
"cmdclass": {"build_ext": BuildExtension.with_options()},
99+
"packages": ["torchrl"],
100+
"package_data": {
101+
"torchrl": ["version.py"],
102+
},
103+
"include_package_data": True,
104+
"zip_safe": False,
60105
}
61106

107+
print(f"DEBUG: Setup kwargs: {setup_kwargs}")
62108
setup(**setup_kwargs)
63109

64110
if __name__ == "__main__":

0 commit comments

Comments
 (0)