Does pip install work with single module projects? - python

I just refactored my Python project to be a single top-level module rather than a package.
However, pip install does not work anymore: I get an error which says:
(forcelib_test) C:\code>pip install git+https://github.com/blokeley/forcelib
Collecting git+https://github.com/blokeley/forcelib
Cloning https://github.com/blokeley/forcelib to c:\users\tomoak~1\appdata\local\temp\pip-t10zegic-build
Complete output from command python setup.py egg_info:
running egg_info
creating pip-egg-info\forcelib.egg-info
writing pip-egg-info\forcelib.egg-info\PKG-INFO
writing dependency_links to pip-egg-info\forcelib.egg-info\dependency_links.txt
writing requirements to pip-egg-info\forcelib.egg-info\requires.txt
writing top-level names to pip-egg-info\forcelib.egg-info\top_level.txt
writing manifest file 'pip-egg-info\forcelib.egg-info\SOURCES.txt'
warning: manifest_maker: standard file '-c' not found
error: package directory 'forcelib' does not exist
I'm not trying to install a package called forcelib, only a module. The setup.py script correctly uses the py_modules argument rather than packages.
Is it possible to install a single module or do I have to revert to using a package?
Note: this question is about a different problem. They want to install an additional text file. I just want to install the single Python module. In fact, that question implies that what I'm trying to do should work without the error I got

I needed to use
py_modules=['forcelib']
Rather than what I had which was
py_modules=['forcelib.py']

Related

setup.py does not find package installed via conda

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')

how to exclude source code from bdist_wheel python

We want to exclude the Python source code from the package we create. But after configuring setup.py, I failed excluding the py files. I have been using python setup.py bdist_wheel as command. Is there any way to exclude to source code from Python package? Basically we do not want to expose the source codes.
The wheel plugin for setuptools that handles bdist_wheel does not have the --exclude_source_files which is only supported by bdist_egg. The egg packages are however deprecated and not supported by pip for example. What you can do however:
pip3 install wheel
python3 setup.py bdist_egg --exclude-source-files
wheel convert dist/mypackage-1.0-py3.6.egg
The wheel utility takes a source-stripped egg and converts it into whl package.
This came up for us putting Python libs on an embedded system with very minimal available memory.
It can be achieved with:
./setup.py bdist_egg --exclude_source_files
Works for both distutils and setuptools.
Well, we also encountered this issue (around 2 years ago) and didn't find a sensible automation process for it. So I wrote my own.
You're welcomed to it: setup.py template

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?

Python Install of Dropbox SDK Fails

I have the same problem as here.
Dropbox Python SDK installation error on Windows 7 (could not create 'build')
The user didn't say how they fixed the issue (I have tried starting again, and reinstalling Python). I asked the user to elaborate and my post was deleted because I wasn't answering the question. Sorry, I'm new here. But re-posting seems counter intuitive to me.
Here goes...
I installed Python 2.7, then downloaded and tried to run setup.py of the Dropbox Python SDK.
It asked me to add the setuptools, so I did, and then tried to install the Dropbox setup.py from a CMD. After which I got the below...
C:\Python27\dropbox-python-sdk-1.5.1>setup.py install
running install
running bdist_egg
running egg_info
writing dropbox_python_sdk.egg-info\PKG-INFO
writing top-level names to dropbox_python_sdk.egg-info\top_level.txt
writing dependency_links to dropbox_python_sdk.egg-info\dependency_links.txt
reading manifest file 'dropbox_python_sdk.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'dropbox_python_sdk.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
error: could not create 'build': Cannot create a file when that file already exists
C:\Python27\dropbox-python-sdk-1.5.1>
What have I done wrong? I know it hasn't installed because the Dropbox module isn't there.
I'm using Windows Server 2008 64bit if that helps.
Answer as per piokuc's comment. He/She did not mark an answer (for quite some time) so I am leaving it here for others to find.
"Remove the build directory you see complaints about. – piokuc"
I found that trying to install the Dropbox python module without 'Easy Install' if fails, leaving the Dropbox module install half finished. Simply delete the file in question and start again.

setuptools searching for false dependency

I am running into a bizarre problem where I try to install my python package (using setuptools) on a Linux system and it tries to install pywin32 as a dependency. This only happens if I run it from a specific directory. If I move the whole tree to a different directory, it installs fine.
My setup.py does reference pywin32 for win32 platforms, but even when I remove this it makes no difference. I've also removed all the other requirements without any change in behavior. My setup.py has nothing in it other than setuptools initialization and a call to setup().
I have a virtualenv active and have tried switching to a new clean virtualenv without a change in behavior. I see the following when I run setup.py develop:
python setup.py develop
running develop
running egg_info
deleting foo.egg-info/requires.txt
writing foo.egg-info/PKG-INFO
writing top-level names to foo.egg-info/top_level.txt
writing dependency_links to foo.egg-info/dependency_links.txt
reading manifest file 'foo.egg-info/SOURCES.txt'
writing manifest file 'foo.egg-info/SOURCES.txt'
running build_ext
Creating /home/user/foo-env2/lib/python2.7/site-packages/foo.egg-link (link to .)
foo 1.0 is already the active version in easy-install.pth
Installed /home/user/magicdirectory/magic
Processing dependencies for foo==1.0
Searching for pywin32
Reading http://pypi.python.org/simple/pywin32/
Reading http://sf.net/projects/pywin32
Now, I may have accidentally tried to install a win32 egg of this package at some point, but that was in the original virtual environment and I can't figure out what it could have done to cause this.
How do I debug this? Where else could setuptools be searching for dependencies from?
UPDATE: It appears that it's not the name of the directory that matters, but where it is. If I move the package directory up one level, it will install fine. The directory in question here has been deleted and recreated multiple times so it doesn't appear to be related to anything inside the directory.
Try removing the *.egg-info in the dist develop directory. If that doesn't work, try starting with a fresh, untouched checkout of your code without any of the other setuptools/dist artifacts and see if that reproduces the problem. If it doesn't then you know it's one of the setuptools/dist artifacts that just needs to be cleaned up.

Categories

Resources