{ "info": { "author": "Daniel Chen", "author_email": "chendaniely@gmail.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3" ], "description": "# Find relative paths from a project root directory\n\nFinding project directories in Python (data science) projects, just like there R [`here`][here] and [`rprojroot`][rprojroot] packages.\n\n**Problem**: I have a project that has a specific folder structure,\nfor example, one mentioned in [Noble 2009][noble2009] or something similar to [this project template][project-template],\nand I want to be able to:\n\n1. Run my python scripts without having to specify a series of `../` to get to the `data` folder.\n2. `cd` into the directory of my python script instead of calling it from the root project directory and specify all the folders to the script.\n3. Reference datasets from a root directory when using a jupyter notebook because everytime I use a jupyter notebook,\n the working directory changes to the location of the notebook, not where I launched the notebook server.\n\n**Solution**: `pyprojroot` finds the root working directory for your project as a `pathlib` object.\nYou can now use the `here` function to pass in a relative path from the project root directory\n(no matter what working directory you are in the project),\nand you will get a full path to the specified file.\nThat is, in a jupyter notebook,\nyou can write something like `pandas.read_csv(here('./data/my_data.csv'))`\ninstead of `pandas.read_csv('../data/my_data.csv')`.\nThis allows you to restructure the files in your project without having to worry about changing file paths.\n\nGreat for reading and writing datasets!\n\n## Installation\n\n```bash\npip install pyprojroot\n```\n\n## Usage\n\n```python\nfrom pyprojroot import here\n\nhere()\n```\n\n### Example\n\nLoad the packages\n```\nIn [1]: from pyprojroot import here\nIn [2]: import pandas as pd\n```\n\nThe current working directory is the \"notebooks\" folder\n```\nIn [3]: !pwd\n/home/dchen/git/hub/scipy-2019-pandas/notebooks\n```\n\nIn the notebooks folder, I have all my notebooks\n```\nIn [4]: !ls\n01-intro.ipynb 02-tidy.ipynb 03-apply.ipynb 04-plots.ipynb 05-model.ipynb Untitled.ipynb\n```\n\nIf I wanted to access data in my notebooks I'd have to use `../data`\n```\nIn [5]: !ls ../data\nbillboard.csv country_timeseries.csv gapminder.tsv pew.csv table1.csv table2.csv table3.csv table4a.csv table4b.csv weather.csv\n```\n\nHowever, with there `here` function, I can access my data all from the project root.\nThis means if I move the notebook to another folder or subfolder I don't have to change the path to my data.\nOnly if I move the data to another folder would I need to change the path in my notebook (or script)\n```\nIn [6]: pd.read_csv(here('./data/gapminder.tsv'), sep='\\t').head()\nOut[6]:\n country continent year lifeExp pop gdpPercap\n0 Afghanistan Asia 1952 28.801 8425333 779.445314\n1 Afghanistan Asia 1957 30.332 9240934 820.853030\n2 Afghanistan Asia 1962 31.997 10267083 853.100710\n3 Afghanistan Asia 1967 34.020 11537966 836.197138\n4 Afghanistan Asia 1972 36.088 13079460 739.981106\n```\n\nBy the way, you get a `pathlib` object path back!\n```\nIn [7]: here('./data/gapminder.tsv')\nOut[7]: PosixPath('/home/dchen/git/hub/scipy-2019-pandas/data/gapminder.tsv')\n```\n\n[here]: https://github.com/r-lib/here\n[rprojroot]: https://github.com/r-lib/rprojroot\n[noble2009]: https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1000424\n[project-template]: https://chendaniely.github.io/sdal/2017/05/30/project_templates/\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/chendaniely/pyprojroot", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "pyprojroot", "package_url": "https://pypi.org/project/pyprojroot/", "platform": "", "project_url": "https://pypi.org/project/pyprojroot/", "project_urls": { "Homepage": "https://github.com/chendaniely/pyprojroot" }, "release_url": "https://pypi.org/project/pyprojroot/0.2.0/", "requires_dist": null, "requires_python": "", "summary": "Find project root paths and return relative project files", "version": "0.2.0" }, "last_serial": 5935309, "releases": { "0.1.1": [ { "comment_text": "", "digests": { "md5": "2af3da3165ed5d0a6c96c4f2a4816c74", "sha256": "a0e3d8edb35edd4f9d25ee30756d4bee3d8234ce625366ef54a706d0e9eb3d4c" }, "downloads": -1, "filename": "pyprojroot-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "2af3da3165ed5d0a6c96c4f2a4816c74", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4339, "upload_time": "2019-07-11T05:34:42", "url": "https://files.pythonhosted.org/packages/d9/48/18ef4260561d7ec27dd85a7ae03287cfc15376fdcdf41913c129f9475a1d/pyprojroot-0.1.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "8b03eb0b336f0f09d9ec52becfdcfc8d", "sha256": "ccd3f01b55a513e6ffcdbd4d94b9396948677b7385369a760b641f93b34a84f6" }, "downloads": -1, "filename": "pyprojroot-0.1.1.tar.gz", "has_sig": false, "md5_digest": "8b03eb0b336f0f09d9ec52becfdcfc8d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2937, "upload_time": "2019-07-11T05:34:44", "url": "https://files.pythonhosted.org/packages/d4/6b/6f2a54316a36a95a60236ad8cad782c05ce08846154fa4a95f42485c7f4e/pyprojroot-0.1.1.tar.gz" } ], "0.1.2": [ { "comment_text": "", "digests": { "md5": "79f9ea1da91aaf18a9323d176a4d4747", "sha256": "e620110e33ce5569f8b5247e39d70c84b85aba2395574927e71ea708b291c5a6" }, "downloads": -1, "filename": "pyprojroot-0.1.2-py3-none-any.whl", "has_sig": false, "md5_digest": "79f9ea1da91aaf18a9323d176a4d4747", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 4348, "upload_time": "2019-07-26T23:29:54", "url": "https://files.pythonhosted.org/packages/f0/20/02d6b5b3dacb8f4d5e11405dc2b1b2ab04504142412b14c4ce73a6301811/pyprojroot-0.1.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "074ebb40d08f98383c053e4490985866", "sha256": "4849c4e11beef9e66631f5cd77868b8ee7ecf6f3cedcb363104314613a1d24cf" }, "downloads": -1, "filename": "pyprojroot-0.1.2.tar.gz", "has_sig": false, "md5_digest": "074ebb40d08f98383c053e4490985866", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2954, "upload_time": "2019-07-26T23:29:55", "url": "https://files.pythonhosted.org/packages/70/5b/91d65bb2edd4cf4214cf44aec41c384063f37e6b22858f55163f8f803cb4/pyprojroot-0.1.2.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "d01a3763047f7e5b20ff7b8e706889a3", "sha256": "741e8b4878a0d6bb6b06ec09aa05797130289e2127aa595b8f1cbadce697909f" }, "downloads": -1, "filename": "pyprojroot-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d01a3763047f7e5b20ff7b8e706889a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5203, "upload_time": "2019-10-06T17:00:56", "url": "https://files.pythonhosted.org/packages/5a/f5/dfbe49718595ff62be70e001b85e58a125928e93bf60f8bb6b7b94280e39/pyprojroot-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "226c9e9c0b0340fd3d57cff1aedcc44b", "sha256": "a79900dc52ee097bfd8d917a3d45e2b98494c47a57ba3a71bf609d7a156732e8" }, "downloads": -1, "filename": "pyprojroot-0.2.0.tar.gz", "has_sig": false, "md5_digest": "226c9e9c0b0340fd3d57cff1aedcc44b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3765, "upload_time": "2019-10-06T17:00:57", "url": "https://files.pythonhosted.org/packages/46/61/9ea2c7197c67a554f0222677ab6f43985babb05555e4bef85fa77275020c/pyprojroot-0.2.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d01a3763047f7e5b20ff7b8e706889a3", "sha256": "741e8b4878a0d6bb6b06ec09aa05797130289e2127aa595b8f1cbadce697909f" }, "downloads": -1, "filename": "pyprojroot-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "d01a3763047f7e5b20ff7b8e706889a3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5203, "upload_time": "2019-10-06T17:00:56", "url": "https://files.pythonhosted.org/packages/5a/f5/dfbe49718595ff62be70e001b85e58a125928e93bf60f8bb6b7b94280e39/pyprojroot-0.2.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "226c9e9c0b0340fd3d57cff1aedcc44b", "sha256": "a79900dc52ee097bfd8d917a3d45e2b98494c47a57ba3a71bf609d7a156732e8" }, "downloads": -1, "filename": "pyprojroot-0.2.0.tar.gz", "has_sig": false, "md5_digest": "226c9e9c0b0340fd3d57cff1aedcc44b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 3765, "upload_time": "2019-10-06T17:00:57", "url": "https://files.pythonhosted.org/packages/46/61/9ea2c7197c67a554f0222677ab6f43985babb05555e4bef85fa77275020c/pyprojroot-0.2.0.tar.gz" } ] }