Last active
August 22, 2019 14:15
-
-
Save a-recknagel/72e819c35b6d5bac857f2118e1387c9e to your computer and use it in GitHub Desktop.
packaging and version fields
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__version__ = '1.2.3' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup | |
setup( | |
name='mypackage', | |
version='2.3.4', # this one actually doesn't matter, it's package metadata that is not related to source code | |
packages=['mypackage'] | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
~/mypackage$ python3 -m venv env | |
~/mypackage$ source env/bin/activate | |
# work in a new virtual env in order to be able to install and manipulate stuff | |
(env) ~/mypackage$ python -c "import mypackage; print(mypackage.__version__)" | |
1.2.3 | |
# python puts the call directory into sys.path, which is why it can find the file even though it isn't installed | |
(env) ~/mypackage$ cd .. | |
(env) ~$ python -c "import mypackage; print(mypackage.__version__)" | |
Traceback (most recent call last): | |
File "<string>", line 1, in <module> | |
ImportError: No module named mypackage | |
# the expected erronous output. when the package isn't installed, this is what should happen | |
(env) ~$ cd mypackage | |
(env) ~/mypackage$ python setup.py install | |
(env) ~/mypackage$ cd .. # go out again, so that we don't just run the local sources | |
(env) ~$ python -c "import mypackage; print(mypackage.__version__)" | |
1.2.3 | |
# it works | |
(env) ~$ pip uninstall -y mypackage | |
[...] # bla bla uninstalling | |
(env) ~$ cd mypackage | |
(env) ~/mypackage$ pip install . | |
(env) ~/mypackage$ cd .. # go out again, so that we don't just run the local sources | |
(env) ~$ python -c "import mypackage; print(mypackage.__version__)" | |
1.2.3 | |
# it works |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment