{"id":21861610,"url":"https://github.com/elcorto/samplepkg","last_synced_at":"2025-10-13T09:39:18.372Z","repository":{"id":85816232,"uuid":"122079383","full_name":"elcorto/samplepkg","owner":"elcorto","description":"Skeleton python package to test setup.py and various ways to install a package using pip + setuptools + setup.py.","archived":false,"fork":false,"pushed_at":"2024-05-14T19:49:08.000Z","size":21,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T08:40:04.909Z","etag":null,"topics":["pip","python","setuptools","virtualenv"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/elcorto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-19T15:08:49.000Z","updated_at":"2024-07-02T06:50:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"2b39e7e1-421b-436a-bf28-3bea5f90029b","html_url":"https://github.com/elcorto/samplepkg","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/elcorto/samplepkg","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Fsamplepkg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Fsamplepkg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Fsamplepkg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Fsamplepkg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/elcorto","download_url":"https://codeload.github.com/elcorto/samplepkg/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/elcorto%2Fsamplepkg/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279014555,"owners_count":26085536,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["pip","python","setuptools","virtualenv"],"created_at":"2024-11-28T03:12:11.221Z","updated_at":"2025-10-13T09:39:18.356Z","avatar_url":"https://github.com/elcorto.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"About\n=====\n\nThis is a skeleton Python package to test `setup.py` and various ways\nof installing a Python package from a source tree and its dependencies (see\n`requirements.txt`) using `pip` + `setuptools` + `setup.py` + `venv`/`pipenv`.\nWe don't (yet) cover `pyproject.toml` or package managers other than\n`pip`, such as `conda`.\n\nThis repo is not a replacement for the [pypa sampleproject][sampleproject].\nRather, we use `installtest.sh` to install/uninstall the package in various\nways and analyze where files have been placed in order to understand how\ndifferent install methods affect the system. This is useful for situations\nwhere using `docker` or cheaper install env separation tech such as venvs is\nnot used and one still needs to separate manually installed packages from those\ninstalled by a system package manager such as `apt` on Debian. Also, this\nknowledge helps to debug situations such as \"Hey, I installed the `foo` package\nusing `$some_method` but my Python says `No module named 'foo'`. What's\nup?\".\n\nKey observations\n================\n\n* system `pip` installs into local site-packages\n  (`~/.local/lib/pythonX.Y/site-packages`, at least on Debian)\n* change `pip` install dir using `PYTHONUSERBASE`\n* `pip` copies the package (no `.egg` files)\n* `setup.py install` creates `.egg` files\n* `pip install -e` is the same as `setup.py develop`, creates a file\n  `\u003cpackage\u003e.egg-link` which points to the source tree\n* `venv --without-pip` uses system `pip` and does *not* install into\n  venv\n* dev install (`pip install -e`) doesn\\'t apply to dependencies (see\n  `requirements.txt`)\n* `pipenv` is a package manager for your dependencies, not an\n  installer for your project, use\n  `pipenv install \u0026\u0026 pipenv run pip install .`\n\nMany ways to create a venv\n--------------------------\n\n*Never* use `venv --without-pip` since this will use system `pip` and make the\nvenv ineffective! However, `venv --system-site-packages` is OK for access to\nsystem site package, but no packages will be installed there.\n\nThe recommended way to set up a venv is thus\n\n```sh\n$ cd /path/to/project\n\n# pure python\n$ python3 -m venv --symlinks [--system-site-packages] awesome_venv\n$ . ./awesome_venv/bin/activate\n(awesome_venv)$ pip install -r requirements.txt  # or pip install dep1 dep2 ...\n(awesome_venv)$ pip install [-e] .\n\n# virtualenvwrapper (--symlinks is default)\n$ mkvirtualenv [--system-site-packages] -p /usr/bin/python3 awesome_venv\n(awesome_venv)$ pip install -r requirements.txt\n(awesome_venv)$ pip install [-e] .\n\n# pipenv\n$ pipenv install\n# then either\n$ pipenv shell\n(project-08xy15foo)$ pip install .\n# or\n$ pipenv run pip install .\n```\n\npipenv\n------\n\nNote that `pipenv` installs venvs by default to `~/.virtualenvs` (e.g.\n`~/.virtualenvs/project-08xy15foo`, where `08xy15foo` is the hash of\n`/path/to/project`). Since `virtualenvwrapper` uses the same dir, you can\nremove venvs with `rmvirtualenv` as well. However, the command for leaving\n`pipenv`'s venv is `exit` instead of `deactivate`. While the latter also works,\nit may leave env vars such as `PIPENV_ACTIVE` behind.\n\nUsage\n=====\n\nAdapt `$version` in `installtest.sh` to your Python version. The script will\ninstall and uninstall the package using various methods and show where files\nare copied to. No `sudo` is used, so everything is happening in `$HOME`.\n\nThe script writes a log file `installtest.log` with detailed command\noutput.\n\nWe assume that we have a naming scheme for the package \"samplepkg\"\naccording to the [pypa sampleproject][sampleproject]\n\n    /path/to/samplepkg\n    /path/to/samplepkg/setup.py\n    /path/to/samplepkg/src/samplepkg/__init__.py\n    /path/to/samplepkg/src/samplepkg/foo.py\n\nIf not, then change `$pkgname` in the script.\n\nYou can also use `installtest.sh` on other projects.\n\n```sh\n$ cd /path/to/myproject\n$ /path/to/samplepkg/installtest.sh\n```\n\nResults from a run of `installtest.sh`, started from\n`/home/elcorto/soft/git/samplepkg/`:\n\n    pip3 install .\n                                                                which pip3 : /usr/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                         /home/elcorto/.local/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg/ samplepkg-1.2.3.dist-info/\n\n    PYTHONUSERBASE=/home/elcorto/soft pip3 install .\n                                                                which pip3 : /usr/bin/pip3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                           /home/elcorto/soft/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg/ samplepkg-1.2.3.dist-info/\n\n    PYTHONPATH=/home/elcorto/soft/lib/python3.7/site-packages/ python3 setup.py install --prefix=/home/elcorto/soft\n                                                                which pip3 : /usr/bin/pip3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                           /home/elcorto/soft/lib/python3.7/site-packages/ : dummy_test-0.1.3-py3.7.egg/ samplepkg-1.2.3-py3.7.egg\n           /home/elcorto/soft/lib/python3.7/site-packages/easy-install.pth : ./samplepkg-1.2.3-py3.7.egg ./dummy_test-0.1.3-py3.7.egg\n\n    pip3 install -e .\n                                                                which pip3 : /usr/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                         /home/elcorto/.local/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg.egg-link\n       /home/elcorto/.local/lib/python3.7/site-packages/samplepkg.egg-link : /home/elcorto/soft/git/samplepkg/src/\n         /home/elcorto/.local/lib/python3.7/site-packages/easy-install.pth : /home/elcorto/soft/git/samplepkg/src/\n\n    PYTHONUSERBASE=/home/elcorto/soft pip3 install -e .\n                                                                which pip3 : /usr/bin/pip3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                           /home/elcorto/soft/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg.egg-link\n         /home/elcorto/soft/lib/python3.7/site-packages/samplepkg.egg-link : /home/elcorto/soft/git/samplepkg/src/\n           /home/elcorto/soft/lib/python3.7/site-packages/easy-install.pth : /home/elcorto/soft/git/samplepkg/src/\n\n    PYTHONPATH=/home/elcorto/soft/lib/python3.7/site-packages/ python3 setup.py develop --prefix=/home/elcorto/soft\n                                                                which pip3 : /usr/bin/pip3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                           /home/elcorto/soft/lib/python3.7/site-packages/ : dummy_test-0.1.3-py3.7.egg/ samplepkg.egg-link\n         /home/elcorto/soft/lib/python3.7/site-packages/samplepkg.egg-link : /home/elcorto/soft/git/samplepkg/src/\n           /home/elcorto/soft/lib/python3.7/site-packages/easy-install.pth : /home/elcorto/soft/git/samplepkg/src/ ./dummy_test-0.1.3-py3.7.egg\n\n    python3.7 -m venv --without-pip --symlinks /home/elcorto/__test_venv__/; . /home/elcorto/__test_venv__/bin/activate; pip3 install .\n                                                                which pip3 : /usr/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                         /home/elcorto/.local/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg/ samplepkg-1.2.3.dist-info/\n\n    python3.7 -m venv --symlinks /home/elcorto/__test_venv__/; . /home/elcorto/__test_venv__/bin/activate; pip3 install .\n                                                                which pip3 : /home/elcorto/__test_venv__/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                  /home/elcorto/__test_venv__/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg/ samplepkg-1.2.3.egg-info/\n\n    PIPENV_VENV_IN_PROJECT=1 pipenv install . \u003e\u003e installtest.log 2\u003e\u00261; . ./.venv/bin/activate\n                                                                which pip3 : /home/elcorto/soft/git/samplepkg/.venv/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3\n                                      ./.venv/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/\n\n    PIPENV_VENV_IN_PROJECT=1 pipenv install -e . \u003e\u003e installtest.log 2\u003e\u00261; . ./.venv/bin/activate\n                                                                which pip3 : /home/elcorto/soft/git/samplepkg/.venv/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                                      ./.venv/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg.egg-link\n                    ./.venv/lib/python3.7/site-packages/samplepkg.egg-link : /home/elcorto/soft/git/samplepkg/src/\n                      ./.venv/lib/python3.7/site-packages/easy-install.pth : /home/elcorto/soft/git/samplepkg/src/\n\n    PIPENV_VENV_IN_PROJECT=1 pipenv install \u003e\u003e installtest.log 2\u003e\u00261; . ./.venv/bin/activate; pip3 install .\n                                                                which pip3 : /home/elcorto/soft/git/samplepkg/.venv/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                                      ./.venv/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg/ samplepkg-1.2.3.dist-info/\n\n    PIPENV_VENV_IN_PROJECT=1 pipenv install \u003e\u003e installtest.log 2\u003e\u00261; . ./.venv/bin/activate; pip3 install -e .\n                                                                which pip3 : /home/elcorto/soft/git/samplepkg/.venv/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                                      ./.venv/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg.egg-link\n                    ./.venv/lib/python3.7/site-packages/samplepkg.egg-link : /home/elcorto/soft/git/samplepkg/src/\n                      ./.venv/lib/python3.7/site-packages/easy-install.pth : /home/elcorto/soft/git/samplepkg/src/\n\n    (PIPENV_VENV_IN_PROJECT=1 pipenv install \u0026\u0026 pipenv run pip install .) \u003e\u003e installtest.log 2\u003e\u00261; . ./.venv/bin/activate\n                                                                which pip3 : /home/elcorto/soft/git/samplepkg/.venv/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3\n                                      ./.venv/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg/ samplepkg-1.2.3.dist-info/\n\n    (PIPENV_VENV_IN_PROJECT=1 pipenv install \u0026\u0026 pipenv run pip install -e .) \u003e\u003e installtest.log 2\u003e\u00261; . ./.venv/bin/activate\n                                                                which pip3 : /home/elcorto/soft/git/samplepkg/.venv/bin/pip3\n                                                                 pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                               PYTHONUSERBASE=/home/elcorto/soft pip3 list : dummy-test 0.1.3  samplepkg 1.2.3 /home/elcorto/soft/git/samplepkg/src\n                                      ./.venv/lib/python3.7/site-packages/ : dummy_test/ dummy_test-0.1.3.dist-info/ samplepkg.egg-link\n                    ./.venv/lib/python3.7/site-packages/samplepkg.egg-link : /home/elcorto/soft/git/samplepkg/src/\n                      ./.venv/lib/python3.7/site-packages/easy-install.pth : /home/elcorto/soft/git/samplepkg/src/\n\nUpload a package to pypi\n========================\n\nSee\n\n* \u003chttps://packaging.python.org/tutorials/packaging-projects/\u003e\n* \u003chttps://packaging.python.org/guides/using-testpypi/\u003e\n\nInstall pypa's upload tool `twine`.\n\n```sh\n# Debian-ish system\n$ sudo apt install twine\n# Any system\n$ pip install twine\n```\n\nBuild package data for upload to pypi.\n\nWith `setup.py`:\n\n```sh\n$ rm -rf build dist $(find . -name \"*.egg-info\")\n$ python3 setup.py sdist bdist_wheel\n```\n\nWith `pyproject.toml`:\n\nInstall the `build` tool first.\n\n```sh\n# Debian-ish system\n$ sudo apt install python3-build\n# Any system\n$ pip install build\n```\n\nBuild\n\n```sh\n$ rm -rf dist\n$ python3 -m build\n```\n\nTest\n\n```sh\n$ twine upload --repository testpypi dist/*\n\n$ mkvirtualenv foo\n\n# this may fail\n(foo) $ pip search --index https://test.pypi.org/simple mypackage\n\n# this usually works\n(foo) $ pip install --index-url https://test.pypi.org/simple [--no-deps] mypackage\n(foo) $ deactivate\n$ rmvirtualenv foo\n```\n\nReal upload\n\n```sh\n$ twine upload dist/*\n```\n\nor use this when using a pypi API token:\n\n```sh\n$ TWINE_USERNAME=__token__ TWINE_PASSWORD=pypi-xxxsupersecretyyy twine upload dist/*\n```\n\nIf you use https://www.passwordstore.org/, e.g.\n\n```sh\n$ pass pypi/api-token\npypi-xxxsupersecretyyy\n__token__\n```\n\nthen the above command reads\n\n```sh\n$ TWINE_USERNAME=__token__ TWINE_PASSWORD=$(pass pypi/api-token | head -n1) twine upload dist/*\n```\n\n[sampleproject]: https://github.com/pypa/sampleproject\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcorto%2Fsamplepkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Felcorto%2Fsamplepkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Felcorto%2Fsamplepkg/lists"}