Conda Cython Build PYD/SO Files - python

I have built a module using "conda build packagename".
However, the built module ends up in "\Anaconda\conda-bld\work".
The module can only be imported (using "import packagename")if I cd into this directory, then run Python. I have tried placing the files in "\Anaconda\conda-bld\work" in "\Anaconda\Lib\site-packages", however I am not able to import the module from any directory; I must be in "\Anaconda\Lib\site-packages".
Is the only solution to put the .PYD file/ .SO file next to the executable Python file or is there a way to let Python know there is a new module installed?
Thank you for your help.

In the conda build script, you need to install the files, not just build them. For Python, this typically means running python setup.py install in the build.sh, and including python in your build dependencies so that the python will install into the build environment.

Related

Can't import python modules with Nodejs and Python shell

I'm trying to run a python script through nodejs pythonshell but I keep getting a modulenotfound error when trying to import the libraries that I downloaded with pip. I installed pythonshell on my computer with npm, so I know that's not the problem.
When you install packages you will install them to a directory named site-packages
In your main directory this can be found from:
your-directory/lib/Python3.6/site-packages
If you copy and paste the files you'd like to run into this folder, and change the script path accordingly, the file will find all imported modules.
This is because the python shell was looking in the current directory for your packages and not finding them.

Run bash script with pip install

I have created a wrapper for c++ library using python.
I have a bash script that will download c++ code, compile it and copy the generated .so file to the python package.
Then I have written the setup.py so that when you use pip install package-name, it will install the .so file also.
What I need is to run that bash script when I type pip install package-name. Currently what I have to do is run the bash script first and then use pip install package-name to install.
And I need to upload the code to the Python Package Index. So the solution has to be compatible with that also*.
PS: I know about the Extension module in setuptools. I can't use that because I need to download something and run a Makefile after editing it. I do all of that with the bash script.
* I learnt that this requirement is not possible. So please ignore that one.
Thank you..

install python package to sys.path

I am new to python3 and I want to create a package that I can import from other python script.
So I created my package and I run
python3 setup.py sdist
to create my tarball.
when I move it to another directory to untar it and then install the package with
python3 setup.py install -user --prefix=
it's fine there is no error and it install in my site-package of python and when I run python3 I can import my lib and call its function.
But when I want to import this package in a script it tell me
ImportError: No module named test_package.pck1.addition
I know that I can add
import sys
sys.path.append('./test_package.0.1')
to fix it but I want to avoid that because it would mean always having to modify the path to the package when trying to use it in another script.
So How can I import my package without modifying the sys.path. Or how can I an install my package so that my script won't need that.
I tried a lot of installation process (using pip3, trying different option etc) nothing work as I expect it.
you created the python package 'toto.py'. you want to import it in the python script 'tata.py'. you write 'import toto' in the tata script and you place the file 'toto.py' in a directory contained in the PYTHONPATH environment variable.
Although I don't use python 2, it seems to me it is the same for python 2 and 3. Thus I'm not sure I understood the question.

Compile C executable during python package installation

I've got a python package which requires to compile and install executable written in C (it is helper program and acts as a script), which will need to go into proper place, i.e. same place where scripts would go ($VIRTUAL_ENV/bin, /usr/local/bin, etc).
What would be the correct way to implement this?
I found an example, but it works only when using pip to install the package, but fail when I try to use python setup.py install: they will build the executable, but will not install it during the "install bdist_egg" stage.

Setup tools install command differences

What are the differences between the below commands
python setup.py install develop
Doesn't work for me error No such file or directory: 'build/bdist.macosx-10.7-intel/egg/test-easy-install-37886.pth'
python setup.py develop
Works for me appears to make an .egg link file
python setup.py install
Works for me appears to make a .egg file which in .zip file format
Develop is a setuptools / distribute feature that allows you to add a project
to your Python environment without installing it - so you can continue
its "development"
In other words, when you call "python setup.py develop", setuptools will
compile the metadata and hook your project into Python's site-package,
but the packages and modules that will be used are the one in the
directory where you've run that command.
This is useful to continue working on your code and testing it without
having to run "python setup.py install" on every run
With develop, Python 'pseudo-installs' a package by running the setup.py script instead of install. The difference is a modification of the environment (it doesn't with develop), so a package can be imported from it's current location instead of a site-package directory. The advantage of this is you can develop packages that are being used by other packages, and you can modify source code in place with develop.
As far as "setup.py install develop", I've never seen anyone use that before, sorry.
source
source
source
python setup.py install develop
Is a wrong command.
When you use develop you use the current code when you run your application.
When you useĀ install and then modify you code, your modifications will not be taken in account while running your app. until you rerun install or develop.

Categories

Resources