navdeep-G/setup.py

Cannot read the the version file

alexanderepstein opened this issue · 6 comments

I have my directory structure like so

setup.py
MANIFEST.in
LICENSE
README.md
pipfile
pipfile.lock
cryptowatch:
    - cryptowatch
    - __version__.py
    - __init__.py
    - utlitiesFile.py

When I run python setup.py I am given this error:

Traceback (most recent call last):
  File "setup.py", line 25, in <module>
    with open(os.path.join(here, NAME, '__version__.py')) as f:
IOError: [Errno 2] No such file or directory: '/home/fsociety/git/bitbucket/cryptowatch/crypotowatch/__version__.py'

I know I have a file there and I even went as far as making it executable with chmod a+x __version__.py but sill no luck.

Is there something I am doing wrong here?

I have modified the setup.py a little but only information not the actual code, just in case I screwed something up while doing that here it is:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import codecs
import os
import sys

from setuptools import find_packages, setup

# Package meta-data.
NAME = 'crypotowatch'
DESCRIPTION = 'Track prices and account balaces bitcoin, ethereum, and litecoin'
URL = 'https://github.com/alexanderepstein/cryptowatch'
EMAIL = 'epsteina@wit.edu'
AUTHOR = 'Alexander Epstein'

here = os.path.abspath(os.path.dirname(__file__))

# Import the README and use it as the long-description.
with codecs.open(os.path.join(here, 'README.md'), encoding='utf-8') as f:
    long_description = '\n' + f.read()

# Load the package's __version__.py module as a dictionary.
about = {}
with open(os.path.join(here, NAME, "__version__.py")) as f:
    exec(f.read(), about)

# Support "$ setup.py publish".
if sys.argv[-1] == "publish":
    os.system("python setup.py sdist bdist_wheel upload")
    sys.exit()

# What packages are required for this module to be executed?
required = [
     'requests', 'Adafruit_GPIO'
]

# Dependencies only for versions less than Python 2.7:
# if sys.version_info < (2, 7):
#     required.append('requests[security]')

# Where the magic happens:
setup(
    name=NAME,
    version=about['__version__'],
    description=DESCRIPTION,
    long_description=long_description,
    author=AUTHOR,
    author_email=EMAIL,
    url=URL,
    packages=find_packages(exclude=('tests',)),
#     entry_points={
#         'console_scripts': ['mycli=mymodule:cli'],
#     },
    install_requires=required,
    include_package_data=True,
    license='MIT',
    classifiers=[
        'License :: OSI Approved :: MIT License',
        'Programming Language :: Python',
        'Programming Language :: Python :: 2.6',
        'Programming Language :: Python :: 2.7',
        'Programming Language :: Python :: Implementation :: CPython',
        'Programming Language :: Python :: Implementation :: PyPy'
    ],
)

I think __version__.py and __init__.py should be inside of cryptowatch, which should be at your root, not inside of another cryptowatch.

Ok that seemed to work after I also changed where it was reading version.py from back to the original but now I am hit with this

usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
   or: setup.py --help [cmd1 cmd2 ...]
   or: setup.py --help-commands
   or: setup.py cmd --help

error: no commands supplied

Doesn't seem like an error just like I'm misusing setup.py.

Additionally if i have a directory structure like Directory_Struct.png
How can I use this file as an installer that allows people to call the cryptowatch file directly and also the cryptoUtils and the cwConfig but not any of the files used inside of cryptoPie. I only want my other python files to be able to access them directly, is there a setup that allows for something like this?

So i split out the modules into separate folder and changed around my import calls. What i think i understand now is by changing the entrypoint inside of the setup.py will determine which file and function is called when the user inputs my package name into the terminal, is this correct.

My new dir tree looks like this

fsociety@whiterose:~/git/cryptowatch$ tree
.
├── cryptoConsole
│   ├── cryptowatch.py
│   └── __init__.py
├── cryptoPie
│   ├── Adafruit_CharLCD.py
│   ├── cryptoPie.py
│   └── __init__.py
├── __init__.py
├── LICENSE
├── MANIFEST.in
├── Pipfile
├── Pipfile.lock
├── README.md
├── setup.py
├── utils
│   ├── cryptoUtils.py
│   ├── cryptoUtilspython2.py
│   ├── cwconfig.py
│   └── __init__.py
└── __version__.py

and I have changed the entry point inside of setup.py to this

    entry_points={
        'console_scripts': ['cryptowatch=cryptoConsole.cryptowatch:main'],
    },

Basically I am trying to make it so that s after the install occurs when the user calls cryptowatch from the command line I want it to run the main function inside of cryptoConsole/cryptowatch.py. Inside of cryptowatch.py I make a call to cryptoPie.py and other files in the utils folder. However I would not like the user to be able to call cryptoPie from the terminal directly. I am alright with it being possible to call it programatically after importing it with import cryptowatch.cryptoPie as this seems unavoidable. I have tried to understand using the link you provided but it doesn't really explain exactly what I am trying to achieve I ended up using https://docs.python.org/3/tutorial/modules.html as a basis for the changes I have made

Sorry for asking the question here, I know this isn't exactly the right place but I figure you have more knowledge on this than I and nothing I search seems to exactly answer what I want

Actually I tested it with setup.py install and it seems to be working fine :) thanks so much for the help