I uploaded my package on pypi using this guide.
But it seems that there is an error with this line in setup.py
long-description=open(os.path.join(os.path.dirname(__file__),'README.md')).read()
which is giving me, on trying to install via pip
IO Error no such file or directory.
So how can I fix this? should a simple open('README.md')?
Is the long-description line really needed when I already have this in my setup.cfg
[metadata]
description-file = README.md
You need to add 'include README.md' in MANIFEST.in, if you do not have this file (the Manifest one), create it.
Just execute this on your repository root directory (where the setup.py file is located)
echo "include README.md" >> MANIFEST.in
Cheers.
Related
I am building an IronPython package that contains a config.ini file in the package directory. The config file is used to maintain user settings but when I try to update the file I get a permissions error:
IOError: System.IO.IOException: Access to the path 'C:\Program Files\IronPython 2.7\Lib\site-packages\...\_config.ini'
I have seen answers to similar questions which, for the most part, suggest running the command line as admin or using error='ignore with open.
with open(Paths.config_path, 'w+', errors='ignore') as configfile:
I don't want to tell my colleagues to run either the cmd.exe or their IDE as admin to use the package. I also don't want to just ignore the error and not update their settings. The basic structure worked fine for a similar CPython project and I would like to re-use the idea here. Is there a way to work around this?
In case it makes a difference:
I am building the package with ipy setup.py bdist_wheel
I use the MANIFEST.in to include the file. recursive-include proj *.ini
The setup file:
from setuptools import setup, find_packages
from prost import _meta
setup(name='...',
version=_meta.__version__,
packages=find_packages(),
include_package_data=True,
package_data={'prost': [r'bin/*.*', r'_config.ini']})
Thanks for the help.
Changed:
ipy -m pip install --upgrade my..-1.0.0.2-py2-none-any.whl
to
ipy -X:Frames -m pip install --upgrade dist\my..-1.0.0.2-py2-none-any.whl
and it worked.
I want to reuse some code for my internal team at work. My plan is to create a package and then have people install the package using pip straight out of our git repo. i.e. as shown here: https://pip.pypa.io/en/latest/reference/pip_install/#git
My question is, do I commit the dist folder to git? What is pip looking for?
Or is there a better way to share / reuse code internally for a team (across many different projects)?
I used a .gitignore file from here (is that github's default Python .gitignore file?) and it ignores all the dist files:
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
but it seems wrong to exclude these from the repo when I'm trying to install from the repo.
You do not need to commit the dist folder. pip really just needs the repository to have a setup.py file along with the packages and/or modules you're installing.
dist is a default name for a directory that contains the final build result: your project ready to be distributed, that is, packaged into a file which pip or other package managers know how to install:
$ python setup.py sdist --help
...
--dist-dir (-d) directory to put the source distribution archive(s) in
[default: dist]
So it is safe to ignore the directory and all of its contents in .gitignore. If you do not plan to upload you project's installation files to PyPI and intend to install it via passing Git url, you don't even need the dist directory and can safely delete it. It will be recreated anyway once you issue any dist command (sdist, bdist, bdist_wheel, bdist_rpm etc).
I have a python package ready for distribution on PyPI. To do this I am using twine as recommended on the in the Python docs. I have my setup.py file and this previously worked using the setup.py register upload command for my previous release.
To upload on to PyPi I am using:
python setup.py sdist
python setup.py bdist_wheel
twine upload dist\PyCoTools-2.1.2-py2-none-any.whl #this was created in the previous line
Now, on another computer I try using:
pip install PyCoTools
and it installs but then:
>>> import PyCoTools
Gives an import error. I go to the Libs/site-packages and all I see is this:
i.e. no folder called PyCoTools, just the dist info.
and inside that I just have
Which (obviously) doesn't incude the files that are in my package. Could anybody give me some pointers as to what I'm doing wrong?
Thanks
did you forget to put init.py inside your pyCoTools directory ? I had the same issue and I resolved it by adding this file.
To avoid specifying dependencies in two places, I have a Python project whose setup.py parses a requirements.txt file to generate the list of install_requires packages. This works great until I try to upload a wheel to a devpi server and then install it - I get the error that requirements.txt is not found.
Is it possible to build a distribution with the requirements.txt files next to setup.py? I've tried package_data and data_files, but the resulting distribution still didn't contain those files.
Just add a MANIFEST.in in the project folder with the content:
include requirements.txt
And it would include the file. You can also use wildcards like * too.
I'm trying to grasp the git(hub) way of managing software. I have a repository:
https://github.com/pythonishvili/django-inguri
And I try to pip install it with this command
pip install git+git://github.com/pythonishvili/django-inguri.git
The response I get:
Downloading/unpacking git+git://github.com/pythonishvili/django-inguri.git
Cloning git://github.com/pythonishvili/django-inguri.git to /tmp/pip-bv5r89-build
Running setup.py egg_info for package from git+git://github.com/pythonishvili/django-inguri.git
Installing collected packages: inguri
Running setup.py install for inguri
Successfully installed inguri
Cleaning up...
But installation went clearly wrong because all I get in my virtualenv (/home/username/.virtualenvs/envname/lib/python2.7/site-packages/inguri) are two files:
__init__.py
__init__.pyc
What did I do wrong? How do I make this work?
I believe you need to add all the subdirectories of your project to the packages option of your setup.py file. Right now, you have just the outermost directory - inguri. You would need to add inguri.ads, inguri.ads.migrations and so forth (as they contain .py files too which you want to include in your distribution).
You also need to add the following line in your manifest file: recursive-include inguri *