Skip to content

Commit a766c55

Browse files
committed
Update MANIFEST.in and examples
1 parent 87ca849 commit a766c55

File tree

6 files changed

+9
-52
lines changed

6 files changed

+9
-52
lines changed

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
include README.md
22
include LICENSE
33
recursive-include examples *.py
4-
recursive-include cpulimiter *.py
4+
recursive-include cpulimiter *.py *.dll

examples/advanced_interactive.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,20 +157,6 @@ def main():
157157
print("❌ Invalid choice")
158158

159159
if __name__ == "__main__":
160-
import ctypes
161-
162-
# Check for admin privileges
163-
try:
164-
is_admin = ctypes.windll.shell32.IsUserAnAdmin()
165-
except:
166-
is_admin = False
167-
168-
if not is_admin:
169-
print("🔐 Administrator privileges required")
170-
print("🔄 Please run as Administrator")
171-
input("Press Enter to exit...")
172-
sys.exit(1)
173-
174160
try:
175161
main()
176162
except KeyboardInterrupt:

examples/basic_usage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# 1. Initialize the limiter
88
limiter = CpuLimiter()
99

10-
app_name = "notepad.exe"
10+
app_name = "chrome.exe"
1111

1212
# 3. Add the process to the limiter
1313
limiter.add(process_name=app_name, limit_percentage=95)

examples/cpu_saver.py

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
- Performance optimization
1313
1414
Requirements:
15-
- Administrator privileges (the script will try to restart itself with admin rights)
1615
- cpulimiter library: pip install cpulimiter
1716
"""
1817

@@ -45,12 +44,6 @@
4544
"csrss.exe", # Client/Server Runtime
4645
}
4746

48-
def is_admin():
49-
"""Checks if the script is running with Administrator privileges."""
50-
try:
51-
return ctypes.windll.shell32.IsUserAnAdmin()
52-
except:
53-
return False
5447

5548
def main():
5649
"""Main loop to monitor and save CPU automatically."""
@@ -132,18 +125,4 @@ def main():
132125
print("✅ CPU Saver stopped cleanly")
133126

134127
if __name__ == "__main__":
135-
# Check for admin privileges
136-
if not is_admin():
137-
print("🔐 Administrator privileges required for CPU Saver")
138-
print("🔄 Attempting to restart with elevated privileges...")
139-
try:
140-
ctypes.windll.shell32.ShellExecuteW(
141-
None, "runas", sys.executable, " ".join(sys.argv), None, 1
142-
)
143-
except Exception as e:
144-
print(f"❌ Failed to restart with admin privileges: {e}")
145-
print("💡 Please run this script as Administrator manually")
146-
sys.exit(1)
147-
else:
148-
print("✅ Running with Administrator privileges")
149-
main()
128+
main()

examples/simple_limit.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
77
Usage:
88
1. Install: pip install cpulimiter
9-
2. Run this script as Administrator
9+
2. Run this script
1010
3. The script will limit Chrome and Spotify to 10% CPU usage
1111
"""
1212

@@ -58,16 +58,4 @@ def main():
5858

5959

6060
if __name__ == "__main__":
61-
import ctypes
62-
import sys
63-
# check if the script is run with Administrator
64-
if ctypes.windll.shell32.IsUserAnAdmin():
65-
main()
66-
else:
67-
print("⚠️ This script requires Administrator privileges.")
68-
choice = input("Do you want to restart with admin rights? (y/n): ").strip().lower()
69-
if choice == 'y':
70-
print("🔄 Attempting to re-launch with elevation...")
71-
ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1)
72-
else:
73-
print("❌ Exiting. Please run as Administrator manually.")
61+
main()

setup.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
long_description_content_type="text/markdown",
1414
url="https://github.com/Ahmed-Ashraf-dv/CPULimiter",
1515
packages=find_packages(),
16+
include_package_data=True,
17+
package_data={
18+
'cpulimiter': ['limiter_engine.dll'],
19+
},
1620
classifiers=[
1721
"Development Status :: 4 - Beta",
1822
"Intended Audience :: Developers",

0 commit comments

Comments
 (0)