setup.py does not find package installed via conda - python

I'm developing my own conda package. I'm using a setup.py in the process of generating that package. When developing, it can be useful to conda install --no-deps package and ./setup.py develop in the repo. The install works, but setup.py errors out because it cannot satisfy a dependency. There is another package with the same name but to low version on pypi. However, the correct version of this dependency is already installed via conda. Why does it first try to install the package before checking if it is already installed? How can I make setup.py realize that nothing needs to be installed?
How is the package built?
I have this blt.bat:
"%PYTHON%" setup.py install --single-version-externally-managed --record=record.txt
if errorlevel 1 exit 1
and the dependencies listed in the meta.yaml. It falls to setup.py to define the package version (read from a .py file), define the entry points and the included non-Python files. It gets the dependencies by parsing the meta.yaml.
What is the error message?
This is the output of setup.py develop:
$ python setup.py develop
running develop
C:\ProgramData\Miniconda3\envs\my_env\lib\site-packages\setuptools\command\easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
C:\ProgramData\Miniconda3\envs\my_env\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running egg_info
writing my_package.egg-info\PKG-INFO
writing dependency_links to my_package.egg-info\dependency_links.txt
writing entry points to my_package.egg-info\entry_points.txt
writing requirements to my_package.egg-info\requires.txt
writing top-level names to my_package.egg-info\top_level.txt
reading manifest file 'my_package.egg-info\SOURCES.txt'
writing manifest file 'my_package.egg-info\SOURCES.txt'
running build_ext
Creating c:\programdata\miniconda3\envs\my_env\lib\site-packages\my_package.egg-link (link to .)
my_package 6.1.0 is already the active version in easy-install.pth
Installing entry_point0-script.py script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installing entry_point0.exe script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installing entry_point1-script.py script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installing entry_point1.exe script to C:\ProgramData\Miniconda3\envs\my_env\Scripts
Installed c:\users\jpoppinga\my_git_repository
Processing dependencies for my_package==6.1.0
Searching for my_dep<13.1,>=13.0.1
Reading https://pypi.org/simple/my_dep/
C:\ProgramData\Miniconda3\envs\my_env\lib\site-packages\pkg_resources\__init__.py:123: PkgResourcesDeprecationWarning: is an invalid version and will not be supported in a future release
warnings.warn(
No local packages or working download links found for my_dep<13.1,>=13.0.1
error: Could not find suitable distribution for Requirement.parse('my_dep<13.1,>=13.0.1')

Related

Wheel not built when pip installing from source - causes ModuleNotFoundError

I have written a python package mypackage , hosted on github, that I now want to install as a dependency to another project (specifically branch branch).
I can build it locally using setuptools and a pyproject.toml file by running python3 -m pip install . at the top of mypackage/ and can then successfully import it into python.
I pushed this to github and now try to install it using
python3 -m pip install "git+https://github.com/mygituser/mypackage.git#branch"
This runs without warning, and if I then run python3 -m pip list I can see mypackage listed there. However, if I enter python and run import mypackage I get the error ModuleNotFoundError: No module named 'mypackage'.
Comparing the verbose outputs I can see that for the local install after installing the dependencies I get
running bdist_wheel
running build
running build_py
running egg_info
writing mypackage/mypackage.egg-info/PKG-INFO
writing dependency_links to mypackage/mypackage.egg-info/dependency_links.txt
...
...
etc. which is absent for the github build process (this just ends after dependencies are installed).
Am I missing a setting in pyproject.toml or somewhere to tell it to build a wheel so I can import mypackage it in python?
I have tried appending with #egg=mypackage and adding wheel to the build dependencies, but none of this has worked.
TIA
In addition to the changes you made to your pyprojcet.toml file here: https://github.com/jatkinson1000/archeryutils/commit/f5fb491aa37961a65796ce4be3616d8be23548ed
You also need to include a __init__.py file in your round_data_files folder so it gets included in the package install.
https://github.com/jatkinson1000/archeryutils/pull/9

AWS beanstalk cant install psycopg2

I have issues deploying my Django application to AWS in the free tier during the pip installation of my requirements.txt.
As I could see here the issue seems to be related to scipy:
AWS Elastic Beanstalk failed to install Python package using requirements.txt Git Pip
The question has been resolved as he could uppgrade to t2.medium but this requires a paid account.
Is there any tip for the free tier?
Could an option like '--no-cache-dir' make it work ? Is there a way to force it (as the pip install is automatically done)
Is there any other way to deploy a Django application on AWS ?
EDIT: It is actually because of psycopg2..
Collecting psycopg2==2.8.4 (from -r /opt/python/ondeck/app/requirements.txt (line 4))
Downloading https://files.pythonhosted.org/packages/84/d7/6a93c99b5ba4d4d22daa3928b983cec66df4536ca50b22ce5dcac65e4e71/psycopg2-2.8.4.tar.gz (377kB)
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info/psycopg2.egg-info
writing pip-egg-info/psycopg2.egg-info/PKG-INFO
writing dependency_links to pip-egg-info/psycopg2.egg-info/dependency_links.txt
writing top-level names to pip-egg-info/psycopg2.egg-info/top_level.txt
writing manifest file 'pip-egg-info/psycopg2.egg-info/SOURCES.txt'
/usr/lib64/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'project_urls'
warnings.warn(msg)
warning: manifest_maker: standard file '-c' not found
Error: pg_config executable not found.
pg_config is required to build psycopg2 from source. Please add the directory
containing pg_config to the $PATH or specify the full executable path with the
option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
As per #phd comment : pip install psycopg2-binary did the trick instead of pip install psycopg2
Although I like the simplicity of the accepted solution, the psycopg2-binary installation notes advise against using it for production:
The binary package is a practical choice for development and testing but in production it is advised to use the package built from sources.
I don't know if this really is a big issue, but, for the sake of completeness, I'll add an alternative:
The Error: pg_config executable not found. can also be fixed by installing postgresql-devel using yum.
On Amazon Linux 2 you could do this using .platform hooks. For example, in you app repository (next to your .ebextensions), add a .platform/hooks/prebuild/01_install_yum_packages.sh file with the following content:
#!/bin/bash
yum -y install postgresql-devel
As described in the docs, you have to set execution permissions on this file before committing it to you repo. E.g. chmod +x 01_install_yum_packages.sh.

How to pip install package without building its' C extensions?

Is it possible to pip install package which provides optional C-extension, but specifically disable process of compiling those extensions?
Sample examples of such packages are:
_speedups in markupsafe
_posixsubprocess32 in subprocess32
It's not because it's setup.py that decides what and how to build. You have to download sources, unpack and edit setup.py to avoid building extensions.

Perplexing Python Package Predicament

First of all, I am running Python 2.7.5 on a Mac. I am trying to install a package and can't get it to work despite different approaches. The package is called python-fs-stack and is available here. https://pypi.python.org/pypi/python-fs-stack. I tried pip install python-fs-stack, sudo pip install python-fs-stack, easy_install python-fs-stack, sudo easy_install python-fs-stack and nothing worked. I then downloaded the package and got an error about a README.rst not being found. I commented out this line in the setup.py file and re-ran it. It got a lot farther, but then there was another error. Here is the output:
>>sudo python /Downloads/python-fs-stack-0.2/setup.py install
running install
running bdist_egg
running egg_info
writing python_fs_stack.egg-info/PKG-INFO
writing top-level names to python_fs_stack.egg-info/top_level.txt
writing dependency_links to python_fs_stack.egg-info/dependency_links.txt
warning: manifest_maker: standard file 'setup.py' not found
error: package directory 'familysearch' does not exist
I would really like to be able to get this package up and running, but I am at a loss. What should I try?

Heroku Django app development on Windows

I'm trying to start a Django app on Heroku using Windows and I'm getting stuck on the following error when I try to pip install psycopg2:
Downloading/unpacking psycopg2
Downloading psycopg2-2.4.5.tar.gz (719Kb): 719Kb downloaded
Running setup.py egg_info for package psycopg2
Error: pg_config executable not found.
Please add the directory containing pg_config to the PATH
or specify the full executable path with the option:
python setup.py build_ext --pg-config /path/to/pg_config build ...
or with the pg_config option in 'setup.cfg'.
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\psycopg2.egg-info
writing pip-egg-info\psycopg2.egg-info\PKG-INFO
writing top-level names to pip-egg-info\psycopg2.egg-info\top_level.txt
writing dependency_links to pip-egg-info\psycopg2.egg-info\dependency_links.txt
writing manifest file 'pip-egg-info\psycopg2.egg-info\SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
I've googled the error and it seems you need libpq-dev python-dev as dependencies for postgres under Python. I also turned up a link that says you gt into trouble if you don't have the postgres bin folder in your Path so I installed Postgres manually and tried again. This time I get:
error: Unable to find vcvarsall.bat
I am still a python N00b so I am lost. Could someone point me in a general direction?
You can use Cygwin and install all the dependencies, but I went through that issue last week and then I realized it was far easier to use a Virtual Box with Ubuntu as my Guest OS. I still did the development on Windows but used Ubuntu just to communicate/push to heroku
I found the answer to my problem. I believe the problem is that pip is looking to compile the dependency from source. The solution is to find a link to pre-compiled version of the dependency. You can then pass this link to the easyinstall library installed in your virtualenv. Easyinstall will download and install the pre-compiled version of the dependency.

Categories

Resources