Adding Custom Modules

All other Source.Python topics and issues.
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Adding Custom Modules

Postby D3CEPTION » Thu Feb 04, 2016 9:35 pm

Hello Everyone :rolleyes: ,

MY GOAL:
trying to add a custom c/c++ module into sp to later import in a script from..

STEPS TAKEN:
step1) aquired a .pyd file via anaconda of my desired module. ( anaconda = python distribution)
step2) putting the same ".pyd" into "csgo\addons\source-python\Python3\plat-win"

PROBLEM:
after starting my server the import command returns "ImportError: No module named 'x'"

my assumptions:
1) dependencies are missing, that were installed into anaconda == the whole method is flawed?
2) i have to register the module somewhere in sp
3) i have to use a special name syntax starting with "_"

is anybody familliar with this issue and wants to offer a solution?
thanks in advance
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Feb 05, 2016 5:45 pm

I moved this thread, because it's not a module/package submission.

D3CEPTION wrote:step2) putting the same ".pyd" into "csgo\addons\source-python\Python3\plat-win"

site-packages should be placed here: https://github.com/Source-Python-Dev-Team/Source.Python/tree/master/addons/source-python/packages/site-packages
custom SP packages here: https://github.com/Source-Python-Dev-Team/Source.Python/tree/master/addons/source-python/packages/custom


D3CEPTION wrote:1) dependencies are missing, that were installed into anaconda == the whole method is flawed?

Since you didn't tell us the name of the package and the original error message, this could be a possible issue.

D3CEPTION wrote:2) i have to register the module somewhere in sp

No, its directory just needs to be in sys.path.

D3CEPTION wrote:3) i have to use a special name syntax starting with "_"

The name doesn't matter.

Which Python version is your anaconda distribution running? Source.Python currently runs with 3.4 (CPython).
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Postby D3CEPTION » Fri Feb 05, 2016 8:12 pm


i know about those, but do those work for adding dlls?
is the second one for dlls? im not familiar with this terminology.
is my "dll" a "package" in this context? ( language-wise module suits better)

Ayuto wrote:Which Python version is your anaconda distribution running? Source.Python currently runs with 3.4 (CPython).

im using 3.5, but my module uses a previous version, so i thought i should be fine?

thanks for helping!
User avatar
Ayuto
Project Leader
Posts: 2193
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Postby Ayuto » Fri Feb 05, 2016 8:27 pm

D3CEPTION wrote:i know about those, but do those work for adding dlls?
is the second one for dlls?

Yes, it doesn't matter whether they are dll/pyd files or normal py files. The only thing that matters is that the containing directory is in sys.path (all of the three mentioned directories are in sys.path).

D3CEPTION wrote:is my "dll" a "package" in this context? ( language-wise module suits better)

Both is possible.

D3CEPTION wrote:im using 3.5, but my module uses a previous version, so i thought i should be fine?

Ideally, the module is compiled for CPython 3.4, because that's the version that Source.Python runs with.

Ayuto wrote:
D3CEPTION wrote:1) dependencies are missing, that were installed into anaconda == the whole method is flawed?

Since you didn't tell us the name of the package and the original error message, this could be a possible issue.

Please tell me the original error message and the package/module name you are trying to import.

Edit: Just saw your update. Yes, 32bit!
User avatar
D3CEPTION
Senior Member
Posts: 129
Joined: Tue Jan 26, 2016 1:24 pm
Location: Switzerland

Postby D3CEPTION » Fri Feb 05, 2016 9:01 pm

okay i updated my modules env, its working now, thanks ayuto!
Yes, it doesn't matter whether they are dll/pyd files or normal py files. The only thing that matters is that the containing directory is in sys.path (all of the three mentioned directories are in sys.path).

thats very easy, great :) i just imagined it to be harder to register modules/packages, therefor my confusion..

Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 22 guests