When running my setup.py a version.py file is created without the version specified in the file. How do I fix it so that a version is specified?
Here's my setup.py:
from setuptools import setup, find_packages
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.md'), encoding='utf-8') as f:
long_description = f.read()
def parse_requirements(filename):
lineiter = (line.strip() for line in open(filename))
return [line for line in lineiter if line and not line.startswith("#")]
install_reqs = parse_requirements(filename='requirements.txt')
setup(
name='eagle-py-framework', # Required
version=1.0, # Required
description='Eagle Python Framework', # Required
long_description=long_description, # Optional
author='asdf', # Optional
author_email='asdf',
url='asdf',
classifiers=[ # Optional
'Development Status :: 3 - Alpha',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
packages=find_packages(exclude=['contrib', 'docs', 'tests']), # Required
install_requires=install_reqs, # Optional
)
The command I'm using to run it is:
python setup.py sdist
The version.py file it creates only contains this:
__version__=
Use version as string
setup(
name='eagle-py-framework', # Required
version = "1.0", # Required #string
)
from here -> https://www.python.org/dev/peps/pep-0396/
3) When a module (or package) includes a version number, the version
SHOULD be available in the version attribute.
4) For modules which live inside a namespace package, the module
SHOULD include the version attribute. The namespace package itself
SHOULD NOT include its own version attribute.
5) The version attribute's value SHOULD be a string.
https://docs.python.org/2/distutils/setupscript.html
Related
I have a C++ project that I have successfully created a Python binding for using Swig. I am able to create a Pip installation for the Python binding of my overall project but it is failing to copy the shared object needed for the binding to work.
When creating a Python binding for a C++ project with Swig there is a shared library created as well as a .py file that acts as the callable definitions for the Python API (think of it as a ).
Here is an example of what my setup.py file looks like:
import setuptools
setuptools.setup(
name='example',
version='0.0.1',
author='me',
description='brief description',
keywords='example, pypi, package',
long_description=long_description,
long_description_content_type='text/markdown',
url='repo.com',
project_urls={
'Documentation': 'docs.com',
'Bug Reports':'repo/issues.com',
'Source Code': 'repo.com',
},
# location of Python API related files
package_dir={'': 'Python'},
packages=setuptools.find_packages(where='Python'),
package_data={'': ['path/to/_example.so']},
classifiers=[
# see https://pypi.org/classifiers/
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9',
'Programming Language :: Python :: 3.10',
'Programming Language :: Python :: 3 :: Only',
'Operating System :: OS Independent',
],
python_requires='>=3.6',
)
How can I modify my setup.py file to include the Swig binding creation process that creates a Pip package out of my project.
I have created a python library whose structure looks like this.
|/library_name
| |__init__.py
| |/subpackage
| | |__init__.py
| | |
|setup.py
|setup.cfg
|LICENSE
Now when i published in pypi, I couldn't see the inner subpackages installed along with it. What should I do? What should be in outer __init__.py. Assume inner __init__.py has classes which I have written. Somebody please help how to add subpackages to the python library.
Here's the setup.py format
setup(
name = 'package',
packages = ['package'],
version = '1.0.1',
license='GNU General Public Version 3',
description = 'Package is the open source Python Library for solving various AI needs',
long_description = long_description,
long_description_content_type = "text/markdown",
author = ['Vigneshwar K R'],
author_email = 'mymail#gmail.com',
url = 'https://github.com/ToastCoder/repo',
download_url = 'https://github.com/ToastCoder/repo/archive/master.zip',
keywords = ['ARTIFICIAL INTELLIGENCE', 'TENSORFLOW'],
install_requires=['tensorflow'],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'Intended Audience :: Education',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
)
Could you share said setup.py & __init__.py codes please ?
I see two ways to deal with this :
make the content from lib/submodule available from the top level : in lib/__init__.py add from submodule import *, then add every imported name in __all__. As far as i know, this is bad practice everywhere BUT inside of __init__.pys
add the submodule directory to setup.py's packages parameter : packages=["lib", "lib.submodule"]
edit: as i expected, submodule is missing from the packages parameter, so it is not considered needed.
the find_packages option commented about has the same effect as adding lib.submodule to the packages list, it is mainly used in large libraries where adding every single module manually would be a pain.
I tried having long_description print when I build my wheel, and it prints just fine. But when I upload to PyPi it doesn't show my long description there. Here's my setup.py, hopefully someone can help figure this out.
from setuptools import setup
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='matchmod',
version='1.2.1',
description='Simple Rust-like pattern matching for Python, with some added features',
long_description=long_description,
url='https://github.com/AN3223/rustlike-pattern-matching-for-python',
author='AN3223',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6',
],
keywords='rust rustlang procedural',
py_modules=['matchmod']
)
EDIT: I just realized I'm getting this error when building the wheel Error while finding module specification for 'setup.py' (AttributeError: module 'setup' has no attribute '__path__'), not sure what to do to solve this? I tried opening the file this way like the link from yausername suggested but still got the same error:
from pkg_resources import resource_string
long_description = resource_string(__name__, 'README.rst').decode('utf-8')
I've developed a chatbot project and this is the structure of its folder:
chatbot1:
__init__.py
__pycache__
build
chatbot_script.egg-info
dist
MANIFEST.in
package_data.dat
README.rst
setup.cfg
setup.py
stanford-postagger-full-2015-04-20
main_chatbot.py
Female_chatbot.py
Male_chatbot.py
arabic_const.py
normalize.py
stem_const.py
stemming.py
and this is the setup.py:
from setuptools import setup, find_packages
from codecs import open
from os import path
here = path.abspath(path.dirname(__file__))
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setup(name='chatbot_script',
version='1.2.0',
description='is a simple chatbot_script that uses simple matching ',
long_description=long_description,
url='https://github.com/pypi/chatbot_script',license='MIT', classifiers=
['Development Status :: 3 - Alpha','Intended Audience :: Developers',
'Topic :: Software Development :: Build Tools',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',],
keywords='sample setuptools development',
packages=find_packages(),
install_requires=['peppercorn'],
extras_require={
'dev': ['check-manifest'],
'test': ['coverage'],},
package_data={
'sample': ['package_data.dat'],},
entry_points={
'console_scripts': [
'sample=sample:main',],},)
I successfully upload the chatbot_script to PyPi and testPyPi. But when I download it there are only these files:
chatbot_script-1.2.0:
chatbot_script.egg-info
PKG-INFO
README.rst
setup.cfg
setup.py
Why I can't upload the other files?
Your main files should go in a wrapper folder
and in your MANIFEST.in you can include/exlude files
For example
File Structure:
chatbot1:
MANIFEST.in
setup.cfg
setup.py
README.rst
chatbot1:
<package files>
MANIFEST.in
recursive-include chatbot1 .*
graft chatbot1
prune chatbot1/unwanted_files
So, I've been trying this whole week to write a proper setup.py, and ended up with something like this:
#!/usr/bin/env python
from setuptools import setup
from codecs import open
from os import path
# Get the version number
from sql_tools2 import __version__
__author__ = 'Pandu POLUAN (pepoluan)'
__copyright__ = '(C) 2015, Pandu POLUAN'
__maintainer__ = 'pepoluan'
__email__ = 'pepoluan#gmail.com'
__status__ = 'Development'
__credits__ = ['pepoluan']
here = path.abspath(path.dirname(__file__))
# Get the long description from the README file
with open(path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
setup(
name='sql_tools2',
version=__version__,
description='Tools to manipulate and analyze SQL Queries before execution.',
long_description=long_description,
url='https://bitbucket.org/pepoluan/sqltools2',
author='Pandu POLUAN',
author_email='pepoluan#gmail.com',
license='MPL 2.0',
classifiers=[
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Intended Audience :: System Administrators',
'Programming Language :: SQL',
'Topic :: Software Development :: Quality Assurance',
'Topic :: Database',
'License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7'
],
keywords='sql subquery',
packages=['sql_tools2'],
install_requires=['sqlparse'],
extras_require={
'dev': ['pytest'],
'test': ['pytest'],
},
zip_safe=False
)
Now if I execute setup.py install, I see the module being installed.
However, another Python program (same virtualenv) cannot import:
>>> import sql_tools2
ImportError: no module named sql_tools2
I am using PyCharm as the IDE. Interestingly, if I type import and wait for auto-completion, PyCharm indeed offered sql_tools2 as one of the modules it recognized.
Where did I go wrong?